Video equalization method and device and electronic equipment
By converting the video into an HSV image and using the cumulative distribution function of the previous frame of image to perform pixel-by-pixel brightness equalization, the problem of video equalization delay is solved, the video processing speed and security are improved, and it is especially suitable for high-speed video processing.
Patent Information
- Application Number
- CN202410681251.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-11-22
AI Technical Summary
There are major delay problems in the existing video equalization methods, especially when the real-time requirements for videos are high, which may lead to safety hazards. For example, video equalization delay in driving on highways leads to driver decision-making errors, increasing the risk of safety accidents. .
By converting the target video into a hue-saturation-brightness (HSV) image, and using the cumulative distribution function of the previous frame image to perform brightness equalization pixel by pixel, combining the equalized brightness value with the hue value and saturation value, each frame is achieved by realizing the equalized brightness value and the hue value and saturation value. The image balance is thus obtained, thus obtaining the equalized video, avoiding the need to cache a video image.
Improves the speed of video equalization, reduces video latency, improves video performance and security, especially in high-speed video processing with small differences in adjacent frame images, achieving smaller accuracy costs and smaller delays .
Smart Images

Figure CN119011795A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video technology, and in particular to a video equalization method, device and electronic equipment. Background Art
[0002] In order to improve the contrast and clarity of the video, it is usually necessary to balance the video to achieve a better overall display effect. There are many methods for video equalization, but most of them are based on the overall balance of the current frame video, that is, after receiving a frame of video, it is balanced based on the global information of the frame, and then output after equalization. Since it needs to be processed based on a frame of image, it is necessary to cache a frame, which introduces additional delay in this link. This delay may bring greater security risks when the real-time requirements of the video are high. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a video equalization method, device and electronic device to solve the problem of large delay in video equalization in the prior art.
[0004] A first aspect of an embodiment of the present application provides a video equalization method, including:
[0005] Obtain a target video, where the target video includes N frames of images, where N is a positive integer greater than 1;
[0006] Convert the i-th frame image of the target video into a hue-saturation-brightness HSV image, where i is a positive integer greater than or equal to 1 and less than N;
[0007] Obtaining a histogram cumulative distribution function mapping table of the i-1th frame image from the storage unit, the mapping table including a mapping relationship between the image brightness value and the equalized i-1th frame image brightness value;
[0008] Taking the brightness value of the first target pixel of the i-th frame image as an index, query the histogram cumulative distribution function mapping table to obtain the brightness value of the first target pixel after equalization;
[0009] Combining the equalized brightness value of the first target pixel with the hue value and the saturation value of the first target pixel to obtain the equalized first target pixel;
[0010] Traverse all pixels of the i-th frame image to obtain the equalized i-th frame image;
[0011] Traverse N frames of images to get the equalized video.
[0012] According to a second aspect of the embodiments of the present application, a video equalization device is provided, including:
[0013] An acquisition module is configured to acquire a target video, where the target video includes N frames of images, where N is a positive integer greater than 1;
[0014] A conversion module is configured to convert the i-th frame image of the target video into a hue-saturation-brightness (HSV) image, where i is a positive integer greater than or equal to 1 and less than N;
[0015] The acquisition module is further configured to acquire a histogram cumulative distribution function mapping table of the i-1th frame image from the storage unit, the mapping table including a mapping relationship between the image brightness value and the equalized i-1th frame image brightness value;
[0016] A query module is configured to use the brightness value of the first target pixel of the i-th frame image as an index, and query the histogram cumulative distribution function mapping table to obtain the brightness value of the first target pixel after equalization;
[0017] a combining module configured to combine the equalized brightness value of the first target pixel with the hue value and the saturation value of the first target pixel to obtain the equalized first target pixel;
[0018] A traversal module is configured to traverse all pixels of the i-th frame image to obtain a balanced i-th frame image; and
[0019] Traverse N frames of images to get the equalized video.
[0020] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0021] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application convert the target video into a Hue-Saturation-Value (HSV) image, and for each frame of the HSV image, perform brightness equalization pixel by pixel using the cumulative distribution function of the previous frame, and then combine the equalized brightness value with the hue value and the saturation value to complete the equalization of all pixels in each frame, thereby obtaining a balanced video. This can improve the speed of video equalization, especially for high-speed videos with small differences between adjacent frame images. This method can achieve video equalization without caching a frame of video images, thereby obtaining a smaller video delay at a lower cost of accuracy, thereby improving video performance, and improving the safety of video use.
[0022] Furthermore, the embodiment of the present application presets an adder lookup table, and uses the brightness value of the current balanced pixel to query in the preset adder lookup table to determine the target adder for accumulating the brightness value, and then performs a plus 1 operation on each target adder. This allows the accumulation of the cumulative distribution function to be completed in one operation when balancing each pixel, thereby improving the processing speed and efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 It is a flowchart of a video equalization method provided in an embodiment of the present application.
[0025] Figure 2 It is a flow chart of a method for determining a histogram cumulative distribution function mapping table of an i-1th frame image provided in an embodiment of the present application.
[0026] Figure 3 It is a flowchart of a method for obtaining a target adder by querying a preset adder lookup table using the brightness value of a second target pixel provided in an embodiment of the present application.
[0027] Figure 4 It is a flowchart of a method for obtaining a mapping relationship between the brightness value of each image and the brightness value of the equalized i-1th frame image based on cumulative distribution times provided in an embodiment of the present application.
[0028] Figure 5 It is a flowchart of another video equalization method provided in an embodiment of the present application.
[0029] Figure 6 This is a flowchart of another video equalization method provided in an embodiment of the present application.
[0030] Figure 7 It is a flowchart of another video equalization method provided in an embodiment of the present application.
[0031] Figure 8 It is a flowchart of another video equalization method provided in an embodiment of the present application.
[0032] Fig. 9 It is a flowchart of a method for determining a cumulative distribution function provided in an embodiment of the present application.
[0033] Fig.10 It is a schematic diagram of a video equalization device provided in an embodiment of the present application.
[0034] Fig.11 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0036] A video equalization method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0037] As mentioned above, most current video equalization methods are based on the overall equalization of the current frame video, that is, after receiving a frame of video, it is equalized based on the global information of the frame, and then output after equalization. Since it needs to be processed based on a frame of image, it is necessary to cache a frame, which introduces additional delay in this link. This delay may bring greater security risks when the real-time requirements of the video are high.
[0038] Taking the equalization of the video in the Camera-Monitor System (CMS) as an example, when the video equalization causes a large delay in the image seen by the driver from the CMS, it may cause the driver to make wrong decisions and lead to safety accidents.
[0039] Assuming that the vehicle where the CMS is located is driving on a highway, the normal driving speed is 120km / h, that is, 33.33m / s, and the distance delay of 50ms is 1.67m. When the driver is speeding, the distance will be further increased on this basis. The increase in distance will affect the driver's judgment accuracy, especially when the vehicle changes lanes to overtake. If the driver sees that there is enough safety distance from the CMS but the actual safety distance between the two vehicles is not that large, changing lanes to overtake will bring greater safety hazards to both the vehicle and the other vehicle, increasing the probability of safety accidents.
[0040] In view of this, an embodiment of the present application provides a video equalization method, which converts the target video into an HSV image, and performs brightness equalization pixel by pixel for each frame of the HSV image using the cumulative distribution function of the previous frame. The equalized brightness value is then combined with the hue value and the saturation value to complete the equalization of all pixels in each frame, thereby obtaining a balanced video. The speed of video equalization can be improved, especially for high-speed videos with small differences between adjacent frame images. This method can achieve video equalization without caching a frame of video image, thereby obtaining a smaller video delay at a lower cost of accuracy, thereby improving video performance and improving the safety of video use.
[0041] Figure 1 FIG. 1 is a flow chart of a video equalization method provided in an embodiment of the present application. Figure 1 As shown, the video equalization method includes the following steps:
[0042] In step S101, a target video is obtained.
[0043] The target video includes N frames of images, where N is a positive integer greater than 1.
[0044] In step S102, the i-th frame image of the target video is converted into an HSV image.
[0045] Wherein, i is a positive integer greater than or equal to 1 and less than N.
[0046] In step S103, a histogram cumulative distribution function mapping table of the (i-1)th frame image is obtained from a storage unit.
[0047] The mapping table includes a mapping relationship between the image brightness value and the equalized image brightness value of the i-1th frame.
[0048] In step S104, the brightness value of the first target pixel in the i-th frame image is used as an index, and the equalized brightness value of the first target pixel is obtained by searching the histogram cumulative distribution function mapping table.
[0049] In step S105 , the equalized brightness value of the first target pixel is combined with the hue value and the saturation value of the first target pixel to obtain the equalized first target pixel.
[0050] In step S106, all pixels of the i-th frame image are traversed to obtain the i-th frame image after equalization; and N frames of images are traversed to obtain the equalized video.
[0051] In the embodiment of the present application, the video equalization method can be used to process videos captured by a CMS camera, etc. Furthermore, the video equalization method can also be used to process other videos, especially videos with high real-time requirements.
[0052] In the embodiment of the present application, the video equalization method can be executed by a terminal, and the terminal can be, for example, a mobile terminal, a vehicle-mounted terminal, or other terminals with certain computing capabilities.
[0053] In the embodiment of the present application, the terminal may first obtain a target video, which is a video to be equalized. The target video may include multiple frames of images.
[0054] In an embodiment of the present application, the i-th frame image of the target video can be converted into an HSV image. In one example, if the target image is a Luma-Chrominance-Chroma (YUV) image, the target image can be directly converted into an HSV image. On the other hand, if the target image is an original video image, the target image can be first converted into a Red-Green-Blue (RGB) image and then converted into an HSV image.
[0055] In the embodiment of the present application, a histogram cumulative distribution function mapping table of the i-1th frame image can be obtained from the storage unit, and the mapping table stores the mapping relationship between the image brightness value and the equalized i-1th frame image brightness value. The number of image brightness values is determined by the number of bits of the brightness value in the pixel. For example, if the brightness value of the pixel is 8 bits, there are 256 image brightness values in total. Each image brightness value in the mapping table is uniquely mapped to an i-1th frame image brightness value, and the i-1th frame image brightness value is the mapping value of each image brightness value obtained after the cumulative distribution equalization processing is performed on the first to i-1th frames of images.
[0056] In the embodiment of the present application, the brightness value of the first target pixel of the i-th frame image can be used as an index to query the histogram cumulative distribution function mapping table to obtain the brightness value of the first target pixel after equalization. In one example, if the brightness value of the first target pixel of the i-th frame image is 220, and the mapping value of the image brightness value of 220 in the mapping table is 232, then the brightness value of the first target pixel after equalization obtained by query is 232.
[0057] In the embodiment of the present application, the equalized brightness value of the first target pixel is combined with the hue value and saturation value of the first target pixel to obtain the equalized first target pixel. Further, all pixels of the i-th frame image are traversed to obtain the equalized i-th frame image. By traversing N frames of images, the equalized video can be obtained.
[0058] That is to say, since the frame rate of the CMS camera is usually 60Hz, the time interval between each frame is 16.67ms. When the driving speed is 120km / h, the distance moved by the vehicle between two frames is 0.56m. If the vehicle is driving at a low speed, the moving distance between the two frames is closer. The small interval in time and the small difference in distance lead to a small difference in the image between the two frames. Therefore, when the histogram equalization algorithm is used for equalization, the cumulative distribution function of the two frames of images does not change much. Therefore, the cumulative distribution function of the current frame of video can be approximated by the cumulative distribution function of the previous frame of video. When the histogram equalization is performed on the current frame of video, the cumulative distribution function calculated by the previous frame of video is used for calculation, so there is no need to cache a frame of video to achieve video equalization, which greatly reduces the equalization delay.
[0059] According to the technical solution provided in the embodiment of the present application, by converting the target video into an HSV image, for each frame of the HSV image, the cumulative distribution function of the previous frame is used to perform brightness equalization pixel by pixel, and then the equalized brightness value is combined with the hue value and the saturation value to complete the equalization of all pixels in each frame, and then the equalized video is obtained. The speed of video equalization can be improved, especially for high-speed videos with small differences between adjacent frame images. This method can achieve video equalization without caching a frame of video image, obtains a smaller video delay at a lower cost of accuracy, improves video performance, and improves the safety of video use.
[0060] In the embodiment of the present application, the image brightness value includes all brightness values of the image, and each image brightness value corresponds to a group of adders. In other words, each image brightness value corresponds to a group of adders, and each image brightness value corresponds to the same group of adders. The group of adders includes K adders, where K is the number of image brightness values.
[0061] Figure 2 : is a flow chart of a method for determining a histogram cumulative distribution function mapping table of the i-1th frame image provided by an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0062] In step S201, each adder is initialized.
[0063] In step S202, a second target pixel in the (i-1)th frame image is acquired, and a brightness value of the second target pixel is determined.
[0064] In step S203, the target adder is obtained by searching a preset adder lookup table using the brightness value of the second target pixel.
[0065] In step S204, an addition operation is performed on the target adder.
[0066] In step S205, all pixels in the i-1th frame image are traversed, and the target adder corresponding to each pixel performs an addition operation to obtain the cumulative distribution times of all pixels in the i-1th frame image.
[0067] In step S206, a mapping relationship between the brightness value of each image and the brightness value of the equalized i-1th frame image is calculated based on the cumulative distribution frequency.
[0068] In the embodiment of the present application, before processing the first element in a frame of image, each adder may be initialized. Then, the second target pixel in the i-1th frame of image is obtained, and the brightness value of the second target pixel is determined. Then, the brightness value of the second target pixel is used to query the preset adder lookup table to obtain the target adder, and an addition operation is performed on the queried target adder.
[0069] In the embodiment of the present application, all pixels in the i-1 frame image can be traversed in sequence, and the target adder corresponding to each pixel performs an add 1 operation, thereby obtaining the cumulative distribution times of all pixels in the i-1 frame image. Finally, the mapping relationship between the brightness value of each image and the brightness value of the i-1 frame image after equalization can be calculated based on the cumulative distribution times.
[0070] In the embodiment of the present application, the adder lookup table includes an address item and an adder string item. Further, each address in the address item corresponds to a brightness value in the image brightness value, each adder string in the adder string item corresponds to an address, and each adder string includes K bits, each bit corresponds to an adder, each bit has a value of 1 or 0, and K is the number of image brightness values.
[0071] Figure 3 1 is a flow chart of a method for obtaining a target adder by querying a preset adder lookup table using the brightness value of a second target pixel provided by an embodiment of the present application. Figure 3 As shown, the method comprises the following steps:
[0072] In step S301, the brightness value of the second target pixel is used as the address, and a target adder string is obtained by searching in a preset adder lookup table.
[0073] In step S302, the adder corresponding to the bit with a value of 1 in the target adder string is determined as the target adder.
[0074] In an embodiment of the present application, when using the brightness value of the second target pixel to query the preset adder lookup table to obtain the target adder, the brightness value of the second target pixel can be used as the address, and the target adder string can be queried in the preset adder lookup table, and then the adder corresponding to the bit with a value of 1 in the target adder string is determined to be the target adder.
[0075] In an embodiment of the present application, in a preset adder lookup table, in the adder string corresponding to the kth address, the value of each bit is determined in the following manner: the values of the high k bits in the adder string are set to 0; the values of the remaining bits in the adder string are set to 1.
[0076] Taking the image brightness value including 256 values as an example, the preset adder lookup table is shown in Table 1:
[0077]
[0078]
[0079] Table 1 Preset adder lookup table
[0080] In one example, taking the brightness value of the second target pixel as 254, its corresponding adder string in the preset adder lookup table is ob000...11 (the lowest 2 bits are 1, and the rest are all 0). Therefore, the two lowest-order adders among the 256 adders are determined as target adders, and the add 1 operation is performed on these target adders, so as to realize the accumulation of the histogram distribution times of the brightness value of the second target pixel.
[0081] In another example, taking the brightness value of the second target pixel as 1, its corresponding adder string in the preset adder lookup table is ob011...11 (the highest bit is 0, and the rest of the bits are all 1). Therefore, the adders except the highest bit adder among the 256 adders are determined as target adders, and the add 1 operation is performed on these target adders, so as to realize the accumulation of the histogram distribution times of the brightness value of the second target pixel.
[0082] Figure 4 1 is a flow chart of a method for obtaining a mapping relationship between the brightness value of each image and the brightness value of the equalized i-1th frame image based on the cumulative distribution times provided in an embodiment of the present application. Figure 4 As shown, the method comprises the following steps:
[0083] In step S401, the cumulative distribution times in each adder are truncated, and the cumulative distribution probability of each image brightness value is calculated using the truncated cumulative distribution times.
[0084] In step S402, the cumulative distribution probability of the brightness value of each image is equalized to obtain the brightness value of each image after the brightness value of each image is equalized.
[0085] In step S403, the product of the brightness value of each image after equalization and the number of image brightness values K is determined as the brightness value of each image in the i-1th frame image, and a mapping relationship between the brightness value of each image and the equalized brightness value of the i-1th frame image is obtained.
[0086] In the embodiment of the present application, after obtaining the cumulative distribution times of all pixels in the i-1th frame image, the cumulative distribution times in each adder can be truncated first so that the number of bits of the truncated data is the same as the number of bits of the image pixel brightness value. Then, the cumulative distribution probability of each image brightness value is calculated using the truncated cumulative distribution times.
[0087] Next, the cumulative distribution probability of the brightness values of each image can be equalized, for example, brightness equalization can be achieved through difference, so as to obtain the brightness values of each image after the brightness values of each image are equalized. Finally, the product of the brightness values of each image after the brightness values of each image are equalized and the number of image brightness values K is determined as the brightness value of each image brightness value in the i-1th frame image, so as to obtain the mapping relationship between the brightness values of each image and the brightness value of the i-1th frame image after equalization.
[0088] Figure 5 is a flow chart of another video equalization method provided in an embodiment of the present application. Figure 5 Steps S501 to S506 in the illustrated embodiment are Figure 1 Steps 101 to S106 in the illustrated embodiment are substantially the same and will not be described in detail herein. Figure 5 As shown, the method also includes the following steps:
[0089] In step S507, the mapping relationship between the image brightness value and the equalized brightness value of the i-th frame image is calculated using the brightness value of each pixel of the i-th frame image to obtain a histogram cumulative distribution function mapping table of the i-th frame image.
[0090] In step S508, in the storage unit, the histogram cumulative distribution function mapping table of the i-th frame image is used to replace the histogram cumulative distribution function mapping table of the i-1th frame image.
[0091] In the embodiment of the present application, after the i-th frame image of the target video is converted into an HSV image, the brightness value of each pixel of the i-th frame image can be used to calculate the mapping relationship between the image brightness value and the brightness value of the i-th frame image after equalization, and obtain the histogram cumulative distribution function mapping table of the i-th frame image. Then, in the storage unit, the histogram cumulative distribution function mapping table of the i-th frame image is used to replace the histogram cumulative distribution function mapping table of the i-1-th frame image.
[0092] It should be noted that the step of calculating and storing the histogram cumulative distribution function mapping table of the i-th frame image and the step of performing equalization processing on the i-th frame image using the histogram cumulative distribution mapping table of the i-1-th frame image may be performed in parallel.
[0093] In an embodiment of the present application, when i is equal to 1, that is, the image currently being equalized is the first frame image in the video, since there is no histogram cumulative distribution function mapping table of the previous frame image at this time, equalization processing may not be performed on the first frame image.
[0094] Figure 6 FIG. 1 is a flow chart of another video equalization method provided in an embodiment of the present application. Figure 6 Steps S601 to S602 in the embodiment shown are Figure 1 Steps 101 to S102 in the illustrated embodiment are substantially the same. Figure 5 Steps S604 to S606 in the illustrated embodiment are similar to Figure 1 Steps 104 to 106 in the illustrated embodiment are substantially the same and will not be described in detail herein. Figure 6 As shown, the method also includes the following steps:
[0095] In step S603, a histogram cumulative distribution function mapping table of the (i-1)th frame image is obtained from a storage unit, where the mapping table is an initial histogram cumulative distribution function mapping table.
[0096] Among them, in the initial histogram cumulative distribution function mapping table, any two values mapped one by one are the same.
[0097] In the embodiment of the present application, when i=1, the histogram cumulative distribution function mapping table of the i-1th frame image can be obtained from the storage unit, and the mapping table is the initial histogram cumulative distribution function mapping table. Among them, in the initial histogram cumulative distribution function mapping table, any two values mapped one to one are the same. For example, the value mapped one to one with the image brightness value 1 in the initial histogram cumulative distribution function mapping table is also 1, and the value mapped one to one with the image brightness value 2 is also 2, and so on.
[0098] Figure 7 FIG. 1 is a flow chart of another video equalization method provided in an embodiment of the present application. Figure 7 Steps S701 to S705 in the embodiment shown are Figure 1 Steps 101 to S105 in the illustrated embodiment are substantially the same and will not be described in detail herein. Figure 7 As shown, the method also includes the following steps:
[0099] In step S706, the equalized first target pixel is saved.
[0100] The first target pixel is the first pixel in the mth row in the i-th frame image.
[0101] In step S707, all pixels in the mth row of the i-th frame image are equalized in sequence, and the equalized pixels are shifted and saved.
[0102] Among them, the most recently equalized pixel is stored in the highest bit.
[0103] In step S708, in response to completing the equalization of all pixels in the mth row of the i-th frame image, all equalized pixels in the mth row of the i-th frame image are output as the mth row of the i-th frame image after equalization.
[0104] In step S709, all rows of the i-th frame image are traversed to obtain the i-th frame image after equalization.
[0105] In step S710, N frames of images are traversed to obtain a balanced video.
[0106] In an embodiment of the present application, after obtaining the first target pixel after equalization, the first target pixel after equalization can be saved first, and the first target pixel is the first pixel of the mth row in the i-th frame image. Then, all pixels in the mth row of the i-th frame image are equalized in sequence, and the equalized pixels are shifted and saved, wherein the latest equalized pixel is saved in the highest bit. After completing the equalization of all pixels in the mth row of the i-th frame image, all equalized pixels in the mth row of the i-th frame image are output as the equalized i-th frame mth row image. Traverse all rows of the i-th frame image to obtain the equalized i-th frame image. Traverse N frames of images to obtain the equalized video.
[0107] Figure 8 FIG. 1 is a flow chart of another video equalization method provided in an embodiment of the present application. Figure 8 As shown in the figure, when each pixel point of the current frame and the current row of the video is input, the RGB data (or YUV) data is converted to the HSV space, and the V component is histogram-equalized using the cumulative distribution function obtained in the previous frame. The equalization method uses a direct table lookup method, using the V component as the address subscript to find the corresponding equalized V component. After merging the H component and the S component of this row after equalization, the chromaticity transformation from the HSV space to the RGB space is performed, and after the transformation is completed, the equalized pixel data of the input pixel is obtained.
[0108] The entire row is output at the output end, and it is stored in two levels. The first level is used to cache each balanced pixel of this row. Every time a new pixel is reached, the existing pixel information is shifted as a whole. After all the data of this row is processed, the data of this row is moved as a whole to the output cache. The output of this row is sent out from the output cache so as not to hinder the data processing of the next row.
[0109] Fig. 9 is a flow chart of a method for determining a cumulative distribution function provided in an embodiment of the present application. Fig. 9As shown, each time a new V component is input, the random access memory (RAM) is searched with the V component as the address. The total number of words in the RAM is the bit width of the V component. The RAM bit width is the maximum range expressed by the V component address plus 1. Taking the V component as 8 bits as an example, the RAM is arranged as 256 bits wide and 256 words. Since when the cumulative distribution function is calculated, after the probability of the previous brightness increases, the probabilities of all pixels higher than the brightness need to be increased accordingly, a table lookup method is used to obtain the value in the RAM to enable the relevant adder. All adders with bits 1 are increased by 1, and those with bits 0 are not added. In this way, the cumulative distribution probability function can be updated once. The bit width of the adder is determined by the total number of pixels.
[0110] When the entire frame of data is received, all the adders have completed the calculation of the probability distribution function, and then the truncation process is performed, and the high 8 bits of the addition result are retained and loaded into the cumulative distribution function register for use in the next frame balance lookup table.
[0111] By adopting the technical solution of the embodiment of the present application, according to the similarity of two frames of video, each new line of video data can be balanced using the equalization parameters of the previous frame, and the equalization parameters required for the next frame of equalization can be updated and calculated. The equalization function can be added without caching a frame of video, the video performance can be improved, and the video delay is not increased.
[0112] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0113] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0114] Fig.10 Schematic diagram of a video equalization device provided in an embodiment of the present application. Fig.10 As shown, the video equalizing device comprises:
[0115] The acquisition module 1001 is configured to acquire a target video, where the target video includes N frames of images, where N is a positive integer greater than 1.
[0116] The conversion module 1002 is configured to convert the i-th frame image of the target video into a hue-saturation-brightness (HSV) image, where i is a positive integer greater than or equal to 1 and less than N.
[0117] The acquisition module 1001 is further configured to acquire a histogram cumulative distribution function mapping table of the i-1th frame image from a storage unit, wherein the mapping table includes a mapping relationship between the image brightness value and the equalized brightness value of the i-1th frame image.
[0118] The query module 1003 is configured to use the brightness value of the first target pixel of the i-th frame image as an index and query the histogram cumulative distribution function mapping table to obtain the brightness value of the first target pixel after equalization.
[0119] The combining module 1004 is configured to combine the equalized brightness value of the first target pixel with the hue value and the saturation value of the first target pixel to obtain the equalized first target pixel.
[0120] The traversal module 1005 is configured to traverse all pixels of the i-th frame image to obtain the i-th frame image after equalization; and
[0121] Traverse N frames of images to get the equalized video.
[0122] According to the technical solution provided in the embodiment of the present application, by converting the target video into an HSV image, for each frame of the HSV image, the cumulative distribution function of the previous frame is used to perform brightness equalization pixel by pixel, and then the equalized brightness value is combined with the hue value and the saturation value to complete the equalization of all pixels in each frame, and then the equalized video is obtained. The speed of video equalization can be improved, especially for high-speed videos with small differences between adjacent frame images. This method can achieve video equalization without caching a frame of video image, obtains a smaller video delay at a lower cost of accuracy, improves video performance, and improves the safety of video use.
[0123] In an embodiment of the present application, the image brightness value includes all brightness values of the image, and each image brightness value corresponds to a group of adders; the histogram cumulative distribution function mapping table of the i-1th frame image is determined in the following manner: initialize each adder; obtain the second target pixel in the i-1th frame image, and determine the brightness value of the second target pixel; use the brightness value of the second target pixel to query the preset adder lookup table to obtain the target adder; perform a plus 1 operation on the target adder; traverse all pixels in the i-1th frame image, and perform a plus 1 operation on the target adder corresponding to each pixel to obtain the cumulative distribution number of all pixels in the i-1th frame image; based on the cumulative distribution number, calculate the mapping relationship between the brightness value of each image and the equalized brightness value of the i-1th frame image.
[0124] In an embodiment of the present application, an adder lookup table includes an address item and an adder string item; wherein each address in the address item corresponds to a brightness value in the image brightness value; each adder string in the adder string item corresponds to an address, and each adder string includes K bits, each bit corresponds to an adder, each bit has a value of 1 or 0, and K is the number of image brightness values; using the brightness value of the second target pixel to query the preset adder lookup table to obtain a target adder, including: using the brightness value of the second target pixel as the address, querying the preset adder lookup table to obtain the target adder string; determining that the adder corresponding to the bit with a value of 1 in the target adder string is the target adder.
[0125] In an embodiment of the present application, in a preset adder lookup table, in the adder string corresponding to the kth address, the value of each bit is determined in the following manner: the values of the high k bits in the adder string are set to 0; the values of the remaining bits in the adder string are set to 1.
[0126] In an embodiment of the present application, a mapping relationship between the brightness value of each image and the brightness value of the i-1th frame image after equalization is obtained based on the cumulative distribution frequency calculation, including: truncating the cumulative distribution frequency in each adder, and using the truncated cumulative distribution frequency calculation to obtain the cumulative distribution probability of each image brightness value; equalizing the cumulative distribution probability of each image brightness value to obtain the brightness value of each image after the brightness value of each image is equalized; determining that the product of the brightness value of each image after the brightness value of each image is equalized and the number of image brightness values K is the brightness value of each image brightness value in the i-1th frame image, and obtaining the mapping relationship between the brightness value of each image and the brightness value of the i-1th frame image after equalization.
[0127] In an embodiment of the present application, after converting the i-th frame image of the target video into an HSV image, it also includes: using the brightness value of each pixel of the i-th frame image to calculate the mapping relationship between the image brightness value and the equalized i-th frame image brightness value, to obtain a histogram cumulative distribution function mapping table of the i-th frame image; in a storage unit, using the histogram cumulative distribution function mapping table of the i-th frame image to replace the histogram cumulative distribution function mapping table of the i-1-th frame image.
[0128] In an embodiment of the present application, in response to i being equal to 1, it also includes: obtaining a histogram cumulative distribution function mapping table of the i-1th frame image from a storage unit, the mapping table being an initial histogram cumulative distribution function mapping table; wherein, in the initial histogram cumulative distribution function mapping table, any two values mapped one to one are the same.
[0129] In an embodiment of the present application, after obtaining the first target pixel after equalization, it also includes: saving the first target pixel after equalization, the first target pixel being the first pixel of the mth row in the i-th frame image; sequentially equalizing all pixels in the mth row of the i-th frame image, and shifting and saving the equalized pixels, wherein the latest equalized pixel is saved in the highest bit; in response to completing the equalization of all pixels in the mth row of the i-th frame image, outputting all equalized pixels in the mth row of the i-th frame image as the mth row of the i-th frame image after equalization; traversing all rows of the i-th frame image to obtain the i-th frame image after equalization.
[0130] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0131] Fig.11 Schematic diagram of an electronic device provided in an embodiment of the present application. Fig.11 As shown, the electronic device 11 of this embodiment includes: a processor 1101, a memory 1102, and a computer program 1103 stored in the memory 1102 and executable on the processor 1101. When the processor 1101 executes the computer program 1103, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1101 executes the computer program 1103, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0132] The electronic device 11 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 11 may include, but is not limited to, a processor 1101 and a memory 1102. Those skilled in the art will appreciate that Fig.11 The electronic device 11 is merely an example and does not limit the electronic device 11 , and may include more or less components than those shown in the figure, or different components.
[0133] Processor 1101 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0134] The memory 1102 may be an internal storage unit of the electronic device 11, for example, a hard disk or memory of the electronic device 11. The memory 1102 may also be an external storage device of the electronic device 11, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 11. The memory 1102 may also include both an internal storage unit of the electronic device 11 and an external storage device. The memory 1102 is used to store computer programs and other programs and data required by the electronic device.
[0135] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0136] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0137] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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. 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 application, and should all be included in the protection scope of the present application.
Claims
1. A video equalization method, characterized in that: include: Acquire a target video, wherein the target video includes N frames of images, where N is a positive integer greater than 1; Convert the i-th frame image of the target video into a hue-saturation-brightness (HSV) image, where i is a positive integer greater than or equal to 1 and less than N; Acquire a histogram cumulative distribution function mapping table of the i-1th frame image from a storage unit, wherein the mapping table includes a mapping relationship between the image brightness value and the equalized i-1th frame image brightness value; Taking the brightness value of the first target pixel of the i-th frame image as an index, querying the histogram cumulative distribution function mapping table to obtain the brightness value of the first target pixel after equalization; Combining the equalized brightness value of the first target pixel with the hue value and the saturation value of the first target pixel to obtain a equalized first target pixel; Traversing all pixels of the i-th frame image to obtain a balanced i-th frame image; The N frames of images are traversed to obtain a balanced video.
2. The method according to claim 1, characterized in that The image brightness value includes all brightness values of the image, and each image brightness value corresponds to a group of adders; The histogram cumulative distribution function mapping table of the i-1th frame image is determined in the following manner: Initialize each adder; Acquire a second target pixel in the (i-1)th frame image, and determine a brightness value of the second target pixel; Using the brightness value of the second target pixel to query a preset adder lookup table to obtain a target adder; Performing an add-1 operation on the target adder; Traversing all pixels in the i-1th frame image, performing an add-1 operation on the target adder corresponding to each pixel, and obtaining the cumulative distribution times of all pixels in the i-1th frame image; A mapping relationship between the brightness value of each image and the brightness value of the equalized i-1th frame image is calculated based on the cumulative distribution times.
3. The method according to claim 2, characterized in that The adder lookup table includes an address item and an adder string item; Wherein, each address in the address item corresponds to a brightness value in the image brightness value; Each adder string in the adder string item corresponds to an address, and each adder string includes K bits, each bit corresponds to an adder, the value of each bit is 1 or 0, and K is the number of image brightness values; The step of using the brightness value of the second target pixel to query a preset adder lookup table to obtain a target adder includes: Using the brightness value of the second target pixel as the address, searching in the preset adder lookup table to obtain a target adder string; Determine that the adder corresponding to the bit with a value of 1 in the target adder string is the target adder.
4. The method according to claim 3, characterized in that In the preset adder lookup table, the value of each bit in the adder string corresponding to the kth address is determined in the following manner: Setting the values of the high k bits in the adder string to 0; The values of the remaining bits in the adder string are set to 1.
5. The method according to claim 2, characterized in that: The mapping relationship between the brightness value of each image and the brightness value of the equalized i-1th frame image is calculated based on the cumulative distribution number, including: The cumulative distribution times in each adder are truncated, and the cumulative distribution probability of each image brightness value is calculated using the truncated cumulative distribution times; The cumulative distribution probability of the brightness value of each image is equalized to obtain the brightness value of each image after the brightness value of each image is equalized; The product of the brightness value of each image after the brightness value of each image is equalized and the number of image brightness values K is determined as the brightness value of each image brightness value in the i-1th frame image, and a mapping relationship between the brightness value of each image and the brightness value of the i-1th frame image after equalization is obtained.
6. The method according to claim 1, characterized in that After converting the i-th frame image of the target video into an HSV image, the method further includes: Using the brightness value of each pixel of the i-th frame image to calculate the mapping relationship between the image brightness value and the equalized i-th frame image brightness value, a histogram cumulative distribution function mapping table of the i-th frame image is obtained; In the storage unit, the histogram cumulative distribution function mapping table of the i-th frame image is used to replace the histogram cumulative distribution function mapping table of the i-1th frame image.
7. The method according to claim 1, characterized in that In response to i being equal to 1, the method further includes: Acquire a histogram cumulative distribution function mapping table of the i-1th frame image from a storage unit, wherein the mapping table is an initial histogram cumulative distribution function mapping table; Among them, in the initial histogram cumulative distribution function mapping table, any two values mapped one by one are the same.
8. The method according to claim 1, characterized in that After obtaining the equalized first target pixel, the method further includes: Saving the equalized first target pixel, where the first target pixel is the first pixel of the mth row in the i-th frame image; Sequentially equalize all pixels in the mth row of the i-th frame image, and shift and save the equalized pixels, wherein the latest equalized pixel is saved in the highest bit; In response to completing the equalization of all pixels in the mth row of the i-th frame image, outputting all equalized pixels in the mth row of the i-th frame image as the mth row of the i-th frame image after equalization; All rows of the i-th frame image are traversed to obtain the i-th frame image after equalization.
9. A video equalization device, characterized in that: include: An acquisition module is configured to acquire a target video, wherein the target video includes N frames of images, where N is a positive integer greater than 1; A conversion module is configured to convert the i-th frame image of the target video into a hue-saturation-brightness (HSV) image, where i is a positive integer greater than or equal to 1 and less than N; The acquisition module is further configured to acquire a histogram cumulative distribution function mapping table of the i-1th frame image from the storage unit, wherein the mapping table includes a mapping relationship between the image brightness value and the equalized i-1th frame image brightness value; A query module is configured to query the histogram cumulative distribution function mapping table to obtain the equalized brightness value of the first target pixel using the brightness value of the first target pixel of the i-th frame image as an index; a combining module configured to combine the equalized brightness value of the first target pixel with the hue value and the saturation value of the first target pixel to obtain the equalized first target pixel; A traversal module is configured to traverse all pixels of the i-th frame image to obtain a balanced i-th frame image; as well as The N frames of images are traversed to obtain a balanced video.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
