An image contrast enhancement method, system, device and storage medium
By iterative clustering and grayscale redistribution processing on the images, the problems of weak characterization capabilities and small grayscale proportions in the prior art are easily ignored, and the effect of image contrast enhancement is achieved.
Patent Information
- Application Number
- CN202110443477.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-23
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2041-04-23
AI Technical Summary
The existing image contrast enhancement algorithm has the problem that pixel features with weak characterization capabilities and small grayscale proportions are easily ignored.
The images are iteratively clustered by spatial adjustment factors and grayscale feature weight adjustment factors, divided into multiple blocks, and the grayscale contrast increment redistribution function is constructed, and the grayscale response value is smoothed by bilinear interpolation method.
The characterization ability of image contrast enhancement is improved, ensuring that pixel features with a small proportion in the grayscale level are not ignored, and the contrast enhancement image is clearer and has good adaptability.
Smart Images

Figure CN115239571B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer image processing, and in particular to an image contrast enhancement method, system, device and storage medium. Background Art
[0002] Image contrast refers to the measurement of the different brightness levels between the brightest white and the darkest black in the light and dark areas of an image, that is, the size of the grayscale contrast of an image; and the image enhancement algorithm can improve the overall and local contrast of the image and highlight the detailed information of the image. The image after contrast enhancement processing can be more in line with the visual characteristics of the human eye and easier for machines to recognize. Image enhancement algorithms have a wide range of applications in military and civilian fields.
[0003] In practical applications, grayscale mapping function-based remapping algorithms have relatively better adaptability in image contrast enhancement algorithms. However, the core of grayscale mapping function-based remapping algorithms is the construction of the remapping function. Conventional mapping function construction methods, such as exponential function, logarithmic function, and cumulative grayscale distribution function, often have shortcomings such as weak representation ability and complex parameter settings. Although the cumulative grayscale distribution function method has strong adaptability, its grayscale remapping process usually lacks effective theoretical support. The remapping function constructed by the grayscale distribution function easily leads to the neglect of detailed features expressed by pixels with a small proportion in the grayscale level. To solve this problem, a large number of modified algorithms have emerged, such as dual histogram equalization, maximum brightness dual histogram equalization, logarithmic histogram equalization, and local restricted histogram equalization. They all attempt to reduce and set mechanisms to redistribute probability distributions to reduce the problems of excessive contrast stretching or loss of detail information. However, these algorithms are still fundamentally inseparable from the basic idea of constructing a remapping function based on grayscale probability distribution. Therefore, they still cannot eliminate the basic problem that grayscale probability distribution cannot explain the logical effect to be achieved by image enhancement.
[0004] In summary, the image contrast enhancement methods in the prior art have problems such as weak representation ability and the features of pixels with a small proportion of gray levels are easily ignored. Summary of the Invention
[0005] In view of the above shortcomings of the prior art, the object of the present invention is to provide an image contrast enhancement method, system, device and storage medium to improve the problems of the image contrast enhancement algorithm in the prior art, such as weak representation ability and the easy neglect of the features of pixels with a small grayscale ratio.
[0006] To achieve the above and other related objectives, the present invention provides an image contrast enhancement method, comprising:
[0007] The image to be processed is iteratively clustered using the spatial adjustment factor and the grayscale feature weight adjustment factor to obtain multiple blocks;
[0008] For each block:
[0009] According to the preset target grayscale range, the effective grayscale span value and the optimal grayscale span value of all pixels are obtained;
[0010] Constructing a grayscale contrast increment redistribution function according to the effective grayscale span value;
[0011] Remapping all pixels based on the grayscale contrast increment redistribution function and the optimal grayscale span value;
[0012] The bilinear interpolation method is used to smooth the grayscale response values of the remapped pixels in each block to obtain the fused grayscale response values of each block.
[0013] In one embodiment of the present invention, the step of iteratively clustering the image to be processed using the spatial adjustment factor and the grayscale feature weight adjustment factor to obtain a plurality of blocks includes:
[0014] Dividing the image to be processed into a grid of a preset size;
[0015] For each grid of the image to be processed:
[0016] According to the domain coordinate offset value of each pixel, the grayscale response value of each pixel in the grid is calculated using the following formula, and the pixel with the smallest grayscale response value is used as the cluster center:
[0017] γ i =min|γ(x,y)-γ(x+Δx,y+Δy)|
[0018] Where: γ i is the grayscale response value of the i-th pixel; (x, y) is the coordinate of the current pixel, Δx is the neighborhood coordinate offset value of the current pixel on the x-coordinate; Δy is the neighborhood coordinate offset value of the current pixel on the y-coordinate;
[0019] According to the cluster center as the circle center, a circle is drawn with twice the length of the preset size as the radius to obtain a range circle;
[0020] The distance between each pixel in the range circle and the cluster center is calculated using the following formula:
[0021] z=η c z c +η s z s
[0022] Wherein, z is the distance; z c is the image grayscale distance metric between the current pixel and the cluster center, z s is the spatial distance measure between the current pixel and the cluster center; η s is the spatial adjustment factor; η c is the grayscale feature weight adjustment factor;
[0023] All pixels whose distance is less than a preset clustering threshold are taken as target pixels;
[0024] Iterative clustering is performed according to the target pixels to obtain the final block.
[0025] In one embodiment of the present invention, the step of iteratively clustering the target pixels to obtain the final blocks includes:
[0026] Processing all target pixels within the current range circle to obtain a geometric centroid and an expected value, wherein the expected value serves as a grayscale response value of the geometric centroid;
[0027] Draw a circle with the geometric centroid as the center and twice the length of the preset size as the radius to obtain the next range circle;
[0028] The following formula is used to calculate the error in the grayscale response value between the cluster center of the next range circle and the current range circle, and determine whether the error meets a preset iterative error;
[0029] ε=|γ r ′-γ r |
[0030] ε is the error; γ r ′ is the grayscale response value of the cluster center of the next range circle; γ r is the grayscale response value of the cluster center of the current range circle;
[0031] If yes, clustering all target pixels within the range circle to obtain the block;
[0032] If not, continue to obtain subsequent range circles.
[0033] In one embodiment of the present invention, the step of obtaining the effective grayscale span value and the optimal grayscale span value of all pixels according to the preset target grayscale range includes:
[0034] The expected grayscale and the effective grayscale span value within the block are calculated using the following formula;
[0035]
[0036] Where: μ k is the desired grayscale; s k is the effective grayscale span value; γ k is the grayscale response value of the kth pixel in the block; n is the total number of pixels in the block;
[0037] According to the target grayscale range, the optimal grayscale span value is calculated using the following formula:
[0038]
[0039] Wherein: span is the grayscale span value of the image to be processed; γ q is the grayscale response value of the qth pixel in the image to be processed; z k is the optimal grayscale span value; g max is the maximum value of the target grayscale range; g min is the minimum value of the target grayscale range.
[0040] In one embodiment of the present invention, the step of constructing a grayscale contrast increment redistribution function according to the effective grayscale span value includes:
[0041] Obtaining a minimum variance value according to a preset screening condition;
[0042] According to the minimum variance value and the effective grayscale span value, the grayscale contrast increment redistribution function is constructed using the following formula:
[0043]
[0044] Where: G is the grayscale contrast increment redistribution function, γ k is the grayscale response value of the kth pixel in the block; κ is the normalization coefficient; σ k is the minimum variance value; μ k is the desired grayscale.
[0045] In one embodiment of the present invention, the step of remapping all pixels based on the grayscale contrast increment redistribution function in combination with the optimal grayscale span value includes:
[0046] Processing to obtain a remapping function according to the grayscale contrast increment redistribution function and the optimal grayscale span value;
[0047] Remapping the grayscale response values of all pixels in the block according to the remapping function.
[0048] In one embodiment of the present invention, the step of smoothing the grayscale response values of the remapped pixels in each block using a bilinear interpolation method to obtain a fused grayscale response value of each block includes:
[0049] Select any of the blocks as a target block, and process to obtain the geometric centroid of the target block and adjacent blocks;
[0050] Processing to obtain the centroid distance between each of the adjacent blocks and the geometric centroid of the target block;
[0051] According to the centroid distance, a linear difference coefficient of each of the adjacent blocks is obtained by processing;
[0052] The fused grayscale response value of the geometric centroid of the target block is obtained by using the following formula:
[0053]
[0054] Among them: H tar is the fused grayscale response value; x is the linear difference coefficient of the adjacent blocks; T is the number of the adjacent blocks; γ is the grayscale response value; and L is the remapping function.
[0055] The present invention also discloses an image contrast enhancement system, which adopts the above-mentioned image contrast enhancement method. The image contrast enhancement system includes:
[0056] A block division module is used to iteratively cluster the image to be processed using a spatial adjustment factor and a grayscale feature weight adjustment factor to obtain multiple blocks;
[0057] Grayscale span calculation module, used for processing each block, according to the preset target grayscale range, to obtain the effective grayscale span value and the optimal grayscale span value of all pixels;
[0058] A function construction module, configured to construct a grayscale contrast increment redistribution function according to the effective grayscale span value in each block;
[0059] a remapping module, configured to remap all pixels based on the grayscale contrast increment redistribution function in combination with the optimal grayscale span value;
[0060] The fused grayscale response value processing module is used to smooth the grayscale response values of the remapped pixels in each block using a bilinear interpolation method to obtain the fused grayscale response values of each block.
[0061] The present invention also discloses an image contrast enhancement device, which includes a processor coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the above-mentioned image contrast enhancement method is implemented.
[0062] In summary, the image contrast enhancement method, system, device, and storage medium provided by the present invention have the following beneficial effects:
[0063] The present invention provides an image contrast enhancement method, system, device, and storage medium. Based on the grayscale distribution type of the image to be processed, the method first classifies, then enhances, and finally fuses the image. The parameter setting during the processing is relatively simple, and the characterization capability is good. The grayscale remapping process has effective theoretical support and has good adaptability. The contrast-enhanced image obtained by the image contrast enhancement method in this technical solution is clearer, and pixels with a small proportion in the grayscale level are not ignored. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0065] Figure 1 Shown is a system flow chart of the image contrast enhancement method of the present invention;
[0066] Figure 2 Shown is a schematic diagram of the principle structure of the image contrast enhancement system of the present invention;
[0067] Figure 3 Shown is a schematic diagram of the principle structure of the image contrast enhancement device of the present invention.
[0068] Component number description
[0069] 100. Image contrast enhancement system;
[0070] 110. Block division module;
[0071] 120. Grayscale span calculation module;
[0072] 130. Function building module;
[0073] 140. Remapping module;
[0074] 150. Fusion grayscale response value processing module;
[0075] 200. Image contrast enhancement equipment;
[0076] 210, processor;
[0077] 220. Memory. DETAILED DESCRIPTION
[0078] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following examples and the features in the examples can be combined with each other unless they conflict. It should also be understood that the terms used in the examples of the present invention are for the purpose of describing specific embodiments, not for the purpose of limiting the scope of protection of the present invention. The test methods for which specific conditions are not specified in the following examples are generally carried out under conventional conditions or under the conditions recommended by the manufacturers.
[0079] See also Figures 1 to 3 . It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the limiting conditions for the implementation of the present invention. Therefore, they have no substantive technical significance. Any modification of the structure, change in the proportional relationship or adjustment of the size should still fall within the scope of the technical content disclosed by the present invention without affecting the efficacy and purpose that can be achieved by the present invention. At the same time, the terms such as "upper", "lower", "left", "right", "middle" and "one" quoted in this specification are only for the convenience of description, and are not used to limit the scope of the implementation of the present invention. Changes or adjustments in their relative relationships should also be regarded as the scope of the implementation of the present invention without substantially changing the technical content.
[0080] When numerical ranges are given in the examples, it should be understood that unless otherwise specified herein, both endpoints of each numerical range and any value between the two endpoints may be used. Unless otherwise defined, all technical and scientific terms used herein are consistent with the prior art as understood by those skilled in the art and the description of the present invention. Any prior art methods, devices, and materials similar or equivalent to those described in the examples of the present invention may also be used to implement the present invention.
[0081] Image contrast refers to the measurement of the different brightness levels between the brightest white and the darkest black in the light and dark areas of an image, that is, the size of the grayscale contrast of an image; the larger the difference range, the greater the contrast, and the smaller the difference range, the smaller the contrast; the image contrast enhancement algorithm is used to increase the overall and local contrast in the image to highlight the image details, making the contrast-enhanced image clearer and easier to identify.
[0082] See also Figure 1 , this embodiment provides an image contrast enhancement method, including:
[0083] Step S100: Iteratively cluster the image to be processed using the spatial adjustment factor and the grayscale feature weight adjustment factor to obtain multiple blocks;
[0084] Specifically:
[0085] Dividing the image to be processed into a grid of a preset size;
[0086] The entire image to be processed is divided into S×S grids. For example, if the image to be processed is a single-channel image of 479×479 pixels, S can be 35.
[0087] Furthermore, steps S120 to S160 are performed for each grid of the image to be processed:
[0088] According to the domain coordinate offset value of each pixel, the grayscale response value of each pixel in the grid is calculated using the following formula, and the pixel with the smallest grayscale response value is used as the cluster center:
[0089] γ i =min|γ(x,y)-γ(x+Δx,y+Δy)|
[0090] Where: γ i is the grayscale response value of the i-th pixel; (x, y) is the coordinate of the current pixel, Δx is the neighborhood coordinate offset value of the current pixel on the x-coordinate; Δy is the neighborhood coordinate offset value of the current pixel on the y-coordinate;
[0091] Preferably, the 8×8 pixel center difference neighborhood pixels can be used here to extract the grayscale response value of pixel i; in order to ensure that the cluster center can better represent the basic pixel characteristics of the grid, the grayscale response values of all pixels in the grid relative to the domain pixels can be calculated, and the pixel i with the smallest grayscale response value is used as the cluster center, because the weaker the cluster center is, the better it can represent the pixel characteristics in the grid, and the lower the possibility of it being a boundary.
[0092] With the cluster center as the center and twice the length of the preset size as the radius, a range circle is obtained;
[0093] In order to ensure smoother segmentation after clustering between grids, the same type of clustering is performed with the pixel with (x, y) coordinates as the center and 2S as the search range.
[0094] The distance between each pixel in the range circle and the cluster center is calculated using the following formula:
[0095] z=η c z c +η s z s
[0096] Where z is the distance; z c is the image grayscale distance metric between the current pixel and the cluster center, z s is the spatial distance measure between the current pixel and the cluster center; η s is the spatial adjustment factor; η c is the grayscale feature weight adjustment factor;
[0097] Specifically:
[0098] Image grayscale distance metric z c You can use Euclidean distance representation, and the formula is as follows:
[0099] z c =|γ(x,y)-γ r |
[0100] Where: γ(x,y) is the grayscale response value at the coordinate position (x,y); γ r It is the grayscale response value of the cluster center of the current range circle.
[0101] Spatial distance metric z s The Euclidean distance between the actual coordinates of each pixel and the cluster center point of the current range circle can be used to represent the distance. The formula is as follows:
[0102]
[0103] Among them, (x, y) is the coordinate of the pixel, and (x0, y0) is the coordinate of the cluster center of the current range circle.
[0104] In order to adjust the importance of grayscale feature similarity and pixel space similarity in the entire similarity measurement, two normalized weights are introduced here: η s is the spatial adjustment factor. To eliminate the relationship between it and the specific image size, we can let η c is the grayscale feature weight adjustment factor, which can be set as a constant based on actual experience. W is the span between the pixel with the largest grayscale and the pixel with the smallest grayscale within the current range circle.
[0105] All pixels whose distance is less than a preset clustering threshold are regarded as target pixels;
[0106] When the distance is less than the clustering threshold, the pixel corresponding to the distance is regarded as the target pixel, that is, it is considered to be the pixel that forms the block together with the cluster center.
[0107] Iterative clustering is performed according to the target pixels to obtain the final block.
[0108] According to all target pixels within the current range circle, a geometric centroid and an expected value are obtained, and the expected value is used as the grayscale response value of the geometric centroid;
[0109] With the geometric centroid as the center and twice the length of the preset size as the radius, draw a circle to obtain the next range circle;
[0110] The following formula is used to calculate the error in the grayscale response value between the cluster center of the next range circle and the current range circle, and to determine whether the error satisfies a preset iterative error;
[0111] ε=|γ r ′-γ r |
[0112] ε is the error; γ r ′ is the grayscale response value of the cluster center of the next range circle; γ r is the grayscale response value of the cluster center of the current range circle;
[0113] If so, all target pixels within the range circle are clustered to obtain a block;
[0114] If not, continue to obtain subsequent range circles.
[0115] Specifically:
[0116] The expected value refers to the probability of each possible result in a discrete random variable experiment multiplied by the sum of its results. By calculating the expected value of the grayscale response value of all target pixels, the grayscale response value of the geometric centroid can be obtained more accurately.
[0117] The iterative error is the classification iteration accuracy set according to user needs during actual calculation. The larger the value, the faster the pixel clustering speed. When the error ε is less than the iterative error T ε When , the iteration ends, and all target pixels within the range circle are clustered to obtain a block.
[0118] Furthermore, for each block, steps S200 to S400 are performed:
[0119] Step S200: According to a preset target grayscale range, obtain the effective grayscale span value and the optimal grayscale span value of all pixels;
[0120] Specifically:
[0121] The expected grayscale and effective grayscale span value within the block are calculated using the following formula;
[0122]
[0123] Where: μ k is the expected grayscale; s k is the effective grayscale span value; γ k is the grayscale response value of the kth pixel in the block; n is the total number of pixels in the block;
[0124] According to the target grayscale range, the optimal grayscale span value is calculated using the following formula:
[0125]
[0126] Where: span is the grayscale span value of the image to be processed; γ q is the grayscale response value of the qth pixel in the image to be processed; z k is the optimal grayscale span value; g max is the maximum value of the target grayscale range; g min is the minimum value of the target grayscale range.
[0127] The target grayscale range is the desired image grayscale range input in advance by the user.
[0128] Step S300: constructing a grayscale contrast increment redistribution function according to the effective grayscale span value;
[0129] Obtaining a minimum variance value according to a preset screening condition;
[0130] According to the minimum variance value and the effective grayscale span value, the grayscale contrast increment redistribution function is constructed using the following formula:
[0131]
[0132] Where: G is the grayscale contrast increment redistribution function, γ k is the grayscale response value of the kth pixel in the block; κ is the normalization coefficient; σ k is the minimum variance value; μ k is the expected grayscale.
[0133] The process of obtaining the minimum variance value is as follows:
[0134] Preferably, the variance value can be taken as a positive integer σ k=1, gradually increase by 1 each time, and continue to bring it into the redistribution function until the redistribution function meets the preset screening conditions:
[0135] G(μ k -s k , σ k )≥1
[0136] Among them, G is the grayscale contrast increment redistribution function. When the variance value is brought into the grayscale contrast increment redistribution function to meet the screening conditions, the minimum variance value σ is obtained. k , then the minimum variance value σ k Substituting the grayscale contrast increment redistribution function into the grayscale contrast increment redistribution function gives the final grayscale contrast increment redistribution function.
[0137] Step S400: remap all pixels based on the grayscale contrast increment redistribution function and the optimal grayscale span value;
[0138] According to the grayscale contrast increment redistribution function and the optimal grayscale span value, a remapping function is obtained;
[0139] According to the remapping function, the grayscale response values of all pixels in the block are remapped.
[0140] Specifically:
[0141] The remapping function uses the following formula:
[0142]
[0143] Where: L is the remapping function; m is the grayscale response value.
[0144] Step S500: Using a bilinear interpolation method, smoothing the grayscale response values of the remapped pixels in each block to obtain a fused grayscale response value of each block;
[0145] Bilinear interpolation, also known as bilinear interpolation, is an extension of linear interpolation of an interpolation function with two variables. Its core idea is to perform linear interpolation in two directions respectively.
[0146] Specifically:
[0147] Select any block as the target block, and process it to obtain the geometric centroid of the target block and adjacent blocks;
[0148] When any block is selected from the image to be processed, its adjacent blocks may be 4 blocks, 3 blocks or 2 blocks.
[0149] Processing to obtain the centroid distance between each adjacent block and the geometric centroid of the target block;
[0150] According to the centroid distance, the linear difference coefficient of each adjacent block is obtained;
[0151] In a preferred embodiment, if the selected target block has four adjacent blocks, the linear interpolation coefficient of each adjacent block can be calculated using the following formula:
[0152]
[0153]
[0154]
[0155]
[0156] Among them, d UL d DL d UR d DR are the centroid distances between the target block and its upper left neighboring block, lower left neighboring block, upper right neighboring block, and lower right neighboring block respectively; x UL 、x UR 、x DL 、x DR are the linear interpolation coefficients of the target block relative to its upper left neighboring block, lower left neighboring block, upper right neighboring block, and lower right neighboring block, respectively.
[0157] The following formula is used to obtain the fused grayscale response value of the geometric centroid of the target block:
[0158]
[0159] Among them: H tar is the fused grayscale response value; x is the linear difference coefficient of adjacent blocks; T is the number of adjacent blocks; γ is the grayscale response value; L is the remapping function.
[0160] Specifically, T is between [2,4].
[0161] See also Figure 2 This embodiment further provides an image contrast enhancement system 100. Using the above-mentioned image contrast enhancement method, the image contrast enhancement system includes:
[0162] A block division module 110 is configured to iteratively cluster the image to be processed using a spatial adjustment factor and a grayscale feature weight adjustment factor to obtain a plurality of blocks;
[0163] Grayscale span calculation module 120, for processing each block to obtain the effective grayscale span value and the optimal grayscale span value of all pixels according to a preset target grayscale range;
[0164] A function construction module 130 is used to construct a grayscale contrast increment redistribution function according to the effective grayscale span value in each block;
[0165] a remapping module 140 for remapping all pixels based on a grayscale contrast increment redistribution function in combination with an optimal grayscale span value;
[0166] The fused grayscale response value processing module 150 is used to smooth the grayscale response values of the remapped pixels in each block using a bilinear interpolation method to obtain fused grayscale response values of each block.
[0167] See also Figure 3This embodiment also provides an image contrast enhancement device 200, which includes a processor 210 and a memory 220. The processor 210 and the memory 220 are coupled, and the memory 220 stores program instructions. When the program instructions stored in the memory 220 are executed by the processor 210, the above-mentioned image contrast enhancement method is implemented. The processor 210 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processing unit (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The memory 220 can include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. The memory 220 may also be an internal memory of the random access memory (RAM) type, and the processor 210 and the memory 220 may be integrated into one or more independent circuits or hardware, such as an application specific integrated circuit (ASIC). It should be noted that the computer program in the above-mentioned memory 220 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for enabling a computer device (which may be a personal computer, an electronic device, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention.
[0168] This embodiment also provides a computer-readable storage medium storing computer instructions for causing a computer to execute the above-described image contrast enhancement method. The storage medium can be an electronic medium, a magnetic medium, an optical medium, an electromagnetic medium, an infrared medium, or a semiconductor system or a propagation medium. The storage medium can also include semiconductor or solid-state memory, magnetic tape, a removable computer disk, a random access memory (RAM), a read-only memory (ROM), a hard disk, and an optical disk. Optical disks can include compact disk-read only memory (CD-ROM), compact disk-read / write (CD-RW), and DVD.
[0169] The present invention provides an image contrast enhancement method, system, device, and storage medium. Based on the grayscale distribution type of the image to be processed, the method first classifies, then enhances, and finally fuses the image. The parameter setting during the processing is relatively simple, and the characterization capability is good. The grayscale remapping process has effective theoretical support and has good adaptability. The contrast-enhanced image obtained by the image contrast enhancement method in this technical solution is clearer, and pixels with a small proportion in the grayscale level are not ignored.
[0170] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. A method for enhancing image contrast, characterized in that: include: The image to be processed is iteratively clustered using the spatial adjustment factor and the grayscale feature weight adjustment factor to obtain multiple blocks; For each block: According to the preset target grayscale range, the effective grayscale span value and the optimal grayscale span value of all pixels are obtained; Constructing a grayscale contrast increment redistribution function according to the effective grayscale span value; Remapping all pixels based on the grayscale contrast increment redistribution function and the optimal grayscale span value; The grayscale response values of the remapped pixels in each block are smoothed using the bilinear interpolation method to obtain the fused grayscale response values of each block. The step of obtaining the effective grayscale span value and the optimal grayscale span value of all pixels according to the preset target grayscale range includes: The expected grayscale and the effective grayscale span value within the block are calculated using the following formula: Where: μ k is the desired grayscale; s k is the effective grayscale span value; γ k is the grayscale response value of the kth pixel in the block; n is the total number of pixels in the block; According to the target grayscale range, the optimal grayscale span value is calculated using the following formula: Wherein: span is the grayscale span value of the image to be processed; γ q is the grayscale response value of the qth pixel in the image to be processed; z k is the optimal grayscale span value; g max is the maximum value of the target grayscale range; g min is the minimum value of the target grayscale range; s k is the effective grayscale span value; The step of constructing a grayscale contrast increment redistribution function according to the effective grayscale span value comprises: Obtaining a minimum variance value according to a preset screening condition; According to the minimum variance value and the effective grayscale span value, the grayscale contrast increment redistribution function is constructed using the following formula: Where: G is the grayscale contrast increment redistribution function, γ k is the grayscale response value of the kth pixel in the block; κ is the normalization coefficient; σ k is the minimum variance value; μ k is the desired grayscale.
2. The image contrast enhancement method according to claim 1, wherein: The step of iteratively clustering the image to be processed using the spatial adjustment factor and the grayscale feature weight adjustment factor to obtain multiple blocks includes: Dividing the image to be processed into a grid of a preset size; For each grid of the image to be processed: The grayscale response value of each pixel in the grid is calculated using the following formula, and the pixel with the smallest grayscale response value is used as the cluster center: c i =min|γ(x,y)-γ(x+Δx,y+Δy)| Where: γ i is the grayscale response value of the i-th pixel; (x, y) is the coordinate of the current pixel, Δx is the neighborhood coordinate offset value of the current pixel on the x-coordinate; Δy is the neighborhood coordinate offset value of the current pixel on the y-coordinate; According to the cluster center as the circle center, a circle is drawn with twice the length of the preset size as the radius to obtain a range circle; The distance between each pixel in the range circle and the cluster center is calculated using the following formula: z=η c With c +η s With s Wherein, z is the distance; z c is the image grayscale distance metric between the current pixel and the cluster center, z s is the spatial distance measure between the current pixel and the cluster center; η s is the spatial adjustment factor; η c is the grayscale feature weight adjustment factor; All pixels whose distance is less than a preset clustering threshold are taken as target pixels; Iterative clustering is performed according to the target pixels to obtain the final block.
3. The image contrast enhancement method according to claim 2, wherein: The step of performing iterative clustering according to the target pixels to obtain the final block includes: Processing all target pixels within the current range circle to obtain a geometric centroid and an expected value, wherein the expected value serves as a grayscale response value of the geometric centroid; Draw a circle with the geometric centroid as the center and twice the length of the preset size as the radius to obtain the next range circle; The following formula is used to calculate the error in the grayscale response value between the cluster center of the next range circle and the current range circle, and to determine whether the error satisfies a preset iterative error: e=|γ′ r -c r | ε is the error; γ′ r is the grayscale response value of the cluster center of the next range circle; r is the grayscale response value of the cluster center of the current range circle; If yes, clustering all target pixels within the range circle to obtain the block; If not, continue to obtain subsequent range circles.
4. The image contrast enhancement method according to claim 1, wherein: The step of remapping all pixels based on the grayscale contrast increment redistribution function and in combination with the optimal grayscale span value comprises: Processing to obtain a remapping function according to the grayscale contrast increment redistribution function and the optimal grayscale span value; Remapping the grayscale response values of all pixels in the block according to the remapping function.
5. The image contrast enhancement method according to claim 4, characterized in that: The step of smoothing the grayscale response values of the remapped pixels in each block by using a bilinear interpolation method to obtain the fused grayscale response values of each block includes: Select any of the blocks as a target block, and process to obtain the geometric centroid of the target block and the blocks adjacent to the target block; Processing to obtain the centroid distance between each of the adjacent blocks and the geometric centroid of the target block; According to the centroid distance, a linear difference coefficient of each of the adjacent blocks is obtained by processing; The fused grayscale response value of the geometric centroid of the target block is obtained by using the following formula: Among them: H tar is the fused grayscale response value; x is the linear difference coefficient of the adjacent blocks; T is the number of the adjacent blocks; γ is the grayscale response value; and L is the remapping function.
6. An image contrast enhancement system, characterized in that: According to any one of claims 1 to 5, the image contrast enhancement method is used, and the image contrast enhancement system includes: A block division module is used to iteratively cluster the image to be processed using a spatial adjustment factor and a grayscale feature weight adjustment factor to obtain multiple blocks; Grayscale span calculation module, used for processing each block, according to the preset target grayscale range, to obtain the effective grayscale span value and the optimal grayscale span value of all pixels; A function construction module, configured to construct a grayscale contrast increment redistribution function according to the effective grayscale span value in each block; a remapping module, configured to remap all pixels based on the grayscale contrast increment redistribution function in combination with the optimal grayscale span value; The fused grayscale response value processing module is used to smooth the grayscale response values of the remapped pixels in each block using a bilinear interpolation method to obtain the fused grayscale response values of each block.
7. An image contrast enhancement device, characterized in that: The method comprises a processor coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the image contrast enhancement method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that: The invention comprises a program which, when being run on a computer, causes the computer to execute the image contrast enhancement method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Improved Histogram equalization low-illumination image enhancement algorithm
CN106651818A
Infrared image denoising enhancement method, device and system based on local adaptive CLAHE, and computer readable storage medium
CN112365424A