CN115834972A - Subtitle color adjusting method and device, electronic equipment and storage medium - Google Patents

Subtitle color adjusting method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115834972A
CN115834972A CN202211644210.5A CN202211644210A CN115834972A CN 115834972 A CN115834972 A CN 115834972A CN 202211644210 A CN202211644210 A CN 202211644210A CN 115834972 A CN115834972 A CN 115834972A
Authority
CN
China
Prior art keywords
color
subtitle
video image
determining
caption
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211644210.5A
Other languages
Chinese (zh)
Inventor
王玮
徐俊
曹军
丁艳燕
国丽
王兆育
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anhui Tingjian Technology Co ltd
Original Assignee
Anhui Tingjian Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anhui Tingjian Technology Co ltd filed Critical Anhui Tingjian Technology Co ltd
Priority to CN202211644210.5A priority Critical patent/CN115834972A/en
Publication of CN115834972A publication Critical patent/CN115834972A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Processing Of Color Television Signals (AREA)

Abstract

The invention provides a subtitle color adjusting method, a subtitle color adjusting device, electronic equipment and a storage medium, and relates to the technical field of video processing, wherein the subtitle color adjusting method comprises the following steps: carrying out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; determining a first set of all first pixel points with colors matched with the colors of the second caption in the second video image; determining a second set of all pixel points within a preset distance from the first pixel point in the second video image; determining a subtitle background area of the first video image based on the union of each second set and the first set; the first subtitle color is adjusted based on the color of the subtitle background region. The determined caption background area is an area which is extended outwards by a preset distance from the caption area, and the color of the picture near the caption area is used as an adjustment basis for the color of the first caption in the first video image, so that the identification degree of the caption is improved.

Description

Subtitle color adjusting method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of video processing technologies, and in particular, to a method and an apparatus for adjusting a subtitle color, an electronic device, and a storage medium.
Background
With the rapid rise of short video platforms, video subtitle production has become a rigid requirement of video bloggers. The mainstream caption platform in the market only supports the superposition of text captions, and when the background color of the video is close to the caption color, the captions cannot be seen clearly, so that the watching experience of a user is influenced. Therefore, how to adjust the subtitle color becomes particularly important.
In the related art, an area where a caption is located is usually determined as a caption area, the color depth of the caption area is determined based on the color value of each pixel point in the caption area, and when the color of the caption area is lighter, the color of the caption is set to be black; when the color of the subtitle region is dark, the subtitle color is set to white.
However, in the related art, the color of the subtitle is adjusted based on the color value of each pixel point in the subtitle region, which may reduce the recognition degree of the subtitle.
Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for adjusting a subtitle color, an electronic device, and a storage medium.
The invention provides a subtitle color adjusting method, which comprises the following steps:
carrying out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first caption color based on the color of the caption background region.
According to a method for adjusting a caption color provided by the present invention, the determining a first set of all first pixel points whose colors are matched with the second caption color in a second video image includes:
determining a coordinate system based on a resolution of the second video image; each coordinate point in the coordinate system corresponds to each pixel point in the second video image one by one; the coordinate value of the coordinate point is matched with the color value of the corresponding pixel point;
determining first pixel points corresponding to all coordinate points of which the coordinate values are matched with a first preset value in the coordinate system as the first set; the first preset value is a color value of the second caption color.
According to a method for adjusting a color of a subtitle, the adjusting the first subtitle color based on the color of the subtitle background region includes:
aiming at each pixel point in the caption background region, determining a corresponding gray value based on the color value of the pixel point;
determining a first gray value of the subtitle background area based on a gray value corresponding to each pixel point in the subtitle background area;
determining a second gray value of the subtitle corresponding to the first video image based on the first gray value;
adjusting the first subtitle color based on the second gray value.
According to a method for adjusting color of subtitles provided by the present invention, the determining a second gray scale value of subtitles corresponding to the first video image based on the first gray scale value includes:
when the first gray value is determined to be larger than or equal to a second preset value, determining the difference value between the first gray value and the second preset value as the second gray value;
and when the first gray value is determined to be smaller than the second preset value, determining the sum of the second preset value and the first gray value as the second gray value.
According to a method for adjusting a color of a subtitle provided by the present invention, the adjusting the color of the first subtitle based on the second gray scale value includes:
deleting the first subtitle color corresponding to the first video image;
determining a target color based on the second gray value;
and determining the target color as the new first subtitle color.
According to a method for adjusting caption color provided by the present invention, the determining a caption background area of the first video image based on the union of each second set and the first set includes:
and determining the difference set of the union set and the first set as a subtitle background area of the first video image.
According to a method for adjusting caption color provided by the present invention, the pure color processing of the first video background color of the first video image and the corresponding first caption color includes:
and when the difference value between the gray value corresponding to the first video background color and the gray value corresponding to the first caption color is determined to be less than or equal to a third preset value, performing pure color processing on the first video background color of the first video image and the corresponding first caption color.
The present invention also provides a subtitle color adjusting apparatus, comprising:
the processing unit is used for carrying out pure color processing on a first video background color of the first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
the first determining unit is used for determining a first set of all first pixel points with colors matched with the colors of the second caption in the second video image;
a second determining unit, configured to determine, for each of the first pixel points, a second set of all pixel points within a preset distance from the first pixel point in the second video image;
a third determining unit, configured to determine a subtitle background region of the first video image based on the union of each second set and the first set;
an adjusting unit, configured to adjust the first subtitle color based on the color of the subtitle background region.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the subtitle color adjusting method.
The invention also provides an electronic device, which comprises a display, a memory, a processor and a computer program, wherein the computer program is stored in the memory and can run on the processor; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first subtitle color based on the color of the subtitle background region;
the display is used for displaying the first video image after the color of the first caption is adjusted.
The present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a subtitle color adjustment method as described in any one of the above.
The present invention also provides a computer program product comprising a computer program, which when executed by a processor, implements the method for adjusting a subtitle color as described in any one of the above.
The method, the device, the electronic equipment and the storage medium for adjusting the caption color provided by the invention are characterized in that firstly, pure color processing is carried out on a first video background color of a first video image and a corresponding first caption color to obtain a second video image with a second video background color and a second caption color different from the second caption color, then a first set of all first pixel points matched with the second caption color is determined from the second video image, a second set of pixel points within a preset distance from each first pixel point is determined, finally, a caption background area of the first video image is determined based on a union set of the second sets and the first set, and the first caption color is adjusted based on the color of the caption background area. Therefore, the determined subtitle background area is an area which is extended from the subtitle area by a preset distance, and the color of the picture near the subtitle area is used as an adjustment basis for the color of the first subtitle in the first video image, so that the identification degree of the subtitle is improved.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a flowchart illustrating a method for adjusting a subtitle color according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a coordinate system provided by an embodiment of the present invention;
fig. 3 is a second flowchart illustrating a subtitle color adjustment method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a video image provided by an embodiment of the invention;
fig. 5 is a schematic structural diagram of a subtitle color adjusting apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention;
fig. 7 is a second schematic physical structure diagram of an electronic device according to an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The subtitle color adjustment method of the present invention is described below with reference to fig. 1-3.
Fig. 1 is a schematic flow chart of a caption color adjustment method according to an embodiment of the present invention, and as shown in fig. 1, the caption color adjustment method includes the following steps:
step 101, performing pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; the second video background color and the second subtitle color of the second video image are different.
Illustratively, the FFmpeg is a set of open-source computer programs which can be used for recording and converting digital audio and video and can convert the digital audio and video into streams, and can extract a subtitle file and a video file corresponding to a target video based on the FFmpeg, analyze the video file to obtain each first video image in the target video, analyze the subtitle file to obtain a first subtitle color corresponding to each subtitle text information in the target video; performing pure color processing on each first subtitle color, namely modifying each first subtitle color into a second subtitle color, for example, the second subtitle color is pure black, so as to obtain a modified subtitle file; and performing pure color processing on the first video background color of each first video image, namely modifying the first video background color of each first video image into a second video background color, for example, the second video background color is pure white to obtain modified video images, each modified video image forms a modified video file, and then introducing the modified subtitle files into the modified video files to obtain new videos, wherein the second subtitle color is pure black, and the second video background color is pure white as an example, the obtained new videos are videos with white video backgrounds and black subtitle colors.
It should be noted that, when the subtitle file is parsed, coordinate information of each subtitle display area, subtitle text information corresponding to each subtitle display area, and time period information for displaying the subtitle text information can also be obtained; for example, the length of the target video is 1 minute, the target video includes 3 subtitle text information, which are subtitle text information 1, subtitle text information 2, and subtitle text information 3, respectively, the subtitle text information 1 is displayed for the first 30 seconds, the subtitle text information 2 is displayed for the middle 20 seconds, and the subtitle text information 3 is displayed for the last 10 seconds.
And 102, determining a first set of all first pixel points with the color matched with the color of the second caption in the second video image.
For example, for each second video image in the new video, the second video image includes a subtitle corresponding to a second video background color and a second subtitle color, all first pixel points having a color same as that of the second subtitle may be determined in the second video image, and a set of all the first pixel points is used as a first set.
Step 103, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image for each first pixel point.
The preset distance may be set based on a requirement, for example, the preset distance is a distance of 3 pixels.
Illustratively, when a first set is obtained, performing outward expansion based on each first pixel point in the first set, that is, determining a second set of all pixel points within a preset distance from the first pixel point in a second video image; for example, if the preset distance is 3 pixels, the second set includes all pixels 3 pixels away from the first pixel.
And 104, determining a subtitle background area of the first video image based on the union of each second set and the first set.
Optionally, a difference set between the union set and the first set is determined as a subtitle background region of the first video image.
For example, when a second set corresponding to each first pixel point is obtained, the second sets corresponding to all the first pixel points are subjected to union processing to obtain a union of all the second sets, and then a difference set between the union and the first set is determined as a subtitle background area of the first video image.
And 105, adjusting the first subtitle color based on the color of the subtitle background area.
For example, when determining the subtitle background region corresponding to the first video image, the first subtitle color corresponding to the first video image may be adaptively adjusted based on the overall color of the subtitle background region.
The method for adjusting the caption color comprises the steps of firstly, carrying out pure color processing on a first video background color of a first video image and a corresponding first caption color to obtain a second video image with a second video background color and a second caption color different from the second caption color, then determining a first set of all first pixel points matched with the second caption color from the second video image, determining a second set of pixel points within a preset distance from each first pixel point, finally determining a caption background area of the first video image based on a union set of the second sets and the first set, and adjusting the first caption color based on the color of the caption background area. Therefore, the determined subtitle background area is an area which is extended from the subtitle area by a preset distance, and the color of the picture near the subtitle area is used as an adjustment basis for the color of the first subtitle in the first video image, so that the identification degree of the subtitle is improved.
In an embodiment, the step 102 may be specifically implemented by:
determining a coordinate system based on a resolution of the second video image; each coordinate point in the coordinate system corresponds to each pixel point in the second video image one by one; the coordinate value of the coordinate point is matched with the color value of the corresponding pixel point;
determining first pixel points corresponding to all coordinate points of which the coordinate values are matched with a first preset value in the coordinate system as the first set; the first preset value is a color value of the second caption color.
For example, a coordinate system may be established based on the resolution of the second video image, that is, a coordinate system is established with the length of the second video image as an X axis and the height of the second video image as a Y axis, where coordinate points in the coordinate system correspond to pixel points in the second video image in a one-to-one manner, and the coordinate values of the coordinate points may be red, green, blue (RGB) values or print Color Mode (CMYK) values of the corresponding pixel points, where RGB values are taken as an example below, and a first set of all coordinate values RGB (0, 0) in the coordinate system is denoted as Z (all points in the area where the caption is located) with the second caption color being pure black and the second video background color being pure white as an example.
The subtitle color adjusting method provided by the embodiment of the invention determines the first set for indicating all pixel points in the region of the subtitle based on the method for determining the coordinate system, and the determination mode is simple and convenient
In an embodiment, determining the second set of all the pixels within the preset distance from the first pixel may specifically be implemented in the following manner:
determining a target area based on the coordinate point corresponding to the first pixel point and the preset distance; and determining pixel points corresponding to all coordinate points in the target area as the second set.
Exemplarily, fig. 2 is a schematic diagram of a coordinate system according to an embodiment of the present invention, as shown in fig. 2, taking a coordinate point a in a first set Z as an example, taking the coordinate point a as a center of a circle, taking a preset distance as a radius, for example, taking a distance of 3 pixels as a radius, drawing a circle to obtain a circular region 201, where the circular region 201 is a target region, and determining pixel points corresponding to all coordinate points in the circular region 201 as a second set, that is, the second set includes the coordinate point a and a region where the coordinate point a extends outward by 3 pixels. All RGB (0, 0) coordinate points are processed in the same way, and the area of each coordinate point which is extended outwards by 3 pixel points is obtained. And merging all coordinate points and the corresponding regions of the 3 pixels which are outwards expanded to obtain a union set, marking the union set as B, wherein the union set B comprises the regions of the 3 pixels which are outwards expanded by the characters in the subtitles and all the pixels in the regions of the characters, and making a difference set between the union set B and the first set Z to obtain a second set C.
Specifically, after a single coordinate point (x, y) is extended outward by 3 pixel points, the solving method of all coordinate points in the area is as follows:
as shown in fig. 2, firstly, a tangent square 202 corresponding to a circular area 201 is constructed, and coordinate points corresponding to four corners of the tangent square 202 are respectively a coordinate point L, a coordinate point M, a coordinate point Y and a coordinate point N, where a coordinate value of the coordinate point L is (x-3, Y-3), a coordinate value of the coordinate point M is (x-3, Y + 3), a coordinate value of the coordinate point Y is (x +3, Y-3), and a coordinate value of the coordinate point N is (x +3, Y + 3); traversing all the coordinate points in the tangent square 202 area, if the distance from the coordinate point a (x, y) is less than or equal to 3, then the pixel point corresponding to the coordinate point is marked as a pixel point in the second set, for example, if the distance from the coordinate point K to the coordinate point a (x, y) is less than 3, then the coordinate point K is a pixel point in the second set, and if the distance from the coordinate point E to the coordinate point a (x, y) is greater than 3, then the coordinate point E is not a pixel point in the second set, until each pixel point in the second set, that is, each pixel point in the circular area 201, is determined.
It should be noted that, when the target region is determined based on the coordinate point corresponding to the first pixel point and the preset distance, the preset distance may be subtracted from the preset value in the X-axis direction, and the preset distance is added to the preset value in the Y-axis direction, so that the obtained target region is a rectangular region, and a set of pixel points corresponding to all the coordinate points in the rectangular region is determined as a second set, which is not limited in the present invention.
According to the subtitle color adjusting method provided by the embodiment of the invention, the target area is determined based on the coordinate point corresponding to the first pixel point and the preset distance, the second set used for indicating all the pixel points including the first pixel point and the first pixel point extending the preset distance outwards is determined by traversing the target area, and the determining mode is simple and convenient.
In an embodiment, fig. 3 is a second flowchart of a subtitle color adjustment method according to an embodiment of the present invention, and as shown in fig. 3, the step 105 may be implemented by:
step 1051, aiming at each pixel point in the caption background area, determining a corresponding gray value based on the color value of the pixel point.
The gray value ranges from 0 to 256 and is used for representing the brightness of an image, the higher the value is, the higher the brightness is, the 0 represents pure black, and the 256 represents pure white.
Exemplarily, in a caption background region where a first video image is obtained, for each pixel point in the caption background region, calculating a gray value of the pixel point based on a color value of the pixel point; for example, the calculation formula is gray scale value gray = R0.299 + g 0.587+ b 0.114, and if the color value of a pixel in the caption background region is RGB (158, 204, 98), the gray scale value gray scale =158 + 0.299+ 204.587 +98 + 0.114=178.162 of the pixel.
Step 1052, determining a first gray value of the subtitle background area based on the gray value corresponding to each pixel point in the subtitle background area.
Exemplarily, when a gray value corresponding to each pixel point in the subtitle background region is obtained, an average value obtained by adding and averaging the gray values corresponding to all the pixel points in the subtitle background region is determined as a first gray value of the subtitle background region; or determining the product of the average value and an empirical coefficient value as the first gray value of the caption background area.
And 1053, determining a second gray value of the subtitle corresponding to the first video image based on the first gray value.
For example, when the first gray value of the subtitle background region is obtained, the brightness of the subtitle background region is determined, and further, the brightness of the subtitle corresponding to the first video image can be determined based on the brightness of the subtitle background region; namely, when the subtitle background area is darker, the subtitle corresponding to the first video image can be lightened; when the subtitle background area is bright, the subtitle corresponding to the first video image can be dimmed. That is, a second gray value of the subtitle corresponding to the first video image is determined based on the first gray value.
And 1054, adjusting the color of the first caption based on the second gray value.
For example, when the second gray value of the subtitle corresponding to the first video image is determined, the value of each color channel corresponding to the first subtitle color may be modified to the second gray value, thereby implementing the adjustment of the first subtitle color. For example, if the second gray value is 128, the RGB value of the adjusted first subtitle color is RGB (128 ); fig. 4 is a schematic diagram of a video image according to an embodiment of the present invention, as shown in fig. 4, a background color of the video image is entirely dark, and a subtitle color is directly adjusted to white in the related art, and as can be seen from fig. 4, a picture near an area 401 where a subtitle is located is white, if the subtitle color is directly adjusted to white, the recognition degree of the subtitle by a user is also affected, so that the area 401 where the subtitle is located is enlarged, that is, a subtitle background area of a first video image determined by the present invention is 402, and a color value of a pixel point of the picture near the area 401 where the subtitle is located is also taken into consideration, so that accuracy of calculating a first gray value of the subtitle background area 402 can be improved, and further, accuracy of a second gray value of the subtitle corresponding to the first video image is improved, that the color of the subtitle corresponding to the first video image is also improved, as shown in fig. 4, a color of the subtitle finally determined can be gray, and compared with white, the recognition degree of the subtitle by the user is improved.
The subtitle color adjusting method provided by the embodiment of the invention adaptively adjusts the first subtitle color of the subtitle corresponding to the first video image based on the brightness degree of the subtitle background area, and realizes the method for adaptively and dynamically adjusting the subtitle color according to the subtitle background color, thereby improving the identification degree of the subtitle.
In an embodiment, the determining the second gray scale value of the subtitle corresponding to the first video image based on the first gray scale value may be specifically implemented by:
when the first gray value is determined to be greater than or equal to a second preset value, determining the difference value between the first gray value and the second preset value as the second gray value;
and when the first gray value is determined to be smaller than the second preset value, determining the sum of the second preset value and the first gray value as the second gray value.
The second preset value may be set based on experience, for example, the second preset value is 128.
For example, when the difference between the gray value of the subtitle color and the gray value of the subtitle background region is 128, the resolution of the subtitle is the best, and the contrast between the subtitle color and the subtitle background is not too strong, assuming that the second gray value is set to D and the first gray value of the subtitle background region is P, the calculation method is as follows: when the first gradation value P is greater than or equal to 128, the second gradation value = P-128; when the first gradation value P is less than 128, the second gradation value = P +128. For example, setting the 16-ary value of the binary grayscale value D to KK, the 16-ary color may be represented as #0000KK.
According to the subtitle color adjusting method provided by the embodiment of the invention, the second gray value can be determined according to the first gray value and the preset value for indicating the best resolution, so that the accuracy of the second gray value is improved, and the accuracy of the first subtitle color adjustment is further improved.
In an embodiment, the adjusting the color of the first subtitle based on the second gray scale value may be specifically implemented by:
deleting the first subtitle color corresponding to the first video image;
determining a target color based on the second gray value;
and determining the target color as the new first subtitle color.
Illustratively, when a second gray value of a subtitle corresponding to a first video image is determined, a first subtitle color corresponding to the first video image is deleted from a subtitle file, then the value of each color channel is modified into the second gray value to obtain a target color, and the target color is written into the subtitle file as a new first subtitle color; according to the same method, the first caption color corresponding to each first video image in the target video is modified, the modified caption file is finally obtained, and the modified caption file is further imported into the video file corresponding to the target video, so that the self-adaptive adjustment of the caption color is realized. For example, if the second gray value is 128, the RGB value of the adjusted first subtitle color is RGB (128 ).
The subtitle color adjusting method provided by the embodiment of the invention realizes the adjustment of the first subtitle color based on the second gray value, and the adjusting mode is simple and convenient.
In an embodiment, the step 101 may be specifically implemented by:
and when the difference value between the gray value corresponding to the first video background color and the gray value corresponding to the first caption color is determined to be less than or equal to a third preset value, performing pure color processing on the first video background color of the first video image and the corresponding first caption color.
Illustratively, when the target video is acquired, for each first video image in the target video, a gray value corresponding to a first video background color of the first video image and a gray value corresponding to a first subtitle color may be calculated first, then a difference between the gray value corresponding to the first video background color and the gray value corresponding to the first subtitle color is calculated, and then the difference is compared with a third preset value, when it is determined that the difference is less than or equal to the third preset value, it indicates that a difference between the first video background color and the first subtitle color is small, and the first subtitle color may not be seen by a user, so that the first video background color of the first video image and the corresponding first subtitle color need to be subjected to pure color processing, and subsequent steps are performed to adjust the subtitle color; when the difference value is determined to be larger than the third preset value, the difference between the first video background color and the first caption color is larger, and the user can clearly see the first caption color without executing the step of caption color adjustment.
According to the subtitle color adjusting method provided by the embodiment of the invention, the subtitle color adjusting step is executed only when the difference value between the gray value corresponding to the first video background color and the gray value corresponding to the first subtitle color is smaller than or equal to the third preset value, so that the accuracy of subtitle color adjustment is improved.
The following describes the caption color adjusting device provided by the present invention, and the caption color adjusting device described below and the caption color adjusting method described above may be referred to correspondingly.
Fig. 5 is a schematic structural diagram of a caption color adjusting apparatus according to an embodiment of the present invention, and as shown in fig. 5, the caption color adjusting apparatus 500 includes a processing unit 501, a first determining unit 502, a second determining unit 503, a third determining unit 504, and an adjusting unit 505, where:
the processing unit 501 is configured to perform pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
a first determining unit 502, configured to determine a first set of all first pixel points in a second video image, where colors of the first pixel points are matched with colors of the second subtitle;
a second determining unit 503, configured to determine, for each first pixel, a second set of all pixels in the second video image that are within a preset distance from the first pixel;
a third determining unit 504, configured to determine a subtitle background region of the first video image based on the union of each second set and the first set;
an adjusting unit 505, configured to adjust the first subtitle color based on the color of the subtitle background region.
The subtitle color adjusting device provided by the invention firstly carries out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image with a second video background color and a second subtitle color different from the first subtitle color, then determines a first set of all first pixel points matched with the second subtitle color from the second video image, determines a second set of pixel points within a preset distance from each first pixel point, finally determines a subtitle background area of the first video image based on a union set of the second sets and the first set, and adjusts the first subtitle color based on the color of the subtitle background area. Therefore, the determined subtitle background area is an area which is extended from the subtitle area by a preset distance, and the color of the picture near the subtitle area is used as an adjustment basis for the color of the first subtitle in the first video image, so that the identification degree of the subtitle is improved.
Based on any of the above embodiments, the first determining unit 502 is specifically configured to:
determining a coordinate system based on a resolution of the second video image; each coordinate point in the coordinate system corresponds to each pixel point in the second video image one by one; the coordinate value of the coordinate point is matched with the color value of the corresponding pixel point;
determining first pixel points corresponding to all coordinate points of which the coordinate values are matched with a first preset value in the coordinate system as the first set; the first preset value is a color value of the second caption color.
Based on any of the above embodiments, the adjusting unit 505 is specifically configured to:
aiming at each pixel point in the caption background region, determining a corresponding gray value based on the color value of the pixel point;
determining a first gray value of the subtitle background area based on a gray value corresponding to each pixel point in the subtitle background area;
determining a second gray value of the subtitle corresponding to the first video image based on the first gray value;
adjusting the first subtitle color based on the second gray value.
Based on any of the above embodiments, the adjusting unit 505 is further specifically configured to:
when the first gray value is determined to be greater than or equal to a second preset value, determining the difference value between the first gray value and the second preset value as the second gray value;
and when the first gray value is determined to be smaller than the second preset value, determining the sum of the second preset value and the first gray value as the second gray value.
Based on any of the above embodiments, the adjusting unit 505 is further specifically configured to:
deleting the first subtitle color in the first video image;
determining a target color based on the second gray value;
and determining the target color as the new first subtitle color.
Based on any of the above embodiments, the third determining unit 504 is specifically configured to:
and determining the difference set of the union set and the first set as a subtitle background area of the first video image.
Based on any of the above embodiments, the processing unit 501 is specifically configured to:
and when the difference value between the gray value corresponding to the first video background color and the gray value corresponding to the first caption color is determined to be less than or equal to a third preset value, performing pure color processing on the first video background color of the first video image and the corresponding first caption color.
Fig. 6 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 6, the electronic device may include: a processor (processor) 610, a communication Interface (Communications Interface) 620, a memory (memory) 630 and a communication bus 640, wherein the processor 610, the communication Interface 620 and the memory 630 communicate with each other via the communication bus 640. Processor 610 may invoke logic instructions in memory 630 to perform a method of subtitle color adjustment, the method comprising: carrying out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first caption color based on the color of the caption background region.
In addition, the logic instructions in the memory 630 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Fig. 7 is a second schematic physical structure diagram of an electronic device according to an embodiment of the present invention, as shown in fig. 7, the electronic device may include: a processor (processor) 710, a communication Interface (Communications Interface) 720, a memory (memory) 730, a communication bus 740, and a display 750, wherein the processor 710, the communication Interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to perform the caption color adjustment method, and the processor 710 performs pure color processing on the first video background color of the first video image and the corresponding first caption color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first subtitle color based on the color of the subtitle background region;
the display 750 is configured to display the first video image with the adjusted first subtitle color.
In addition, the logic instructions in the memory 730 can be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, a computer is capable of executing the subtitle color adjusting method provided by the above methods, the method including: carrying out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first caption color based on the color of the caption background region.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program, which when executed by a processor, is implemented to perform the method for adjusting the color of a subtitle provided by the above methods, the method comprising: carrying out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first caption color based on the color of the caption background region.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (12)

1. A method for adjusting a color of a subtitle, comprising:
carrying out pure color processing on a first video background color of a first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first caption color based on the color of the caption background region.
2. The method of claim 1, wherein the determining a first set of all first pixels in the second video image whose color matches the second caption color comprises:
determining a coordinate system based on a resolution of the second video image; each coordinate point in the coordinate system corresponds to each pixel point in the second video image one by one; the coordinate value of the coordinate point is matched with the color value of the corresponding pixel point;
determining first pixel points corresponding to all coordinate points of which the coordinate values are matched with a first preset value in the coordinate system as the first set; the first preset value is a color value of the second caption color.
3. The method of claim 1, wherein the adjusting the first caption color based on the color of the caption background region comprises:
aiming at each pixel point in the caption background region, determining a corresponding gray value based on the color value of the pixel point;
determining a first gray value of the subtitle background area based on a gray value corresponding to each pixel point in the subtitle background area;
determining a second gray value of the subtitle corresponding to the first video image based on the first gray value;
adjusting the first subtitle color based on the second gray value.
4. The method of claim 3, wherein the determining a second gray value of the subtitle corresponding to the first video image based on the first gray value comprises:
when the first gray value is determined to be greater than or equal to a second preset value, determining the difference value between the first gray value and the second preset value as the second gray value;
and when the first gray value is determined to be smaller than the second preset value, determining the sum of the second preset value and the first gray value as the second gray value.
5. The method of adjusting caption color according to claim 3, wherein the adjusting the first caption color based on the second gray scale value comprises:
deleting the first subtitle color corresponding to the first video image;
determining a target color based on the second gray value;
and determining the target color as a new first subtitle color.
6. The method of any of claims 1-5, wherein the determining the subtitle background region for the first video image based on the union of each of the second sets and the first set comprises:
and determining the difference set of the union set and the first set as a subtitle background area of the first video image.
7. The method for adjusting caption color according to any one of claims 1-5, wherein the performing pure color processing on the first video background color of the first video image and the corresponding first caption color comprises:
and when the difference value between the gray value corresponding to the first video background color and the gray value corresponding to the first caption color is determined to be less than or equal to a third preset value, performing pure color processing on the first video background color of the first video image and the corresponding first caption color.
8. A subtitle color adjustment apparatus, comprising:
the processing unit is used for carrying out pure color processing on a first video background color of the first video image and a corresponding first subtitle color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
the first determining unit is used for determining a first set of all first pixel points with colors matched with the colors of the second caption in the second video image;
a second determining unit, configured to determine, for each of the first pixel points, a second set of all pixel points within a preset distance from the first pixel point in the second video image;
a third determining unit, configured to determine a subtitle background region of the first video image based on the union of each second set and the first set;
an adjusting unit, configured to adjust the first subtitle color based on the color of the subtitle background region.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the subtitle color adjustment method according to any one of claims 1 to 7 when executing the program.
10. An electronic device, comprising a display, a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor performs a pure color process on a first video background color of a first video image and a corresponding first caption color to obtain a second video image; a second video background color and a second subtitle color of the second video image are different;
determining a first set of all first pixel points with colors matched with the colors of the second caption in a second video image;
for each first pixel point, determining a second set of all pixel points within a preset distance from the first pixel point in the second video image;
determining a subtitle background area of the first video image based on the union of each second set and the first set;
adjusting the first subtitle color based on the color of the subtitle background region;
the display is used for displaying the first video image after the color of the first caption is adjusted.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the subtitle color adjustment method according to any one of claims 1 to 7.
12. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the subtitle color adjustment method according to any one of claims 1 to 7.
CN202211644210.5A 2022-12-20 2022-12-20 Subtitle color adjusting method and device, electronic equipment and storage medium Pending CN115834972A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211644210.5A CN115834972A (en) 2022-12-20 2022-12-20 Subtitle color adjusting method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211644210.5A CN115834972A (en) 2022-12-20 2022-12-20 Subtitle color adjusting method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115834972A true CN115834972A (en) 2023-03-21

Family

ID=85517167

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211644210.5A Pending CN115834972A (en) 2022-12-20 2022-12-20 Subtitle color adjusting method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115834972A (en)

Similar Documents

Publication Publication Date Title
US11138695B2 (en) Method and device for video processing, electronic device, and storage medium
US8417032B2 (en) Adjustment of image luminance values using combined histogram
US8059899B2 (en) Image processing apparatus, image processing method, and computer product
US20210281718A1 (en) Video Processing Method, Electronic Device and Storage Medium
CN111739041B (en) Image frame clipping method, device and equipment
CN108009997B (en) Method and device for adjusting image contrast
CN113596573B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN111064942B (en) Image processing method and apparatus
CN107424137B (en) Text enhancement method and device, computer device and readable storage medium
US8165421B2 (en) Method and apparatus for image processing by using stored image
US8036459B2 (en) Image processing apparatus
CN113034509A (en) Image processing method and device
US20080013849A1 (en) Video Processor Comprising a Sharpness Enhancer
US20150271416A1 (en) Information Processing Method and Electronic Device
US7375770B2 (en) Method for luminance transition improvement
CN110796689B (en) Video processing method, electronic device and storage medium
JP3950551B2 (en) Image processing method, apparatus, and recording medium
US20170019568A1 (en) Information processing apparatus, method for processing information, and computer program
CN115834972A (en) Subtitle color adjusting method and device, electronic equipment and storage medium
EP3360321B1 (en) Projection apparatus, projection system, program, and non-transitory computer-readable recording medium
US20220044369A1 (en) Image processing method, terminal and non-transitory computer-readable storage medium
CN113283543B (en) WebGL-based image projection fusion method, device, storage medium and equipment
CN113507572A (en) Video picture display method, device, terminal and storage medium
CN110941413B (en) Display screen generation method and related device
JP2018195262A (en) Image processing apparatus, image processing method, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination