Video contrast enhancement method, device, electronic device and storage medium
By cutting and area recognition of video frame images, combining crop threshold and adjustment function, the color distortion problem caused by contrast enhancement in the prior art is solved, and the natural and continuity of contrast enhancement is achieved, and the image quality is improved.
Patent Information
- Application Number
- CN202411324356.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2044-09-23
AI Technical Summary
When the prior art enhances the contrast of the image, it is easy to cause color distortion in the face part and the contrast enhancement effect is poor.
By cutting the frame image of the video to be processed, skin type and non-skin type areas are identified, cropping threshold and adjustment functions are determined based on pixel information, skin type areas are identifiable mapped, non-skin type areas are adjusted, and presets are used The adjustment model and interpolation process are used to generate target images to maintain the natural and continuity of enhanced contrast.
It effectively protects the authenticity of the character's skin tone, avoids color distortion, improves the visual consistency and overall image quality between video frames, and makes the contrast enhancement effect more natural and continuous.
Smart Images

Figure CN118840305B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to, but is not limited to, the field of image processing technology, and in particular to a video contrast enhancement method, device, electronic device and storage medium. Background Art
[0002] Contrast enhancement algorithms are a class of image processing techniques used to adjust the contrast of an image to improve image quality. In the field of digital image processing, contrast usually refers to the degree of difference between the parts of an image, including light and dark contrast and color contrast. High contrast means that the color and brightness changes in the image are more obvious, making the image details more clearly visible. In contrast, a low-contrast image will appear flat and details will be difficult to discern.
[0003] In related technologies, in order to improve image clarity, image contrast enhancement processing is usually performed on the image, and the image clarity and transparency are improved by adjusting the contrast of the entire image or part of the image to improve the visual effect of the image. At present, the contrast enhancement processing of the image is generally performed by filtering the image and then stretching the filtered image as a whole, but this method easily causes color distortion of the face part of the image, and the image contrast enhancement effect is poor. Summary of the invention
[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
[0005] The embodiments of the present application provide a video contrast enhancement method, device, electronic device and storage medium, which can enhance the contrast of each frame image in a video and also preserve the true skin color of the character.
[0006] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a video contrast enhancement method, comprising: obtaining multiple frame images of a video to be processed, and for each of the frame images, cutting the frame image to obtain multiple regional images; obtaining first pixel information of each pixel point in each of the regional images, and determining each of the regional images as one of a skin quality image or a non-skin quality image based on the first pixel information; for each of the frame images, determining a cropping threshold based on the first pixel information in the non-skin quality image corresponding to the current frame image and the first pixel information in the regional image corresponding to the previous frame image, and determining a first adjustment function according to the first pixel information and the cropping threshold, wherein the cropping threshold is used to represent the adjustment range of the first pixel information; performing identity mapping on the skin quality image corresponding to the current frame image, adjusting the non-skin quality image corresponding to the current frame image according to the first adjustment function, and obtaining a first adjusted image corresponding to the current frame image; inputting the first adjusted image into a preset adjustment model for adjustment, and obtaining a second adjusted image; performing interpolation processing on the second adjusted image, determining a target image corresponding to the current frame image, and determining a target video according to the target images corresponding to each of the frame images.
[0007] In one embodiment, the first pixel information includes a first point brightness and a first point chromaticity of each pixel in the regional image, and for each of the frame images, a cropping threshold is determined based on the first pixel information in the non-skin image corresponding to the current frame image and the first pixel information in the regional image corresponding to the previous frame image, and a first adjustment function is determined according to the first pixel information and the cropping threshold, including: determining a chromaticity mean based on the first point chromaticity of each pixel in the previous regional image in a time series; determining a cropping threshold for each of the non-skin images according to the chromaticity mean, the first pixel information of each pixel in the current non-skin image and a preset chromaticity weight; and determining a first adjustment function corresponding to each of the non-skin images based on the first point brightness of each pixel in the current non-skin image and the cropping threshold.
[0008] In one embodiment, the first adjustment function corresponding to each non-skin image is determined based on the first point brightness of each pixel point in the current non-skin image and the cropping threshold, including: determining the brightness distribution function of the current non-skin image based on the first point brightness; determining the first adjustment function according to the brightness distribution function and the cropping threshold.
[0009] In one embodiment, the adjustment model includes a first blur module and a second blur module, the first adjustment image includes a plurality of first image blocks, the first image blocks correspond one-to-one to the current regional image, the second adjustment image includes a plurality of second image blocks, the second image blocks correspond one-to-one to the first image blocks, and the first adjustment image is input into a preset adjustment model to obtain a second adjusted image, including: obtaining the second point brightness of each of the pixel points in each of the first image blocks, and determining the brightness variance corresponding to each of the first image blocks; inputting each of the brightness variances into the first blur module in sequence to obtain the first blur parameter corresponding to each of the first image blocks; inputting the second point brightness and the first blur parameter into the second blur module to determine a second adjustment function, and determining the second image block corresponding to each of the first image blocks according to the second adjustment function.
[0010] In one embodiment, the first fuzzy module includes a first precise function and multiple first fuzzy functions, and the step of inputting each of the brightness variances into the first fuzzy module in sequence to obtain the first fuzzy parameters corresponding to each of the first image blocks includes: performing fuzzy reasoning on each of the brightness variances in sequence to determine the offset ratio corresponding to each of the first image blocks; inputting the brightness variances into each of the first fuzzy functions in sequence to obtain multiple first memberships; and inputting the offset ratio, all of the first memberships and a preset first adjustment weight into the first precise function to obtain the first fuzzy parameter corresponding to each of the first image blocks.
[0011] In one embodiment, fuzzy reasoning is performed on each of the brightness variances in turn to determine the offset ratio corresponding to each of the first image blocks, including: when the brightness variance is small, the corresponding offset ratio is high; when the brightness variance is medium, the corresponding offset ratio is medium; when the brightness variance is large, the corresponding offset ratio is low.
[0012] In one embodiment, the second fuzzy module includes multiple second fuzzy functions, and the second point brightness and the first fuzzy parameter are input into the second fuzzy module to determine the second adjustment function, and the second image block corresponding to each first image block is determined according to the second adjustment function, including: obtaining the second point brightness of each pixel point in the first image block, determining the brightness mean of each first image block, performing fuzzy reasoning on each second point brightness, and determining the fuzzy brightness corresponding to each pixel point; inputting the second point brightness into each second fuzzy function in turn to obtain a second membership, and determining a second adjustment weight based on the second membership and the first fuzzy parameter corresponding to each first image block; determining a second adjustment function based on the fuzzy brightness, a preset second adjustment weight and the second membership, and determining the second image block corresponding to each first image block according to the second adjustment function.
[0013] In addition, to achieve the above-mentioned purpose, the second aspect of the present application proposes a video contrast enhancement device, including: an acquisition module, used to acquire multiple frame images of a video to be processed, and for each of the frame images, the frame image is cut to obtain multiple regional images; a determination module, used to acquire first pixel information of each pixel point in each of the regional images, and determine each of the regional images as one of a skin image or a non-skin image based on the first pixel information; a processing module, used to determine a cropping threshold for each of the frame images based on the first pixel information in the non-skin image corresponding to the current frame image and the first pixel information in the regional image corresponding to the previous frame image, according to The first pixel information and the cropping threshold determine a first adjustment function, wherein the cropping threshold is used to represent the adjustment range of the first pixel information; a first adjustment module is used to perform identity mapping on the skin quality image corresponding to the current frame image, and adjust the non-skin image corresponding to the current frame image according to the first adjustment function to obtain a first adjusted image corresponding to the current frame image; a second adjustment module is used to input the first adjusted image into a preset adjustment model for adjustment to obtain a second adjusted image; an interpolation module is used to perform interpolation processing on the second adjusted image to determine the target image corresponding to the current frame image, and determine the target video according to the target images corresponding to each frame image.
[0014] To achieve the above-mentioned purpose, the third aspect of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the video contrast enhancement method described in the first aspect is implemented.
[0015] To achieve the above-mentioned purpose, the fourth aspect of the present application proposes a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the video contrast enhancement method described in the first aspect is implemented.
[0016] The embodiments of the present application include at least the following beneficial effects: after extracting a frame image from a video to be processed, the frame image is segmented to obtain a plurality of regional images; in a video to be processed containing a person, some regional images are of human skin quality; by obtaining the first pixel information of the regional image, it is identified based on the first pixel information that the regional image belongs to a skin quality image or a non-skin quality image, thereby protecting the skin color area and avoiding distortion of the person's skin color; when the regional image is a skin quality image, an identity transformation is performed on the regional image, that is, the first pixel information of the regional image is not adjusted; when the regional image is a skin quality image, the temporal changes of the frame image are considered, and a cropping threshold is determined according to the first pixel information of the current regional image and the first pixel information of the regional image at the same position of the previous frame image in the time series. The cropping threshold is used to limit the maximum range of contrast stretching in the corresponding regional image. The first adjustment function is determined based on the cropping threshold. The regional image is adjusted by the first adjustment function corresponding to each other, which can avoid that some areas in the regional image are too bright or some areas are too dark, and can also alleviate the light and dark changes at the location of the regional image in the video to be processed, which helps to maintain the visual consistency between consecutive frames in the video to be processed and reduce the unnatural feeling caused by the contrast change between frames; after the first image block is adjusted by the preset adjustment model, the second image block is linearly interpolated, so that the edges of each second image block can be smoothed, which improves the visual quality of the second image block after enhancement, so that the target image maintains the overall naturalness and continuity while enhancing the local contrast.
[0017] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0019] Figure 1 A schematic diagram of an optional flow chart of a video contrast enhancement method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of an optional flow chart for determining a first adjustment function provided in an embodiment of the present application;
[0021] Figure 3 An optional specific flow chart of determining a first adjustment function provided in an embodiment of the present application;
[0022] Figure 4 An optional flow chart of an adjustment model provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of an optional process for determining a first fuzzy parameter provided in an embodiment of the present application;
[0024] Figure 6 A schematic diagram of an optional process for determining a second image block according to a first fuzzy parameter provided in an embodiment of the present application;
[0025] Figure 7 A schematic diagram of an optional method for linear interpolation provided in an embodiment of the present application;
[0026] Figure 8 A schematic diagram of an optional method for clipping a brightness distribution function provided in an embodiment of the present application;
[0027] Fig. 9 An optional function schematic diagram of the first fuzzy function provided in an embodiment of the present application;
[0028] Fig.10 An optional function diagram of the second fuzzy function provided in the embodiment of the present application;
[0029] Fig.11 A schematic diagram of an optional structure of the video contrast enhancement device provided in this embodiment;
[0030] Fig.12 A schematic diagram of an optional hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0032] In the description of this application, “several” means one or more, “more” means more than two, “greater than”, “less than”, “exceed”, etc. are understood to exclude the number, and “above”, “below”, “within”, etc. are understood to include the number.
[0033] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims or the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0034] To facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:
[0035] The CLAHE algorithm (Contrast Limited Adaptive Histogram Equalization) is a contrast enhancement technique for image preprocessing. It reduces noise amplification by limiting contrast amplification during histogram equalization. The CLAHE algorithm is mainly divided into three parts. First, the input image is first segmented into multiple small areas. Then, each small area is histogram equalized, using predefined clipping limits to prevent excessive contrast amplification. Histogram equalization includes histogram calculation, excess calculation, excess allocation, excess reallocation, and scaling and mapping using cumulative distribution functions. Finally, the processed tiles are stitched together using a bilinear interpolation method to generate an output image with improved contrast. Finally, the processed small area images are stitched together using a bilinear interpolation method to generate an output image with improved contrast.
[0036] The HSV color space is an improvement on the traditional RGB model, which introduces three main components to define color: hue, saturation, and value. The core of the HSV model is hue. The HSV color space corresponds to a cone-shaped model, in which hue (H) represents the type of color and the position of the color on the color wheel; saturation (S) represents the purity of the color; and value (V) represents the lightness and darkness of the color. In the HSV model, the top surface of the cone represents various combinations of saturation and value, while the height of the cone represents different brightness from black to white.
[0037] In related technologies, in order to improve image clarity, image contrast enhancement processing is usually performed on the image, and the image clarity and transparency are improved by adjusting the contrast of the entire image or part of the image to improve the visual effect of the image. At present, the contrast enhancement processing of the image is generally performed by filtering the image and then stretching the filtered image as a whole, but this method easily causes color distortion of the face part of the image, and the image contrast enhancement effect is poor.
[0038] Based on this, the embodiments of the present application provide a video contrast enhancement method, device, electronic device and storage medium. After extracting a frame image from a video to be processed, the frame image is segmented to obtain a plurality of regional images. In the video to be processed containing a person, there are some regional images of human skin. By obtaining the first pixel information of the regional image, it is identified based on the first pixel information that the regional image belongs to a skin image or a non-skin image, thereby protecting the skin color area and avoiding distortion of the person's skin color. When the regional image is a skin image, an identity transformation is performed on the regional image, that is, the first pixel information of the regional image is not adjusted. When the regional image is a skin image, the temporal change of the frame image is considered, and according to the first pixel information of the current regional image and the first pixel information of the regional image at the same position of the previous frame image in the time series, The information determines a cropping threshold, and the cropping threshold is used to limit the maximum range of contrast stretching in the corresponding regional image. The first adjustment function is determined based on the cropping threshold. The regional images are adjusted by the corresponding first adjustment functions, which can avoid that some areas in the regional images are too bright or some areas are too dark, and can also alleviate the light and dark changes at the locations of the regional images in the video to be processed, which helps to maintain the visual consistency between consecutive frames in the video to be processed and reduce the unnatural feeling caused by the contrast change between frames; after the first adjustment image is adjusted by the preset adjustment model, the second adjustment image is linearly interpolated, so that the edges of each second adjustment image can be smoothed, thereby improving the visual quality of the second adjustment image after enhancement, so that the target image maintains the overall naturalness and continuity while enhancing the local contrast.
[0039] The video contrast enhancement method, device, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the video contrast enhancement method in the embodiments of the present application is described.
[0040] The video contrast enhancement method provided in the embodiment of the present application relates to the field of computer technology. The video contrast enhancement method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or can be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the video contrast enhancement method, etc., but is not limited to the above forms.
[0041] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0042] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0043] like Figure 1 As shown, Figure 1 An optional flow chart of a video contrast enhancement method provided in an embodiment of the present application is provided. The video contrast enhancement method may be executed by a server, or may be executed by a terminal, or may be executed by a server in cooperation with a terminal. The video contrast enhancement method includes but is not limited to the following steps S110 to S160:
[0044] Step S110, obtaining a plurality of frame images of the video to be processed, and cutting each frame image to obtain a plurality of region images;
[0045] Step S120, obtaining first pixel information of each pixel point in each regional image, and determining each regional image as a skin image or a non-skin image based on the first pixel information;
[0046] Step S130, for each frame image, determining a cropping threshold based on first pixel information in a non-skin image corresponding to a current frame image and first pixel information in a region image corresponding to a previous frame image, and determining a first adjustment function according to the first pixel information and the cropping threshold, wherein the cropping threshold is used to represent an adjustment range of the first pixel information;
[0047] Step S140, performing identity mapping on the skin quality image corresponding to the current frame image, and adjusting the non-skin image corresponding to the current frame image according to a first adjustment function to obtain a first adjusted image corresponding to the current frame image;
[0048] Step S150, inputting the first adjusted image into a preset adjustment model for adjustment to obtain a second adjusted image;
[0049] Step S160 , interpolating the second adjusted image to determine a target image corresponding to the current frame image, and determining a target video according to the target images corresponding to each frame image.
[0050] It can be understood that after extracting the frame image from the video to be processed, the frame image is segmented to obtain multiple regional images. In the video to be processed containing a person, there are some regional images with human skin quality. By obtaining the first pixel information of the regional image, it is identified based on the first pixel information that the regional image belongs to a skin quality image or a non-skin quality image, thereby protecting the skin color area and avoiding distortion of the person's skin color. When the regional image is a skin quality image, an identity transformation is performed on the regional image, that is, the first pixel information of the regional image is not adjusted. When the regional image is a skin quality image, the temporal change of the frame image is considered, and the cropping threshold is determined according to the first pixel information of the current regional image and the first pixel information of the regional image at the same position of the previous frame image in the time series. The cropping threshold is used The maximum range of contrast stretching in the corresponding regional image is limited, and the first adjustment function is determined based on the cropping threshold. The regional images are adjusted by the first adjustment functions corresponding to each other. This can avoid that some areas in the regional image are too bright or some areas are too dark, and can also alleviate the light and dark changes at the location of the regional image in the video to be processed, which helps to maintain the visual consistency between consecutive frames in the video to be processed and reduce the unnatural feeling caused by the contrast change between frames; after the first adjustment image is adjusted by the preset adjustment model, the second adjustment image is linearly interpolated, so that the edges of each second adjustment image can be smoothed, which improves the visual quality of the second adjustment image after enhancement, so that the target image maintains the overall naturalness and continuity while enhancing the local contrast.
[0051] In a specific embodiment, after extracting a frame image from a video to be processed, the frame image is converted from an RGB color space to an HSV color space, and the first pixel information includes a first-point brightness, a first-point chromaticity, and a first-point saturation of each pixel point in the regional image. When the first-point brightness is within a preset skin color brightness range, the first-point chromaticity is within a preset skin color chromaticity range, and the first-point saturation is within a preset skin color saturation range, the pixel point is determined to be a skin color point. When the number of skin color points is greater than a preset skin color number threshold, the regional image is determined to be a skin quality image; otherwise, the regional image is determined to be a non-skin image.
[0052] In a specific embodiment, referring to Figure 7 As shown, Figure 1In step S160, the midpoint of each second image block in each second adjusted image is selected as the reference pixel, assuming that the coordinates of the reference pixels at the upper left corner, the upper right corner, the lower left corner and the lower right corner in the second adjusted image are (X1, Y1), (X1, Y2), (X2, Y1) and (X2, Y2) respectively, when the coordinates (x, y) of the pixel point to be adjusted satisfy x≤X1 and y≤Y1, the pixel point is not adjusted, when x≤X1 and y≥Y2, the pixel point is not adjusted, when x≥X2 and y≤Y1, the pixel point is not adjusted, and when x≥X2 and y≥Y2, the pixel point is not adjusted;
[0053] When the pixel coordinates (x, y) satisfy y≤Y1 and X1≤x≤X2, single linear interpolation is performed through (X1, Y1) and (X2, Y1); when y≥Y2 and X1≤x≤X2, single linear interpolation is performed through (X1, Y2) and (X2, Y2); when x≤X1 and Y1≤x≤Y2, single linear interpolation is performed through (X1, Y1) and (X1, Y2); when x≥X2 and Y1≤x≤Y2, single linear interpolation is performed through (X2, Y1) and (X2, Y2);
[0054] When the pixel point coordinates (x, y) satisfy X1≤x≤X2 and Y1≤x≤Y2, bilinear interpolation is performed on the pixel point using the four reference pixels that are most adjacent to the pixel point.
[0055] In addition, in one embodiment of the present application, the first pixel information includes the first point brightness and the first point chromaticity of each pixel in the regional image, referring to Figure 2 As shown, Figure 1 The method step S130 includes but is not limited to the following steps S210 to S230:
[0056] Step S210, determining a chromaticity mean value based on the first point chromaticity of each pixel in the previous regional image in the time series;
[0057] Step S220, determining a cropping threshold of each non-skin image according to the chromaticity mean, first pixel information of each pixel point in the current non-skin image, and a preset chromaticity weight;
[0058] Step S230: determining a first adjustment function corresponding to each non-skin image based on the first point brightness of each pixel in the current non-skin image and the cropping threshold.
[0059] Specifically, after obtaining the chromaticity mean of the previous regional image in the time series and the chromaticity of the first point of the current regional image, the chromaticity weighted difference sum of the current regional image is calculated:
[0060]
[0061] Among them, h n Indicates the chromaticity of the first point of the nth pixel in the current area image, h_mean indicates the chromaticity mean, s n represents the first point saturation of the nth pixel in the current region image, h_dif represents the weighted chromaticity difference, and N represents the number of pixels in the region image;
[0062] Then, calculate the clipping threshold:
[0063]
[0064] Among them, para represents the chroma weight, and clip_limit represents the clipping threshold.
[0065] In addition, one embodiment of the present application, referring to Figure 3 As shown, Figure 2 Step S230 in the embodiment includes but is not limited to the following steps S310 to S320:
[0066] Step S310, determining a brightness distribution function of the current non-skin image based on the brightness of the first point;
[0067] Step S320: determining a first adjustment function according to the brightness distribution function and the clipping threshold.
[0068] In a specific embodiment, the present application processes a non-skin image based on the CLAHE method. After obtaining the brightness of the first point of the regional image, a brightness histogram of the regional image is drawn with brightness as the horizontal coordinate and the number of pixels as the vertical coordinate, and each number column in the brightness histogram is divided by the number of pixels to obtain a brightness distribution function; the storage bit width of the brightness is obtained, and the adjustment coefficient and the maximum adjustment threshold are determined based on the brightness distribution function, the storage bit width and the clipping threshold, and the first adjustment function is determined according to the adjustment coefficient and the maximum adjustment threshold.
[0069] Specifically, the above calculation process is as follows:
[0070] Reference Figure 8 As shown, first, obtain the brightness histogram HIST(i) and calculate the brightness distribution function:
[0071] PDF(i)=HIST(i) / N
[0072] Then, calculate the adjustment factor:
[0073]
[0074]
[0075] Among them, refer to Fig. 9As shown in the figure, PDF(i) represents the brightness distribution function, i represents the brightness value, bit_wide represents the storage bit width of the brightness, taking 8-bit storage bit width as an example, bit_wide=256, at this time, the minimum value of i is 0, indicating the darkest, and the maximum value of i is 255, indicating the brightest, steal(i) represents the difference between the number of pixels with brightness i and the clipping threshold, when the number of pixels with brightness i is greater than the clipping threshold, steal(i) is equal to the difference between the number of pixels and the clipping threshold, when the number of pixels with brightness i is less than or equal to the clipping threshold, steal(i) is equal to 0, add_clip is the adjustment coefficient;
[0076] Then, calculate the maximum adjustment threshold:
[0077] upper=clip_limit-add_clip
[0078] Then, calculate the target distribution function:
[0079]
[0080] Wherein, upper represents the maximum adjustment threshold. When PDF(i) in the brightness distribution function is greater than the maximum adjustment threshold, PDF(i) will be limited to the clipping threshold. When PDF(i) in the brightness distribution function is less than or equal to the maximum adjustment threshold, the adjustment coefficient is added to the original PDF(i) to obtain the target distribution function.
[0081] Then, the target cumulative histogram is determined according to the target distribution function:
[0082] CDF_dst(0)=PDF_dst(0)
[0083] CDF_dst(i)=CDF_dst(i-1)+PDF_dst(i)
[0084] Among them, CDF_dst(i) represents the number of pixels from brightness 0 to brightness i;
[0085] Then, the first adjustment function LUT1(i) corresponding to the current region image is determined according to the target cumulative histogram:
[0086] LUT1(i)=CDF_dst(i)×bit_wide
[0087] It can be understood that by limiting the extreme values of the brightness histogram (peak clipping) and redistributing these values (valley filling), the contrast of the image is enhanced while avoiding excessive enhancement of noise, thereby achieving local contrast enhancement and improving the visual effect of the image without sacrificing image quality.
[0088] In addition, in one embodiment of the present application, the adjustment model includes a first blur module and a second blur module, the first adjustment image includes a plurality of first image blocks, the first image blocks correspond to the current regional image one by one, the second adjustment image includes a plurality of second image blocks, the second image blocks correspond to the first image blocks one by one, and the Figure 4 As shown, Figure 1 The method step S150 includes but is not limited to the following steps S410 to S430:
[0089] Step S410, obtaining the second point brightness of each pixel in each first image block, and determining the brightness variance corresponding to each first image block;
[0090] Step S420, inputting each brightness variance into the first fuzzy module in sequence to obtain first fuzzy parameters corresponding to each first image block;
[0091] Step S430: input the second point brightness and the first fuzzy parameter into a second fuzzy module, determine a second adjustment function, and determine the second image block corresponding to each first image block according to the second adjustment function.
[0092] Specifically, the first fuzzy module includes a preset first fuzzy rule, obtains the second point brightness of each pixel in the first image block, calculates the brightness variance of each first image block, and determines the membership of the brightness variance based on the first fuzzy rule. According to the rule of thumb, when the brightness variance is large, it means that the contrast of the first image block is strong, and it needs to be mapped to a darker one. When the brightness variance is small, it means that the contrast of the first image block is weak, and it needs to be mapped to a brighter one. By setting the first fuzzy module based on the first fuzzy rule, the contrast adjustment direction can be customized according to different image features and enhancement requirements, the contrast enhancement effect of the first adjustment function can be mitigated, and the visual effect of the image can be improved.
[0093] In addition, in one embodiment of the present application, the first fuzzy module includes a first precise function and a plurality of first fuzzy functions, referring to Figure 5 As shown, Figure 4 The method step S420 includes but is not limited to the following steps S510 to S530:
[0094] Step S510, performing fuzzy reasoning on each brightness variance in turn to determine the offset ratio corresponding to each first image block;
[0095] Step S520, inputting the brightness variance into each first fuzzy function in sequence to obtain a plurality of first membership degrees;
[0096] Step S530: input the offset ratio, all first membership degrees and the preset first adjustment weight into a first precise function to obtain first blur parameters corresponding to each first image block.
[0097] In a specific embodiment, the first fuzzy function is as follows Fig. 9 As shown, the calculation process of the first fuzzy parameter is as follows:
[0098] First, for one of the first image blocks, the brightness mean v_mean in the first image block is calculated based on the target probability distribution:
[0099]
[0100] Then, the brightness variance sd_v is calculated based on the brightness mean:
[0101]
[0102] Then, fuzzy reasoning is performed on the brightness variance, and the first fuzzy rule of fuzzy reasoning is:
[0103] Rule 1: If the brightness variance is small, the offset ratio is high;
[0104] Rule 2: If the brightness variance is medium, then the offset ratio is medium;
[0105] Rule 3: If the brightness variance is large, the offset ratio is low.
[0106] Then, the first fuzzy function corresponds to the first fuzzy rule one by one, and the brightness variance is input into Fig. 9 Among the three first fuzzy functions shown, three first membership degrees are obtained;
[0107] Then, the offset weights corresponding to the offset ratios are obtained, and the first fuzzy parameters are calculated based on the first precise function according to the offset weights, the first membership degree, and the result values corresponding to the first fuzzy rules:
[0108]
[0109] Among them, prop represents the first fuzzy parameter, represents the result value preset by the jth first fuzzy rule, It represents the first membership degree obtained by inputting the brightness variance into the jth first fuzzy function. represents the offset weight corresponding to the jth first membership degree. The result value of each first fuzzy rule is preset according to actual needs and will not be restricted here. The value of the result value is positively correlated with the actual value of the brightness variance;
[0110] In addition, in one embodiment of the present application, the second fuzzy module includes a plurality of second fuzzy functions, referring to Figure 6 As shown, Figure 4 Step S430 in the embodiment includes but is not limited to the following steps S610 to S630:
[0111] Step S610, obtaining the second point brightness of each pixel in the first image block, determining the brightness mean of each first image block, performing fuzzy reasoning on each second point brightness, and determining the fuzzy brightness corresponding to each pixel;
[0112] Step S620, inputting the second point brightness into each second fuzzy function in sequence to obtain a second membership degree, and determining a second adjustment weight based on the second membership degree and a first fuzzy parameter corresponding to each first image block;
[0113] Step S630: determining a second adjustment function based on the blurred brightness, a preset second adjustment weight and a second membership degree, and determining a second image block corresponding to each first image block according to the second adjustment function.
[0114] In a specific embodiment, the second fuzzy function is as follows: Fig.10 As shown, in the second fuzzy module, for any second image block, all brightness values a within the storage bit width are traversed, and each brightness value a is blurred. The second fuzzy rule is as follows:
[0115] Rule 1: If the input brightness is black, then the output brightness is black, and the result value is ;
[0116] Rule 2: If the input brightness is dark, then the output brightness is darker, and the result value is ;
[0117] Rule 3: If the input brightness is gray, then the output brightness is gray, and the result value is ;
[0118] Rule 4: If the input brightness is bright, then the output brightness is brighter, and the result value is ;
[0119] Rule 5: If the input brightness is white, then the output brightness is white, and the result value is ;
[0120] Wherein, prop is the first blur parameter of the first image block corresponding to the second image block currently being processed;
[0121] Then, the second fuzzy function corresponds to the second fuzzy rule one by one, and all brightness values a within the storage bit width are input Fig.10 In the second fuzzy function shown, a plurality of second membership degrees are obtained;
[0122] Then, the result values of each second fuzzy rule and the second adjustment weights of each output brightness are obtained, and a second adjustment function is determined based on the second membership degree, the result values of each second fuzzy rule and the second adjustment weights of each output brightness. The formula of the second adjustment function is:
[0123]
[0124] Among them, LUT2 is the second adjustment function, represents the result value of the jth second fuzzy rule, represents the jth second membership, represents the second adjustment weight corresponding to the j-th output brightness. When the brightness value of the pixel in the first image block is a, the brightness value of the corresponding pixel in the second image block is adjusted to LUT2(a).
[0125] It can be understood that by calling the adjustment model and using the first fuzzy rule and the second fuzzy rule to perform fuzzy adjustment on each first image block, the fuzzy adjustment method can classify bright and dark areas and make adjustments based on the brightness distribution of the local area, thereby effectively retaining the details and texture information of the image. In addition, by processing the brightness value through the first fuzzy function and the second fuzzy function, useful signals can be selectively enhanced in the process of enhancing contrast, while suppressing noise and improving image quality.
[0126] In addition, the embodiment of the present application further provides a video contrast enhancement device 1100, comprising:
[0127] The acquisition module 1110 is used to acquire multiple frame images of the video to be processed, and for each frame image, cut the frame image to obtain multiple region images;
[0128] A determination module 1120 is used to obtain first pixel information of each pixel point in each regional image, and determine each regional image as a skin image or a non-skin image based on the first pixel information;
[0129] The processing module 1130 is used to determine, for each frame image, a cropping threshold based on first pixel information in a non-skin image corresponding to a current frame image and first pixel information in a region image corresponding to a previous frame image, and determine a first adjustment function according to the first pixel information and the cropping threshold, wherein the cropping threshold is used to indicate an adjustment range of the first pixel information;
[0130] A first adjustment module 1140 is used to perform identity mapping on the skin quality image corresponding to the current frame image, and adjust the non-skin image corresponding to the current frame image according to a first adjustment function to obtain a first adjusted image corresponding to the current frame image;
[0131] The second adjustment module 1150 is used to input the first adjustment image into a preset adjustment model for adjustment to obtain a second adjustment image;
[0132] The interpolation module 1160 is used to perform interpolation processing on the second adjusted image, determine the target image corresponding to the current frame image, and determine the target video according to the target images corresponding to each frame image.
[0133] The video contrast enhancement device 1100 and the video contrast enhancement method are based on the same inventive concept, and will not be described in detail herein.
[0134] In addition, refer to Fig.12 , Fig.12 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0135] The processor 1201 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0136] The memory 1202 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1202 may store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1202, and the processor 1201 calls and executes the video contrast enhancement method of the embodiment of the present application, for example, executing the above-described Figure 1 Steps S110 to S160 of the method, Figure 2 Steps S210 to S230 of the method, Figure 3 Steps S310 to S320 of the method, Figure 4 Steps S410 to S430 of the method, Figure 5 Steps S510 to S530 of the method, Figure 6 Steps S610 to S630 of the method;
[0137] Input / output interface 1203, used to implement information input and output;
[0138] The communication interface 1204 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0139] A bus 1205 that transmits information between various components of the device (e.g., the processor 1201, the memory 1202, the input / output interface 1203, and the communication interface 1204);
[0140] The processor 1201 , the memory 1202 , the input / output interface 1203 and the communication interface 1204 are connected to each other in communication within the device via the bus 1205 .
[0141] The embodiment of the present application also provides a storage medium, which is a computer-readable storage medium for computer-readable storage. The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned video contrast enhancement method, for example, to execute the above-described Figure 1 Steps S110 to S160 of the method, Figure 2 Steps S210 to S230 of the method, Figure 3 Steps S310 to S320 of the method, Figure 4 Steps S410 to S430 of the method, Figure 5 Steps S510 to S530 of the method, Figure 6 Method steps S610 to S630.
[0142] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0143] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0144] It can be understood by those skilled in the art that Figures 1 to 6The technical solutions shown in the figure do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than those shown in the figure, or a combination of certain steps, or different steps.
[0145] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0146] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0147] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0148] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0149] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0150] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0152] If the integrated 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 technical solution of the present application, or the part that contributes to the prior art, or all or 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 multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0153] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A video contrast enhancement method, characterized in that: include: Acquire multiple frame images of the video to be processed, and for each of the frame images, cut the frame image to obtain multiple region images; Acquire first pixel information of each pixel point in each of the regional images, and determine each of the regional images as a skin quality image or a non-skin quality image based on the first pixel information; For each of the frame images, a cropping threshold is determined based on the first pixel information in the non-skin image corresponding to the current frame image and the first pixel information in the regional image corresponding to the previous frame image, and a first adjustment function is determined according to the first pixel information and the cropping threshold, wherein the cropping threshold is used to represent an adjustment range of the first pixel information; Performing identity mapping on the skin quality image corresponding to the current frame image, and adjusting the non-skin image corresponding to the current frame image according to the first adjustment function to obtain a first adjusted image corresponding to the current frame image; Inputting the first adjusted image into a preset adjustment model for adjustment to obtain a second adjusted image; Performing interpolation processing on the second adjusted image to determine a target image corresponding to the current frame image, and determining a target video according to the target images corresponding to each frame image; The first pixel information includes a first point brightness and a first point chromaticity of each pixel point in the regional image, and for each frame image, determining a clipping threshold based on the first pixel information in the non-skin image corresponding to the current frame image and the first pixel information in the regional image corresponding to the previous frame image, and determining a first adjustment function according to the first pixel information and the clipping threshold, including: Determine a chromaticity mean value based on the first point chromaticity of each of the pixel points in the previous regional image in the time series; Determine a cropping threshold of each of the non-skin images according to the chrominance mean, the first pixel information of each of the pixels in the current non-skin image, and a preset chrominance weight; Determine a first adjustment function corresponding to each of the non-skin images based on the first point brightness of each of the pixel points in the current non-skin image and the cropping threshold; The adjustment model includes a first blur module and a second blur module, the first adjustment image includes a plurality of first image blocks, the first image blocks correspond one-to-one to the current regional image, the second adjustment image includes a plurality of second image blocks, the second image blocks correspond one-to-one to the first image blocks, and the first adjustment image is input into a preset adjustment model to obtain a second adjustment image, including: Acquire the second point brightness of each pixel in each of the first image blocks, and determine the brightness variance corresponding to each of the first image blocks; Inputting each of the brightness variances into the first fuzzy module in sequence to obtain first fuzzy parameters corresponding to each of the first image blocks; The second point brightness and the first blur parameter are input into the second blur module to determine a second adjustment function, and the second image block corresponding to each of the first image blocks is determined according to the second adjustment function.
2. The video contrast enhancement method according to claim 1, characterized in that: The determining, based on the first point brightness of each pixel point in the current non-skin image and the cropping threshold, a first adjustment function corresponding to each non-skin image includes: Determine a brightness distribution function of the current non-skin image based on the brightness of the first point; A first adjustment function is determined according to the brightness distribution function and the clipping threshold.
3. The video contrast enhancement method according to claim 1, characterized in that: The first fuzzy module includes a first precise function and a plurality of first fuzzy functions, and the step of sequentially inputting the brightness variances into the first fuzzy module to obtain first fuzzy parameters corresponding to the first image blocks includes: Performing fuzzy reasoning on each of the brightness variances in turn to determine an offset ratio corresponding to each of the first image blocks; Inputting the brightness variance into each of the first fuzzy functions in sequence to obtain a plurality of first membership degrees; The offset ratio, all the first membership degrees and the preset first adjustment weight are input into the first precise function to obtain the first blur parameter corresponding to each of the first image blocks.
4. The video contrast enhancement method according to claim 3, characterized in that: The step of performing fuzzy reasoning on each of the brightness variances in sequence to determine the offset ratio corresponding to each of the first image blocks includes: When the brightness variance is small, the corresponding offset ratio is high; When the brightness variance is medium, the corresponding offset ratio is medium; When the brightness variance is large, the corresponding offset ratio is low.
5. The video contrast enhancement method according to claim 1, characterized in that: The second fuzzy module includes a plurality of second fuzzy functions, inputting the second point brightness and the first fuzzy parameter into the second fuzzy module, determining a second adjustment function, and determining the second image block corresponding to each of the first image blocks according to the second adjustment function, including: Acquire the second point brightness of each pixel in the first image block, determine the brightness mean of each first image block, perform fuzzy reasoning on each second point brightness, and determine the fuzzy brightness corresponding to each pixel; Inputting the brightness of the second point into each of the second fuzzy functions in sequence to obtain a second membership degree, and determining a second adjustment weight based on the second membership degree and a first fuzzy parameter corresponding to each of the first image blocks; A second adjustment function is determined based on the blurred brightness, a preset second adjustment weight and the second membership degree, and a second image block corresponding to each of the first image blocks is determined according to the second adjustment function.
6. A video contrast enhancement device, characterized in that: The video contrast enhancement device is used to execute the video contrast enhancement method according to any one of claims 1 to 5.
7. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the video contrast enhancement method according to any one of claims 1 to 5 when executing the computer program.
8. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the video contrast enhancement method according to any one of claims 1 to 5 is implemented.
