Subtitle color adjustment method, device, electronic device and storage medium
By performing solid color processing on the background and subtitle color of the video image, determining the subtitle background area and adjusting the subtitle color, the problem of low subtitle recognition is solved and the user experience is improved.
Patent Information
- Application Number
- CN202211644210.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-12-20
AI Technical Summary
With existing subtitle processing technology, when the background color is similar to the subtitle color, subtitle recognition is reduced, affecting the user's viewing experience.
By performing solid color processing on the background color and subtitle color of the video image, the subtitle background area is determined, and the subtitle color is adjusted based on the color value of the area, and the subtitle area is expanded to improve recognition.
Improved subtitle recognition and enhanced user viewing experience.
Smart Images

Figure CN115834972B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video processing, and in particular to a subtitle color adjustment method, device, electronic equipment and storage medium. Background Art
[0002] With the rapid rise of short video platforms, video subtitle production has become a rigid demand for video bloggers. The mainstream subtitle platforms on the market only support the superposition of text subtitles. When the video background color is similar to the subtitle color, the subtitles cannot be seen clearly, affecting the user's viewing experience. Therefore, how to adjust the subtitle color becomes particularly important.
[0003] In the related art, the area where the subtitles are located is usually determined as the subtitle area, and the color depth of the subtitle area is determined based on the color value of each pixel in the subtitle area. When the color of the subtitle area is lighter, the subtitle color is set to black; when the color of the subtitle area is darker, the subtitle color is set to white.
[0004] However, in the above-mentioned related technologies, adjusting the subtitle color based on the color value of each pixel in the subtitle area will reduce the recognition of the subtitles. Summary of the invention
[0005] In view of the problems existing in the prior art, the embodiments of the present invention provide a subtitle color adjustment method, device, electronic device and storage medium.
[0006] The present invention provides a subtitle color adjustment method, comprising:
[0007] Performing pure color processing on a first video background color and a corresponding first subtitle color of the first video image to obtain a second video image; wherein a second video background color and a second subtitle color of the second video image are different;
[0008] Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color;
[0009] For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point;
[0010] determining a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0011] The first subtitle color is adjusted based on the color of the subtitle background area.
[0012] According to a subtitle color adjustment method provided by the present invention, the step of determining a first set of all first pixel points in a second video image whose colors match the second subtitle color comprises:
[0013] A coordinate system is determined based on the resolution of the second video image; each coordinate point in the coordinate system corresponds one-to-one to each pixel point in the second video image; and the coordinate value of the coordinate point matches the color value of the corresponding pixel point;
[0014] The first pixel points corresponding to all coordinate points in the coordinate system whose coordinate values match a first preset value are determined as the first set; the first preset value is the color value of the second subtitle color.
[0015] According to a subtitle color adjustment method provided by the present invention, the adjusting the first subtitle color based on the color of the subtitle background area includes:
[0016] For each pixel in the subtitle background area, determining a corresponding grayscale value based on the color value of the pixel;
[0017] Determine a first grayscale value of the subtitle background area based on the grayscale value corresponding to each pixel in the subtitle background area;
[0018] Determining a second grayscale value of a subtitle corresponding to the first video image based on the first grayscale value;
[0019] The first subtitle color is adjusted based on the second grayscale value.
[0020] According to a subtitle color adjustment method provided by the present invention, determining a second grayscale value of a subtitle corresponding to the first video image based on the first grayscale value includes:
[0021] When it is determined that the first grayscale value is greater than or equal to a second preset value, determining a difference between the first grayscale value and the second preset value as the second grayscale value;
[0022] When it is determined that the first grayscale value is less than the second preset value, the sum of the second preset value and the first grayscale value is determined as the second grayscale value.
[0023] According to a subtitle color adjustment method provided by the present invention, the adjusting the first subtitle color based on the second grayscale value includes:
[0024] deleting the first subtitle color corresponding to the first video image;
[0025] determining a target color based on the second grayscale value;
[0026] The target color is determined as the new first subtitle color.
[0027] According to a subtitle color adjustment method provided by the present invention, the determining of the subtitle background area of the first video image based on the union of each of the second sets and the first set includes:
[0028] A difference between the union and the first set is determined as a subtitle background area of the first video image.
[0029] According to a subtitle color adjustment method provided by the present invention, the first video background color of the first video image and the corresponding first subtitle color are processed into pure colors, including:
[0030] When it is determined that the difference between the grayscale value corresponding to the first video background color and the grayscale value corresponding to the first subtitle color is less than or equal to a third preset value, the first video background color of the first video image and the corresponding first subtitle color are subjected to pure color processing.
[0031] The present invention also provides a subtitle color adjustment device, comprising:
[0032] A processing unit, configured to perform pure color processing on a first video background color and a corresponding first subtitle color of a first video image to obtain a second video image; wherein a second video background color and a second subtitle color of the second video image are different;
[0033] A first determining unit, configured to determine a first set of all first pixel points in a second video image whose colors match the second subtitle color;
[0034] 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;
[0035] a third determining unit, configured to determine a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0036] An adjusting unit is used to adjust the first subtitle color based on the color of the subtitle background area.
[0037] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned subtitle color adjustment methods is implemented.
[0038] The present invention also provides 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 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 of the second video image is different from the second subtitle color;
[0039] Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color;
[0040] For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point;
[0041] determining a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0042] adjusting the first subtitle color based on the color of the subtitle background area;
[0043] The display is used for displaying the first video image after adjusting the color of the first subtitle.
[0044] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned subtitle color adjustment methods is implemented.
[0045] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the subtitle color adjustment method described above is implemented.
[0046] The subtitle color adjustment method, device, electronic device and storage medium provided by the present invention firstly perform pure color processing on the first video background color and the corresponding first subtitle color of the first video image to obtain a second video image whose second video background color and second subtitle color are different, then determine a first set of all first pixel points matching the second subtitle color from the second video image, and determine a second set of pixel points within a preset distance from each first pixel point, and finally determine the subtitle background area of the first video image based on the union of the second set and the first set, and adjust the first subtitle color based on the color of the subtitle background area. It can be seen that the subtitle background area determined in the present invention is an area extending outward from the subtitle area by a preset distance, and the color of the screen near the subtitle area is used as the basis for adjusting the first subtitle color in the first video image, thereby improving the recognition of the subtitles. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 This is one of the flow charts of the subtitle color adjustment method provided by an embodiment of the present invention;
[0049] Figure 2 is a schematic diagram of a coordinate system provided by an embodiment of the present invention;
[0050] Figure 3 This is a second flow chart of the subtitle color adjustment method provided by an embodiment of the present invention;
[0051] Figure 4 is a schematic diagram of a video image provided by an embodiment of the present invention;
[0052] Figure 5 is a structural schematic diagram of a subtitle color adjustment device provided by an embodiment of the present invention;
[0053] Figure 6 It is one of the physical structure diagrams of the electronic device provided by the embodiment of the present invention;
[0054] Figure 7 This is the second schematic diagram of the physical structure of the electronic device provided by the embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] Combine the following Figure 1-Figure 3 The subtitle color adjustment method of the present invention is described.
[0057] Figure 1 FIG. 1 is a flow chart of a subtitle color adjustment method provided by an embodiment of the present invention. Figure 1 As shown, the subtitle color adjustment method includes the following steps:
[0058] Step 101: Perform pure color processing on a first video background color and a corresponding first subtitle color of a first video image to obtain a second video image; a second video background color and a second subtitle color of the second video image are different.
[0059] For example, FFmpeg is a set of open source computer programs that can be used to record, convert digital audio and video, and convert them into streams. Based on FFmpeg, the subtitle file and video file corresponding to the target video can be extracted, the video file can be parsed to obtain each first video image in the target video, and the subtitle file can be parsed to obtain the first subtitle color corresponding to each subtitle text information in the target video; each first subtitle color is processed with a pure color, that is, each first subtitle color is modified to a second subtitle color, for example, the second subtitle color is pure black, and a modified subtitle file is obtained; and the first video background color of each first video image is processed with a pure color, that is, the first video background color of each first video image is modified to a second video background color, for example, the second video background color is pure white, and a modified video image is obtained. Each modified video image constitutes a modified video file, and then the modified subtitle file is imported into the modified video file to obtain a new video. Taking the second subtitle color as pure black and the second video background color as pure white as an example, the new video obtained is a video with a white video background and a black subtitle color.
[0060] It should be noted that when parsing the subtitle file, the coordinate information of each subtitle display area, the subtitle text information corresponding to each subtitle display area, and the time period information of the subtitle text information display can also be obtained; for example, the length of the target video is 1 minute, and the target video includes 3 subtitle text information, namely subtitle text information 1, subtitle text information 2 and subtitle text information 3. Subtitle text information 1 is displayed in the first 30 seconds, subtitle text information 2 is displayed in the middle 20 seconds, and subtitle text information 3 is displayed in the last 10 seconds.
[0061] Step 102: Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color.
[0062] For example, for each second video image in a new video, the second video image includes subtitles corresponding to the second video background color and the second subtitle color. All first pixel points having the same color as the second subtitle color can be determined in the second video image, and the set of all first pixel points is taken as the first set. Since the second video background color and the second subtitle color are pure colors of different colors, all first pixel points included in the first set are all pixel points in the area where the subtitles are located.
[0063] Step 103: for each of the first pixel points, determine in the second video image a second set of all pixel points within a preset distance from the first pixel point.
[0064] The preset distance may be set based on demand, for example, the preset distance is a distance of 3 pixels.
[0065] For example, when obtaining the first set, expansion is performed based on each first pixel point in the first set, that is, a second set of all pixel points within a preset distance from the first pixel point is determined in the second video image; for example, if the preset distance is 3 pixels, the second set includes all pixel points that are 3 pixels away from the first pixel point.
[0066] Step 104: determine the subtitle background area of the first video image based on the union of each of the second sets and the first set.
[0067] Optionally, a difference between the union and the first set is determined as a subtitle background area of the first video image.
[0068] For example, when the second set corresponding to each first pixel point is obtained, the second sets corresponding to all the first pixel points are unioned to obtain the union of all the second sets, and then the difference between the union and the first set is determined as the subtitle background area of the first video image. Because the background of the area where the subtitles are located is itself covered by the subtitles, removing the first set indicating the area where the subtitles are located can improve the grayscale calculation accuracy of the subtitle background area.
[0069] Step 105: Adjust the first subtitle color based on the color of the subtitle background area.
[0070] For example, when determining the subtitle background area corresponding to the first video image, the color of the first subtitle corresponding to the first video image may be adaptively adjusted based on the overall color of the subtitle background area.
[0071] The subtitle color adjustment method provided by the present invention first performs pure color processing on the first video background color and the corresponding first subtitle color of the first video image to obtain a second video image with a second video background color different from the second subtitle color, and then determines a first set of all first pixel points matching the second subtitle color from the second video image, and determines a second set of pixel points within a preset distance from each first pixel point, and finally determines the subtitle background area of the first video image based on the union of the second set and the first set, and adjusts the first subtitle color based on the color of the subtitle background area. It can be seen that the subtitle background area determined in the present invention is an area extending outward from the subtitle area by a preset distance, and the color of the screen near the subtitle area is used as the basis for adjusting the first subtitle color in the first video image, thereby improving the recognition of the subtitles.
[0072] In one embodiment, the above step 102 may be implemented in the following manner:
[0073] A coordinate system is determined based on the resolution of the second video image; each coordinate point in the coordinate system corresponds one-to-one to each pixel point in the second video image; and the coordinate value of the coordinate point matches the color value of the corresponding pixel point;
[0074] The first pixel points corresponding to all coordinate points in the coordinate system whose coordinate values match a first preset value are determined as the first set; the first preset value is the color value of the second subtitle color.
[0075] For example, a coordinate system can be established based on the resolution of the second video image, that is, the coordinate system is established with the length of the second video image as the X-axis and the height of the second video image as the Y-axis. The coordinate points in the coordinate system correspond one-to-one to the pixel points in the second video image, and the coordinate values of the coordinate points can be the red, green, and blue (RGB) values or the printing color mode (CMYK) values of the corresponding pixel points. The following takes the RGB value as an example, and takes the second subtitle color as pure black and the second video background color as pure white as an example. The first set of all coordinate values in the coordinate system of RGB (0,0,0) is recorded as Z (all points in the area where the subtitles are located).
[0076] The subtitle color adjustment method provided by the embodiment of the present invention determines the first set of all pixel points in the area where the subtitle is located based on the method of determining the coordinate system. The determination method is simple and convenient.
[0077] In one embodiment, determining the second set of all pixels within a preset distance from the first pixel may be specifically implemented in the following manner:
[0078] Determine a target area based on the coordinate point corresponding to the first pixel point and the preset distance; and determine the pixel points corresponding to all the coordinate points in the target area as the second set.
[0079] For example, Figure 2 is a schematic diagram of a coordinate system provided by an embodiment of the present invention, such as Figure 2As shown, taking the coordinate point A in the first set Z as an example, taking the coordinate point A as the center of the circle and taking the preset distance as the radius, for example, drawing a circle with the distance of 3 pixels as the radius, a circular area 201 is obtained, and the circular area 201 is the target area. Then, the pixel points corresponding to all the coordinate points in the circular area 201 are determined as the second set, that is, the second set includes the coordinate point A and the area extending outward by 3 pixels from the coordinate point A. All the coordinate points of RGB (0,0,0) are processed in the same way to obtain the area extending outward by 3 pixels from each coordinate point. All the coordinate points and the corresponding areas extending outward by 3 pixels are processed as a union to obtain a union, which is recorded as B. The union B contains the area extending outward by 3 pixels from the text in the subtitles and all the pixels in the area where the text itself is located. The union B is subtracted from the first set Z to obtain the second set C.
[0080] Specifically, after a single coordinate point (x, y) is expanded outward by 3 pixels, the solution method for all coordinate points in the area is as follows:
[0081] like Figure 2 As shown, firstly, a tangent square 202 corresponding to the circular area 201 is constructed, and the coordinate points corresponding to the four corners of the tangent square 202 are coordinate point L, coordinate point M, coordinate point Y and coordinate point N, wherein the coordinate value of coordinate point L is (x-3, y-3), the coordinate value of coordinate point M is (x-3, y+3), the coordinate value of coordinate point Y is (x+3, y-3), and the coordinate value of coordinate point N is (x+3, y+3); all coordinate points in the tangent square 202 are traversed, and if the distance from the coordinate point A(x, y) is less than or equal to 3, the pixel point corresponding to the coordinate point is recorded as a pixel point in the second set, for example, if the distance between coordinate point K and coordinate point A(x, y) is less than 3, then coordinate point K is a pixel point in the second set, and if the distance between coordinate point E and coordinate point A(x, y) is greater than 3, then 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.
[0082] It should be noted that when determining the target area based on the coordinate point corresponding to the first pixel point and the preset distance, the preset distance can be subtracted from the preset value in the X-axis direction, and the preset distance can be added to the preset value in the Y-axis direction. The target area obtained in this way is a rectangular area, and the set of pixel points corresponding to all coordinate points in the rectangular area is determined as the second set. The present invention is not limited to this.
[0083] The subtitle color adjustment method provided by the embodiment of the present invention determines the target area based on the coordinate point corresponding to the first pixel point and the preset distance, and determines the second set indicating all pixel points including the first pixel point and the first pixel point extending outward by the preset distance by traversing the target area. The determination method is simple.
[0084] In one embodiment, Figure 3 FIG. 2 is a flow chart of a subtitle color adjustment method provided by an embodiment of the present invention. Figure 3 As shown, the above step 105 can be specifically implemented by the following steps:
[0085] Step 1051: for each pixel in the subtitle background area, determine a corresponding grayscale value based on the color value of the pixel.
[0086] The grayscale value ranges from 0 to 256, which is used to indicate the brightness of the image. A higher value indicates a higher brightness. 0 indicates pure black, and 256 indicates pure white.
[0087] For example, after obtaining the subtitle background area of the first video image, for each pixel in the subtitle background area, the grayscale value of the pixel is calculated based on the color value of the pixel; for example, the calculation formula is grayscale value gray=R*0.299+G*0.587+B*0.114. If the color value of a pixel in the subtitle background area is RGB(158,204,98), then the grayscale value of the pixel gray=158*0.299+204*0.587+98*0.114=178.162.
[0088] Step 1052: Determine a first grayscale value of the subtitle background area based on the grayscale value corresponding to each pixel in the subtitle background area.
[0089] For example, when obtaining the grayscale value corresponding to each pixel in the subtitle background area, the average value obtained by adding and averaging the grayscale values corresponding to all pixels in the subtitle background area is determined as the first grayscale value of the subtitle background area; or the product obtained by multiplying the average value by an empirical coefficient value is determined as the first grayscale value of the subtitle background area.
[0090] Step 1053: Determine a second grayscale value of the subtitle corresponding to the first video image based on the first grayscale value.
[0091] For example, when the first grayscale value of the subtitle background area is obtained, the brightness of the subtitle background area is determined, and then the brightness of the subtitle corresponding to the first video image can be determined based on the brightness of the subtitle background area; that is, when the subtitle background area is dark, the subtitle corresponding to the first video image can be brightened; when the subtitle background area is bright, the subtitle corresponding to the first video image can be dimmed. That is, the second grayscale value of the subtitle corresponding to the first video image is determined based on the first grayscale value.
[0092] Step 1054: Adjust the first subtitle color based on the second grayscale value.
[0093] For example, when determining the second grayscale value of the subtitle corresponding to the first video image, the value of each color channel corresponding to the first subtitle color can be modified to the second grayscale value, thereby adjusting the first subtitle color. For example, if the second grayscale value is 128, the RGB value of the adjusted first subtitle color is RGB (128, 128, 128); Figure 4 is a schematic diagram of a video image provided by an embodiment of the present invention, such as Figure 4 As shown in FIG. 1 , the overall background color of the video is darker. In the related art, the subtitle color is directly adjusted to white. Figure 4 It can be seen that the picture near the subtitle area 401 is white. If the subtitle color is directly adjusted to white, it still affects the user's recognition of the subtitle. Therefore, the present invention expands the subtitle area 401, that is, the subtitle background area of the first video image determined by the present invention is 402, and the color value of the pixel point of the picture near the subtitle area 401 is also taken into account. In this way, the accuracy of calculating the first grayscale value of the subtitle background area 402 can be improved, and then the accuracy of the second grayscale value of the subtitle corresponding to the first video image can be improved, and the accuracy of the color of the subtitle corresponding to the first video image is also improved. Figure 4 As shown, it is finally determined that the color of the subtitles can be gray, which improves the user's recognition of the subtitles compared to white.
[0094] The subtitle color adjustment method provided by the embodiment of the present invention adaptively adjusts the first subtitle color of the subtitle corresponding to the first video image based on the brightness of the subtitle background area, realizes a method for adaptively and dynamically adjusting the subtitle color according to the subtitle background color, thereby improving the recognition of the subtitle.
[0095] In one embodiment, the determining of the second grayscale value of the subtitle corresponding to the first video image based on the first grayscale value may be implemented in the following manner:
[0096] When it is determined that the first grayscale value is greater than or equal to a second preset value, determining a difference between the first grayscale value and the second preset value as the second grayscale value;
[0097] When it is determined that the first grayscale value is less than the second preset value, the sum of the second preset value and the first grayscale value is determined as the second grayscale value.
[0098] The second preset value may be set based on experience, for example, the second preset value is 128.
[0099] For example, when the grayscale value of the subtitle color differs from the grayscale value of the subtitle background area by 128, the resolution of the subtitle is optimal, and the contrast between the subtitle color and the subtitle background is not too strong. Assuming that the second grayscale value is set to D, and the first grayscale value of the subtitle background area is P, the calculation method is as follows: when the first grayscale value P is greater than or equal to 128, the second grayscale value = P-128; when the first grayscale value P is less than 128, the second grayscale value = P+128. For example, if the hexadecimal value of the second grayscale value D is set to KK, the hexadecimal color can be expressed as #0000KK.
[0100] The subtitle color adjustment method provided by the embodiment of the present invention can determine the second gray value based on the magnitude of the first gray value and the preset value for indicating the best resolution, thereby improving the accuracy of the second gray value and further improving the accuracy of the first subtitle color adjustment.
[0101] In one embodiment, the adjusting of the first subtitle color based on the second grayscale value may be implemented in the following manner:
[0102] deleting the first subtitle color corresponding to the first video image;
[0103] determining a target color based on the second grayscale value;
[0104] The target color is determined as the new first subtitle color.
[0105] For example, when determining the second grayscale value of the subtitle corresponding to the first video image, first delete the first subtitle color corresponding to the first video image in the subtitle file, then modify the value of each color channel to the second grayscale value to obtain the target color, and write the target color as the new first subtitle color into the subtitle file; in the same way, modify the first subtitle color corresponding to each first video image in the target video, and finally obtain the modified subtitle file, and then import the modified subtitle file into the video file corresponding to the target video, so as to realize the adaptive adjustment of the subtitle color. For example, if the second grayscale value is 128, the RGB value of the adjusted first subtitle color is RGB (128, 128, 128).
[0106] The subtitle color adjustment method provided by the embodiment of the present invention realizes the adjustment of the first subtitle color based on the second grayscale value, and the adjustment method is simple and convenient.
[0107] In one embodiment, the above step 101 may be implemented in the following manner:
[0108] When it is determined that the difference between the grayscale value corresponding to the first video background color and the grayscale value corresponding to the first subtitle color is less than or equal to a third preset value, the first video background color of the first video image and the corresponding first subtitle color are subjected to pure color processing.
[0109] For example, when the target video is acquired, for each first video image in the target video, the grayscale value corresponding to the first video background color of the first video image and the grayscale value corresponding to the first subtitle color can be calculated first, and then the difference between the grayscale value corresponding to the first video background color and the grayscale value corresponding to the first subtitle color can be calculated, and then the difference can be compared with a third preset value. When it is determined that the difference is less than or equal to the third preset value, it means that the difference between the first video background color and the first subtitle color is small, and the user may not be able to see the first subtitle color clearly, so it is necessary to perform pure color processing on the first video background color of the first video image and the corresponding first subtitle color, and execute subsequent steps to adjust the subtitle color; when it is determined that the difference is greater than the third preset value, it means that the difference between the first video background color and the first subtitle color is large, and the user can see the first subtitle color clearly, and there is no need to execute the subtitle color adjustment step.
[0110] The subtitle color adjustment method provided by the embodiment of the present invention performs the subtitle color adjustment step only when the difference between the grayscale value corresponding to the first video background color and the grayscale value corresponding to the first subtitle color is less than or equal to the third preset value, thereby improving the accuracy of subtitle color adjustment.
[0111] The subtitle color adjustment device provided by the present invention is described below. The subtitle color adjustment device described below and the subtitle color adjustment method described above can be referred to each other.
[0112] Figure 5 is a schematic diagram of the structure of a subtitle color adjustment device provided by an embodiment of the present invention. Figure 5 As shown, the subtitle color adjustment device 500 includes a processing unit 501, a first determination unit 502, a second determination unit 503, a third determination unit 504 and an adjustment unit 505, wherein:
[0113] The processing unit 501 is used to perform pure color processing on a first video background color and a corresponding first subtitle color of a first video image to obtain a second video image; the second video background color and the second subtitle color of the second video image are different;
[0114] A first determining unit 502 is configured to determine a first set of all first pixel points in a second video image whose colors match the second subtitle color;
[0115] A second determining unit 503 is 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;
[0116] A third determining unit 504 is configured to determine a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0117] The adjusting unit 505 is configured to adjust the first subtitle color based on the color of the subtitle background area.
[0118] The subtitle color adjustment device provided by the present invention first performs pure color processing on the first video background color and the corresponding first subtitle color of the first video image to obtain a second video image with a second video background color different from the second subtitle color, and then determines a first set of all first pixel points matching the second subtitle color from the second video image, and determines a second set of pixel points within a preset distance from each first pixel point, and finally determines the subtitle background area of the first video image based on the union of the second set and the first set, and adjusts the first subtitle color based on the color of the subtitle background area. It can be seen that the subtitle background area determined in the present invention is an area extending outward from the subtitle area by a preset distance, and the color of the screen near the subtitle area is used as the basis for adjusting the first subtitle color in the first video image, thereby improving the recognition of the subtitles.
[0119] Based on any of the foregoing embodiments, the first determining unit 502 is specifically configured to:
[0120] A coordinate system is determined based on the resolution of the second video image; each coordinate point in the coordinate system corresponds one-to-one to each pixel point in the second video image; and the coordinate value of the coordinate point matches the color value of the corresponding pixel point;
[0121] The first pixel points corresponding to all coordinate points in the coordinate system whose coordinate values match a first preset value are determined as the first set; the first preset value is the color value of the second subtitle color.
[0122] Based on any of the above embodiments, the adjusting unit 505 is specifically used for:
[0123] For each pixel in the subtitle background area, determining a corresponding grayscale value based on the color value of the pixel;
[0124] Determine a first grayscale value of the subtitle background area based on the grayscale value corresponding to each pixel in the subtitle background area;
[0125] Determining a second grayscale value of a subtitle corresponding to the first video image based on the first grayscale value;
[0126] The first subtitle color is adjusted based on the second grayscale value.
[0127] Based on any of the above embodiments, the adjusting unit 505 is further specifically configured to:
[0128] When it is determined that the first grayscale value is greater than or equal to a second preset value, determining a difference between the first grayscale value and the second preset value as the second grayscale value;
[0129] When it is determined that the first grayscale value is less than the second preset value, the sum of the second preset value and the first grayscale value is determined as the second grayscale value.
[0130] Based on any of the above embodiments, the adjusting unit 505 is further specifically configured to:
[0131] Deleting the first subtitle color in the first video image;
[0132] determining a target color based on the second grayscale value;
[0133] The target color is determined as the new first subtitle color.
[0134] Based on any of the foregoing embodiments, the third determining unit 504 is specifically configured to:
[0135] A difference between the union and the first set is determined as a subtitle background area of the first video image.
[0136] Based on any of the above embodiments, the processing unit 501 is specifically configured to:
[0137] When it is determined that the difference between the grayscale value corresponding to the first video background color and the grayscale value corresponding to the first subtitle color is less than or equal to a third preset value, the first video background color of the first video image and the corresponding first subtitle color are subjected to pure color processing.
[0138] Figure 6 is one of the physical structure diagrams of the electronic device provided by the embodiment of the present invention, such as Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the subtitle color adjustment method, which includes: performing pure color processing on the first video background color of the first video image and the corresponding first subtitle color to obtain a second video image; the second video background color of the second video image is different from the second subtitle color;
[0139] Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color;
[0140] For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point;
[0141] determining a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0142] The first subtitle color is adjusted based on the color of the subtitle background area.
[0143] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0144] Figure 7 FIG. 2 is a schematic diagram of a physical structure of an electronic device provided by an embodiment of the present invention. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, and also includes a display 750, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the subtitle 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 subtitle color to obtain a second video image; the second video background color of the second video image is different from the second subtitle color;
[0145] Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color;
[0146] For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point;
[0147] determining a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0148] adjusting the first subtitle color based on the color of the subtitle background area;
[0149] The display 750 is used to display the first video image after the color of the first subtitle is adjusted.
[0150] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0151] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the subtitle color adjustment method provided by the above methods, the method comprising: 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 of the second video image is different from the second subtitle color;
[0152] Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color;
[0153] For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point;
[0154] determining a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0155] The first subtitle color is adjusted based on the color of the subtitle background area.
[0156] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the subtitle color adjustment method provided by the above methods is implemented, the method comprising: 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 of the second video image is different from the second subtitle color;
[0157] Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color;
[0158] For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point;
[0159] determining a subtitle background area of the first video image based on a union of each of the second sets and the first set;
[0160] The first subtitle color is adjusted based on the color of the subtitle background area.
[0161] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they 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 scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0162] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A subtitle color adjustment method, characterized in that: include: Performing pure color processing on the first video background color and the corresponding first subtitle color of the first video image to obtain a second video image; The second video background color and the second subtitle color of the second video image are different; Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color; For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point; determining a subtitle background area of the first video image based on a union of each of the second sets and the first set; adjusting the first subtitle color based on the color of the subtitle background area; The determining of the subtitle background area of the first video image based on the union of each of the second sets and the first set comprises: A difference between the union and the first set is determined as a subtitle background area of the first video image.
2. The subtitle color adjustment method according to claim 1, characterized in that: The determining a first set of all first pixel points in the second video image whose colors match the second subtitle color includes: A coordinate system is determined based on the resolution of the second video image; each coordinate point in the coordinate system corresponds one-to-one to each pixel point in the second video image; and the coordinate value of the coordinate point matches the color value of the corresponding pixel point; The first pixel points corresponding to all coordinate points in the coordinate system whose coordinate values match a first preset value are determined as the first set; the first preset value is the color value of the second subtitle color.
3. The subtitle color adjustment method according to claim 1, characterized in that: The adjusting the first subtitle color based on the color of the subtitle background area includes: For each pixel in the subtitle background area, determining a corresponding grayscale value based on the color value of the pixel; Determine a first grayscale value of the subtitle background area based on the grayscale value corresponding to each pixel in the subtitle background area; Determining a second grayscale value of a subtitle corresponding to the first video image based on the first grayscale value; The first subtitle color is adjusted based on the second grayscale value.
4. The subtitle color adjustment method according to claim 3, characterized in that: The determining, based on the first grayscale value, a second grayscale value of a subtitle corresponding to the first video image includes: When it is determined that the first grayscale value is greater than or equal to a second preset value, determining a difference between the first grayscale value and the second preset value as the second grayscale value; When it is determined that the first grayscale value is less than the second preset value, the sum of the second preset value and the first grayscale value is determined as the second grayscale value.
5. The subtitle color adjustment method according to claim 3, characterized in that: The adjusting the first subtitle color based on the second grayscale value includes: deleting the first subtitle color corresponding to the first video image; determining a target color based on the second grayscale value; The target color is determined as a new first subtitle color.
6. The subtitle color adjustment method according to any one of claims 1 to 5, characterized in that: The step of performing pure color processing on the first video background color of the first video image and the corresponding first subtitle color includes: When it is determined that the difference between the grayscale value corresponding to the first video background color and the grayscale value corresponding to the first subtitle color is less than or equal to a third preset value, the first video background color of the first video image and the corresponding first subtitle color are subjected to pure color processing.
7. A subtitle color adjustment device, characterized in that: include: A processing unit, configured to perform pure color processing on a first video background color and a corresponding first subtitle color of a first video image to obtain a second video image; The second video background color and the second subtitle color of the second video image are different; A first determining unit, configured to determine a first set of all first pixel points in a second video image whose colors match the second subtitle color; 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 area of the first video image based on a union of each of the second sets and the first set; An adjusting unit, configured to adjust the color of the first subtitle based on the color of the subtitle background area; The third determining unit is specifically configured to: A difference between the union and the first set is determined as a subtitle background area of the first video image.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the subtitle color adjustment method according to any one of claims 1 to 6 is implemented.
9. 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 pure color processing on a first video background color and a corresponding first subtitle color of the first video image to obtain a second video image; a second video background color and a second subtitle color of the second video image are different; Determine a first set of all first pixel points in the second video image whose colors match the second subtitle color; For each of the first pixel points, determining in the second video image a second set of all pixel points within a preset distance from the first pixel point; determining a subtitle background area of the first video image based on a union of each of the second sets and the first set; adjusting the first subtitle color based on the color of the subtitle background area; The display is used for displaying the first video image after adjusting the color of the first subtitle; The determining of the subtitle background area of the first video image based on the union of each of the second sets and the first set comprises: A difference between the union and the first set is determined as a subtitle background area of the first video image.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the subtitle color adjustment method according to any one of claims 1 to 6 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the subtitle color adjustment method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Caption processing method and apparatus
CN106604107A
