Image enhancement method and terminal
By determining the image type and generating a histogram in the image enhancement method, identifying the pixel number threshold and slope correspondence, and calculating the image transformation relationship, the problem of low adaptability in existing technologies is solved, and a highly adaptive image enhancement effect is achieved.
Patent Information
- Application Number
- CN202310525848.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-12-06
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2038-12-06
AI Technical Summary
Existing histogram-based image enhancement methods have low adaptability and poor enhancement effects.
By determining the image type, the color image is converted to the YUV space, the brightness information is obtained to generate a histogram, the pixel number threshold is determined to correspond to the preset slope, the image transformation relationship is calculated based on the slope, and the image brightness transformation is performed.
It achieves adaptive and strong image enhancement, highlights image details, and has a good enhancement effect, providing an effective guarantee for subsequent observation and processing.
Smart Images

Figure CN116596808B_ABST
Abstract
Description
[0001] This application is a divisional application of the parent application with the filing date of December 6, 2018, the application number of 201811483637.5, and the inventor patent of "a histogram-based adaptive image enhancement method and terminal" as the parent application. TECHNICAL FIELD
[0002] The present application relates to the field of image processing, in particular to an image enhancement method and terminal. BACKGROUND
[0003] In recent years, with the rapid development of industrial technology and machine vision, the quality requirements for images are getting higher and higher. Whether it is used to improve the visual effect of the human eye or subsequent machine vision, or even intelligent post-processing, clearer and more detailed images are needed. However, in many application scenarios, due to the limitations and influences of the scene conditions, the visual effect of image shooting is poor, and the useful information in the image cannot be presented or effectively presented.
[0004] Image enhancement technology is a signal processing technology that enhances the local or overall features of an image by a series of transformations according to the quality and application of the image. The histogram of an image describes the number of pixels with that gray level in the image, which represents the relationship between the gray level and the probability distribution of the gray level in an image. A commonly used image enhancement method in the prior art is a histogram-based image enhancement method. The statistical distribution of the histogram indicates the number of gray levels in the image. By expanding the gray levels with a large number of pixels and compressing the gray levels with a small number of pixels, the contrast of the image can be enhanced, and the details of the image can be highlighted.
[0005] However, the existing histogram-based image enhancement method usually only sets a few parameters, and simply divides the entire gray scale interval into several gray scale intervals based on the set parameters to control the gray scale interval to be expanded or compressed. The adaptability is not high, and the enhancement effect is not good. SUMMARY
[0006] The technical problem to be solved by the present application is to provide an image enhancement method and terminal with high adaptability, which can automatically make the image clear and transparent, and has good enhancement effect.
[0007] To solve the above technical problems, a technical solution adopted by the present application is:
[0008] An image enhancement method, comprising the steps of:
[0009] S0, judging whether the image to be enhanced is a color image, if yes, converting the color image from RGB space to YUV space to obtain Y component and UV component;
[0010] If not, the image to be enhanced is a black and white image, then directly taking the value of each pixel point in the black and white image as the brightness to perform N-level histogram statistics;
[0011] S1, obtaining the brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information;
[0012] S2, determining a pixel quantity threshold corresponding to the brightness in the image to be enhanced according to the histogram, and one-to-one corresponding the pixel quantity threshold to a preset slope of image enhancement transformation, wherein the number of the pixel quantity thresholds is at least two;
[0013] S3, determining the slope corresponding to each segment representing the pixel quantity of each brightness in the image to be enhanced according to the slope and the corresponding pixel quantity threshold;
[0014] S4, determining an image transformation relationship according to the slope corresponding to each segment, and transforming the brightness of the image to be enhanced according to the image transformation relationship.
[0015] In order to solve the above technical problems, another technical solution adopted by the present application is:
[0016] An image enhancement terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the following steps when executing the computer program:
[0017] S0, judging whether the image to be enhanced is a color image, if yes, converting the color image from RGB space to YUV space to obtain Y component and UV component;
[0018] If not, the image to be enhanced is a black and white image, then directly taking the value of each pixel point in the black and white image as the brightness to perform N-level histogram statistics;
[0019] S1, obtaining the brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information;
[0020] S2, determining a pixel quantity threshold corresponding to the brightness in the image to be enhanced according to the histogram, and one-to-one corresponding the pixel quantity threshold to a preset slope of image enhancement transformation, wherein the number of the pixel quantity thresholds is at least two;
[0021] S3, determining the slope corresponding to each segment representing the pixel quantity of each brightness in the image to be enhanced according to the slope and the corresponding pixel quantity threshold;
[0022] S4, determining an image transformation relationship according to the slope corresponding to each segment, and transforming the brightness of the image to be enhanced according to the image transformation relationship.
[0023] The present application has the beneficial effect that the number threshold of pixels corresponding to brightness in the image to be enhanced is determined according to the histogram, and is one-to-one corresponding to the preset slope, the slope corresponding to each segment of the histogram is calculated according to the threshold and the preset slope, the transformation relationship of image enhancement is calculated according to the slope of each segment of the histogram, and the brightness of the image is transformed according to the transformation relationship, instead of simply and generally stretching and contracting the few gray interval directly based on the preset parameter, but determining the slope corresponding to each segment based on the number of segments of the histogram, then determining the transformation relationship of each segment according to the slope corresponding to each segment, and then obtaining the image after synchronous brightness enhancement of each segment, which is adaptive and has good enhancement effect, and achieves the purpose of enhancing the contrast image and highlighting the image details, which provides effective guarantee for subsequent observation, processing and recognition of the image; wherein, before step S1, it is judged whether the image to be enhanced is a color image, if yes, the spatial transformation from RGB to YUV is performed first to obtain the corresponding brightness information Y component, after the Y component is enhanced and transformed, the transformation from YUV space to RGB space is performed, which can conveniently realize the brightness enhancement transformation of the color image, if not, it is determined that the image to be enhanced is a black and white image, and the value of each pixel point is directly taken as the brightness for subsequent N-level histogram statistics. BRIEF DESCRIPTION OF DRAWINGS
[0024] Figure 1 The step flow chart of an image enhancement method of an embodiment of the present application is shown in the figure.
[0025] Figure 2 The structure schematic diagram of an image enhancement terminal of an embodiment of the present application is shown in the figure.
[0026] Figure 3 The linear interpolation fitting schematic diagram of the slope of each segment of the histogram of an embodiment of the present application is shown in the figure.
[0027] Label explanation:
[0028] 1, an image enhancement terminal; 2, a memory; 3, a processor. DETAILED DESCRIPTION
[0029] To explain the technical contents of the present application, the purposes and effects achieved, the following will be described in conjunction with the embodiments and the accompanying drawings. However, the present application can be implemented in many different forms, and the present application should not be interpreted as being limited to the specific embodiments set forth below. On the contrary, these embodiments are provided so that the present application will be comprehensive and complete, and to explain the principles of the present application and its practical applications, so that other skilled persons in the art can understand the principles and various embodiments of the present application.
[0030] The most critical idea of the present application is that a pixel quantity threshold corresponding to brightness in the image to be enhanced is determined according to a histogram, and the pixel quantity threshold is one-to-one corresponding to a preset slope, a slope corresponding to each segment in the histogram is calculated according to the threshold and the preset slope, a transformation relationship of image enhancement is calculated according to the slope of each segment in the histogram, and the brightness of the image is transformed according to the transformation relationship.
[0031] Please refer to Figure 1 An image enhancement method, comprising the steps of:
[0032] S0, judging whether the image to be enhanced is a color image, if yes, converting the color image from an RGB space to a YUV space to obtain Y and UV components;
[0033] If not, the image to be enhanced is a black and white image, and the values of each pixel point in the black and white image are directly taken as brightness for N-level histogram statistics;
[0034] S1, obtaining brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information;
[0035] S2, determining a pixel quantity threshold corresponding to brightness in the image to be enhanced according to the histogram, and one-to-one corresponding the pixel quantity threshold to a preset slope of image enhancement transformation, the number of the pixel quantity thresholds is at least two;
[0036] S3, determining a slope corresponding to each segment representing the number of each brightness pixel in the image to be enhanced in the histogram according to the slope and the corresponding pixel quantity threshold;
[0037] S4, determining an image transformation relationship according to the slope corresponding to each segment, and transforming the brightness of the image to be enhanced according to the image transformation relationship.
[0038] From the above description, the beneficial effects of the present application are that: according to the histogram, the pixel quantity threshold corresponding to the brightness in the image to be enhanced is determined, and it is one-to-one corresponding with the preset slope, the corresponding slope of each section in the histogram is calculated according to the threshold and the preset slope, the transformation relationship of image enhancement is calculated according to the slope of each section of the histogram, and the image brightness is transformed according to the transformation relationship, instead of simply and generally stretching and contracting the few gray interval based on the preset parameters, but determining the corresponding slope of each section based on the number of sections of the histogram, then determining the transformation relationship of each section according to the corresponding slope of each section, and then obtaining the image after synchronous brightness enhancement of each section, which is adaptive and has good enhancement effect, realizes the purpose of enhancing the contrast diagram and highlighting the image details, and provides effective guarantee for subsequent observation, processing and identification of the image; wherein, before step S1, it is judged whether the image to be enhanced is a color image, if yes, the space transformation from RGB to YUV is carried out first, the corresponding brightness information Y component is obtained, after the Y component is enhanced and transformed, the transformation from YUV space to RGB space is carried out, which can conveniently realize the brightness enhancement transformation of the color image, and if not, it is determined that the image to be enhanced is a black and white image, and the value of each pixel point is directly taken as the brightness for subsequent N-level histogram statistics.
[0039] Further, the step S2 comprises:
[0040] S21, determining the maximum pixel quantity and the average pixel quantity in each brightness of the image to be enhanced according to the histogram;
[0041] S22, determining the minimum pixel quantity according to the average pixel quantity;
[0042] S23, one-to-one corresponding the maximum pixel quantity and the minimum pixel quantity with the maximum slope and the minimum slope of the preset image enhancement transformation respectively, or one-to-one corresponding the maximum pixel quantity, the average pixel quantity and the minimum pixel quantity with the maximum slope, the slope 1 and the minimum slope of the preset image enhancement transformation respectively.
[0043] From the above description, according to the histogram, the maximum pixel quantity, the average pixel quantity and the minimum pixel quantity in each brightness of the image to be enhanced can be determined intuitively and simply, in the process of corresponding each pixel quantity with the slope, only the maximum and minimum pixel quantities can be selected to correspond with the maximum slope and the minimum slope respectively to simplify the calculation, or the average pixel quantity can be further increased to correspond with the slope 1, so that the calculation is more precise and the enhancement effect is further improved.
[0044] Further, the step S3 comprises:
[0045] The slope of each segment in the histogram is determined by linear interpolation or curve fitting method according to the slope and corresponding pixel number threshold and the pixel number represented by each segment in the histogram.
[0046] As can be seen from the above description, on the basis of a sufficient number of slopes and corresponding pixel number thresholds, the slope of each segment in the histogram can be determined conveniently and quickly by linear interpolation or curve fitting method according to the pixel number represented by each segment in the histogram.
[0047] Further, the step S4 comprises:
[0048] S41, calculating the transformation value of each segment according to the slope corresponding to each segment:
[0049] Yt i = Yt i-1 + k i × NInt, Yt0=0, i=1, 2, …, N
[0050] In the formula, Yt represents the transformed luminance value, N represents the total number of segments of the histogram, i represents the i-th segment of the histogram, k i represents the slope of the i-th segment of the histogram, and NInt represents the number of pixel gray scales contained in each segment of the histogram.
[0051] S42, performing normalization processing on Yt to obtain a normalized luminance table:
[0052] YLut i = Yt i × Y max / Yt N , i=1, 2, …, N
[0053] In the formula, YLut i represents the i-th element of the normalized luminance table, Y max represents the maximum value in Yt, Yt N represents the gray scale value of the last sampling point of Yt.
[0054] S43, transforming the luminance of the image to be enhanced according to the normalized luminance table:
[0055]
[0056] In the formula, m represents the serial number of the histogram segment where the pixel point Y ij is located, represents down rounding, and Ye represents the transformed luminance information.
[0057] From the above description, the slope corresponding to each segment in the histogram is calculated and normalized to obtain a normalized brightness table, and the brightness of the image to be enhanced is transformed according to a general formula, which has strong universality and avoids the situation that the image becomes very dark or very bright and overflows through normalization processing.
[0058] Further, the step S4 further includes:
[0059] S5, when the image to be enhanced is the color image, converting the color image from YUV space to RGB space according to the UV component and the transformed brightness information.
[0060] When the image to be enhanced is the black and white image, the enhanced image is the enhanced image.
[0061] Please refer to Figure 2 An image enhancement terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0062] S0, judging whether the image to be enhanced is a color image, if yes, converting the color image from RGB space to YUV space to obtain Y component and UV component;
[0063] If not, the image to be enhanced is a black and white image, and the value of each pixel point in the black and white image is directly taken as the brightness for N-level histogram statistics;
[0064] S1, obtaining the brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information;
[0065] S2, determining a pixel quantity threshold corresponding to the brightness in the image to be enhanced according to the histogram, and one-to-one corresponding the pixel quantity threshold to the slope of the preset image enhancement transformation, the number of the pixel quantity threshold is at least two;
[0066] S3, determining the slope corresponding to each segment representing the number of each brightness pixel in the image to be enhanced in the histogram according to the slope and the corresponding pixel quantity threshold;
[0067] S4, determining the image transformation relationship according to the slope corresponding to each segment, and transforming the brightness of the image to be enhanced according to the image transformation relationship.
[0068] From the above description, the beneficial effects of the present application are that: according to the histogram, the pixel quantity threshold corresponding to the brightness in the image to be enhanced is determined, and it is one-to-one corresponding with the preset slope, the corresponding slope of each section in the histogram is calculated according to the threshold and the preset slope, the transformation relationship of image enhancement is calculated according to the slope of each section of the histogram, and the image brightness is transformed according to the transformation relationship, instead of simply and generally stretching and contracting the few gray interval based on the preset parameters, but determining the corresponding slope of each section based on the number of sections of the histogram, then determining the transformation relationship of each section according to the corresponding slope of each section, and then obtaining the image after synchronous brightness enhancement of each section, which is adaptive and has good enhancement effect, realizes the purpose of enhancing the contrast diagram and highlighting the image details, and provides effective guarantee for subsequent observation, processing and identification of the image; wherein, before step S1, it is judged whether the image to be enhanced is a color image, if yes, the space transformation from RGB to YUV is carried out first, the corresponding brightness information Y component is obtained, after the Y component is enhanced and transformed, the transformation from YUV space to RGB space is carried out, which can conveniently realize the brightness enhancement transformation of the color image, and if not, it is determined that the image to be enhanced is a black and white image, and the value of each pixel point is directly taken as the brightness for subsequent N-level histogram statistics.
[0069] Further, the step S2 comprises:
[0070] S21, determining the maximum pixel quantity and the average pixel quantity in each brightness of the image to be enhanced according to the histogram;
[0071] S22, determining the minimum pixel quantity according to the average pixel quantity;
[0072] S23, one-to-one corresponding the maximum pixel quantity and the minimum pixel quantity with the maximum slope and the minimum slope of the preset image enhancement transformation respectively, or one-to-one corresponding the maximum pixel quantity, the average pixel quantity and the minimum pixel quantity with the maximum slope, the slope 1 and the minimum slope of the preset image enhancement transformation respectively.
[0073] From the above description, according to the histogram, the maximum pixel quantity, the average pixel quantity and the minimum pixel quantity in each brightness of the image to be enhanced can be determined intuitively and simply, in the process of corresponding each pixel quantity with the slope, only the maximum and minimum pixel quantities can be selected to correspond with the maximum slope and the minimum slope respectively to simplify the calculation, or the average pixel quantity can be further increased to correspond with the slope 1, so that the calculation is more precise and the enhancement effect is further improved.
[0074] Further, the step S3 comprises:
[0075] The slope of each segment in the histogram is determined by linear interpolation or curve fitting method according to the slope and corresponding pixel number threshold and the pixel number represented by each segment in the histogram.
[0076] As can be seen from the above description, on the basis of a sufficient number of slopes and corresponding pixel number thresholds, the slope of each segment in the histogram can be determined by linear interpolation or curve fitting method according to the pixel number represented by each segment in the histogram.
[0077] Further, the step S4 comprises:
[0078] S41, calculating a transformation value of each segment according to the slope corresponding to each segment:
[0079] Yt i = Yt i-1 + k i × NInt, Yt0=0, i=1, 2, …, N
[0080] In the formula, Yt represents the transformed luminance value, N represents the total number of segments of the histogram, i represents the i-th segment of the histogram, k i represents the slope of the i-th segment of the histogram, and NInt represents the number of pixel gray scales contained in each segment of the histogram.
[0081] S42, performing normalization processing on Yt to obtain a normalized luminance table:
[0082] YLut i = Yt i × Y max / Yt N , i=1, 2, …, N
[0083] In the formula, YLut i represents the i-th element of the normalized luminance table, Y max represents the maximum value in Yt, Yt N represents the gray scale value of the last sampling point of Yt.
[0084] S43, transforming the luminance of the image to be enhanced according to the normalized luminance table:
[0085]
[0086] In the formula, m represents the serial number of the segment of the histogram where the pixel point Y ij is located, represents down rounding, and Ye represents the transformed luminance information.
[0087] From the above description, the slope corresponding to each segment in the histogram is calculated and normalized to obtain the normalized brightness table, and the brightness of the image to be enhanced is transformed according to the general formula, which has strong universality, and the normalization processing avoids the situation that the image becomes very dark or very bright and overflows.
[0088] Further, the step S4 further includes:
[0089] S5, when the image to be enhanced is the color image, the color image is converted from the YUV space to the RGB space according to the UV component and the transformed brightness information.
[0090] When the image to be enhanced is the black and white image, the enhanced image is the enhanced image.
[0091] Embodiment one
[0092] Please refer to Figure 1 An image enhancement method, comprising the steps of:
[0093] S1, obtaining the brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information.
[0094] Specifically, before obtaining the brightness information of the image to be enhanced, it is first judged whether the image to be enhanced is a color image, if so, the color image is converted from the RGB space to the HUV space, for example, if a 16-bit color image is obtained, the conversion of the high-definition image standard can be used, and the specific 16-bit conversion formula is:
[0095]
[0096] In the formula, Y and UV represent 16-bit brightness components and 16-bit color components respectively, and R, G and B are red, green and blue components of the three primary color space respectively.
[0097] After the space conversion, the brightness component Y of the YUV can be subjected to 256-level brightness histogram statistics of all pixel points, that is, 16-bit Y is subjected to 256-level histogram Hist256 statistics, each segment occupies 256-level gray scale, that is, all pixels with a gray scale of 0-255 are counted into the first segment of the histogram, all pixels with a gray scale of 256-511 are counted into the second segment, and so on, until all pixels in Y are counted, and the size of each segment in the histogram represents the number of corresponding brightness pixels.
[0098] If not, that is, the image to be enhanced is a black and white image, the value of each pixel point in the black and white image is directly taken as the brightness for N-level brightness histogram statistics, and the specific number N can be set according to the actual situation.
[0099] S2, determining a pixel quantity threshold corresponding to brightness in the image to be enhanced according to the histogram, and corresponding the pixel quantity threshold to a preset slope of image enhancement transformation one by one, wherein the number of the pixel quantity threshold is at least two;
[0100] Specifically, comprising steps of:
[0101] S21, determining a maximum pixel quantity and an average pixel quantity in each brightness of the image to be enhanced according to the histogram;
[0102] The maximum value of the quantity of each segment in the N-level histogram can be calculated to obtain the maximum pixel quantity Hist max For the Hist256-level histogram, the formula is as follows:
[0103] Hist max = max{Hist256}
[0104] In the formula, Hist max represents the maximum value of the Hist256-level histogram, max represents the maximum operation, and Hist256 represents the size of each segment in the histogram;
[0105] Preferably, N is a power of 2, such as 64, 128 or 256, and N is 128 in the system. The number of segments of the histogram cannot be too small, otherwise the effect is not obvious, and too large resource consumption is too much;
[0106] The average pixel quantity can be obtained by accumulating all pixel quantities of the N-segment histogram and dividing by N, or by multiplying the width of the image by the length of the image and dividing by N. For the Hist256-level histogram, the formula is as follows:
[0107]
[0108] In the formula, Hist mean represents the average value of the Hist256-level histogram, and sum represents the summation operation;
[0109] S22, determining a minimum pixel quantity according to the average pixel quantity;
[0110] The 1 / M of the evaluation pixel quantity can be set as the minimum pixel quantity, and preferably, M is equal to 8. Thus, the following is obtained:
[0111] The maximum threshold Hmax = Hist max , the middle threshold Hmed = Hist mean , and the minimum threshold Hmin = Hist mean / 8;
[0112] S23, the maximum number of pixels and minimum number of pixels are respectively corresponding to the maximum slope and minimum slope of the preset image enhancement transformation or the maximum number of pixels, average number of pixels and minimum number of pixels are respectively corresponding to the maximum slope, slope 1 and minimum slope of the preset image enhancement transformation;
[0113] According to the actual application requirements, the maximum slope kmax and minimum slope kmin of the image enhancement transformation are set, and the maximum slope and minimum slope represent the intensity of image enhancement; the greater the maximum slope, the stronger the stretching of the pixel set with the most gray scale distribution in the image, and the smaller the minimum slope, the more obvious the compression degree of the pixel set with the least gray scale distribution in the image;
[0114] The maximum threshold can be directly corresponding to the maximum slope, and the minimum threshold can be corresponding to the minimum slope; in addition, in order to further improve the accuracy of subsequent enhancement, an intermediate slope 1 can be added, and it is corresponding to the intermediate threshold;
[0115] S3, according to the slope and the corresponding pixel number threshold, the slope corresponding to each segment representing the number of pixels of each brightness of the image to be enhanced in the histogram is determined;
[0116] Specifically, according to the slope and the corresponding pixel number threshold and the pixel number represented by each segment in the histogram, the slope of each segment in the histogram is determined by linear interpolation or curve fitting method, Figure 3 It is shown that the slope of each segment in the histogram is determined by linear interpolation method, Figure 3 It can be seen that the result of the slope calculation of each segment of the histogram is between kmin and kmax, wherein, preferably, kmax=2, kmin=0.5;
[0117] S4, according to the slope corresponding to each segment, the image transformation relationship is determined, and the brightness of the image to be enhanced is transformed according to the image transformation relationship;
[0118] Specifically, it includes the following steps:
[0119] S41, according to the slope corresponding to each segment, the transformation value of each segment is calculated:
[0120] Yt i = Yt i-1 + k i × NInt, Yt0=0, i=1,2,…,N
[0121] In the formula, Yt represents the transformed brightness value, N represents the total number of segments of the histogram, i represents the i-th segment of the histogram, k iNInt represents the number of pixel gray levels contained in each segment of the histogram, for example, for a 16-bit Y statistic 256-level histogram Hist256, each segment occupies 256 gray levels, then NInt is 256;
[0122] S42, Yt is normalized to obtain a normalized brightness table:
[0123] YLut i = Yt i × Y max / Yt N , i = 1, 2, …, N
[0124] In the formula, YLut i represents the i-th element of the normalized brightness table, Y max represents the maximum value in Yt, Yt N represents the gray value of the last sampling point of Yt;
[0125] Divided by Yt N Because Yt is monotonic, but its maximum value may not be the saturation value, for example, Yt is 8-bit, but if the maximum value of Yt may be any value less than or greater than 255, if not normalized, the image brightness will change, that is, dark or bright;
[0126] For example, if Yt N is 124 after transformation, then it needs to be normalized by multiplying 255 / 124 to ensure that the overall brightness of the image will not be dark; if Yt N is 335 after transformation, then it needs to be multiplied by 255 / 335, otherwise a large part of the content will be greater than 255 after transformation, causing the image to overflow, and the overall brightness will be bright;
[0127] S43, transforming the brightness of the image to be enhanced according to the normalized brightness table:
[0128]
[0129] In the formula, m represents the serial number of the histogram segment where the pixel Y ij is located, represents the floor function, and Ye represents the transformed brightness information; the above transformation formula has covered different cases: if each pixel is a segment in histogram segmentation, for example, an 8-bit brightness image, a 256-segment histogram is counted, then the enhanced brightness information can be obtained by directly looking up the table, or Ye ij = YLut mIf the image histogram contains more than one gray level, for example, a 16-bit luminance image, the 256 segments of the histogram are calculated, i.e., each segment contains 8 gray levels, and the final adaptive enhanced image is calculated by piecewise linear interpolation, i.e., the corresponding pixel value is substituted into the above transformation formula, assuming Y ij In the 8th segment of the 256 segments, the linear interpolation formula can be expressed as:
[0130]
[0131] If the image to be enhanced is a black and white image, the enhanced image is the enhanced image; if the image to be enhanced is a color image, the enhanced luminance image and the color image need to be converted from the light color separation space to the color space, specifically:
[0132] According to the UV component and the transformed luminance information, the color image is converted from the YUV space to the RGB space, and the conversion formula is:
[0133]
[0134] In the formula, Ye is the enhanced luminance component, R, G and B are the red, green and blue components of the enhanced color image, respectively;
[0135] The histogram N in the embodiment of the application is not limited to 256, but is set according to the actual needs of system application; the maximum threshold, the intermediate threshold and the minimum threshold can also be calculated in other ways, such as percentage; the maximum and minimum slopes are set according to system requirements, and of course can be adjusted adaptively according to application.
[0136] Embodiment two
[0137] Please refer to Figure 2 An image enhancement terminal 1, comprising a memory 2, a processor 3 and a computer program stored on the memory 2 and executable on the processor 3, wherein the processor 3 implements each step of the embodiment one when executing the computer program.
[0138] In summary, the image enhancement method and terminal provided by the application determine the pixel quantity threshold corresponding to the brightness in the image to be enhanced according to the histogram, and make the threshold correspond to the preset slope one by one, calculate the slope corresponding to each section of the histogram according to the threshold and the preset slope, calculate the transformation relationship of the image enhancement according to the slope of each section of the histogram, and transform the brightness of the image according to the transformation relationship, instead of simply and generally stretching and contracting the few gray scale intervals directly based on the preset parameters, but determining the slope corresponding to each section based on the section number of the histogram, then determining the transformation relationship of each section according to the slope corresponding to each section, and then obtaining the image after the synchronous brightness enhancement of each section, which is adaptive and has good enhancement effect, achieves the purpose of enhancing the contrast image and highlighting the image details, and provides effective guarantee for the subsequent observation, processing and identification of the image.
[0139] The above description is only an embodiment of the application, and does not limit the patent scope of the application, and any equivalent transformation or direct or indirect application in the related technical field based on the content of the specification and drawings of the application is also included in the patent protection scope of the application.
Claims
1. An image enhancement method characterized by, The method comprises the steps of: S0, judging whether the image to be enhanced is a color image, if yes, converting the color image from RGB space to YUV space to obtain Y component and UV component; if not, the image to be enhanced is a black and white image, then directly taking the value of each pixel point in the black and white image as brightness to perform N-level histogram statistics; S1, obtaining brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information; S2, determining a pixel quantity threshold corresponding to brightness in the image to be enhanced according to the histogram, and one-to-one corresponding the pixel quantity threshold to a preset slope of image enhancement transformation, wherein the number of the pixel quantity threshold is at least two; S3, determining a slope corresponding to each segment representing the quantity of each brightness pixel in the image to be enhanced according to the slope and the corresponding pixel quantity threshold; S4, determining an image transformation relationship according to the slope corresponding to each segment, and transforming the brightness of the image to be enhanced according to the image transformation relationship; The step S4 comprises: S41, calculating a transformation value of each segment according to the slope corresponding to each segment; In the formula, Yt represents the transformed luminance value, N represents the total number of segments of the histogram, i represents the i-th segment of the histogram, represents the slope of the i-th segment of the histogram, and Nint represents the number of pixel gray scales contained in each segment of the histogram. S42, performing normalization processing on Yt to obtain a normalized brightness table; wherein denotes the i-th element of the normalized luminance table, denotes the maximum value in Yt, YtNdenotes the gray value of the last sample point of Yt; S43, transforming the brightness of the image to be enhanced according to the normalized brightness table; In the formula, m represents a pixel point the serial number of the histogram section in which the pixel point is located, represents a down-rounding, and Ye represents the luminance information after the transformation.
2. The image enhancement method of claim 1, wherein, The step S2 comprises: S21, determining the maximum pixel quantity and the average pixel quantity in each brightness of the image to be enhanced according to the histogram; S22, determining the minimum pixel quantity according to the average pixel quantity; S23, one-to-one corresponding the maximum pixel quantity and the minimum pixel quantity to the maximum slope and the minimum slope of the preset image enhancement transformation, or one-to-one corresponding the maximum pixel quantity, the average pixel quantity and the minimum pixel quantity to the maximum slope, the slope 1 and the minimum slope of the preset image enhancement transformation.
3. The image enhancement method of claim 1 or 2, wherein, The step S3 comprises: determining the slope of each segment in the histogram by linear interpolation or curve fitting method according to the slope and the corresponding pixel quantity threshold and the pixel quantity represented by each segment in the histogram.
4. The image enhancement method of claim 1 or 2, wherein, The step S4 further comprises: S5, when the image to be enhanced is the color image, converting the color image from YUV space to RGB space according to the UV component and the transformed brightness information; when the image to be enhanced is the black and white image, then the enhanced image is the enhanced image.
5. An image enhancement terminal comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the following steps: S0, judging whether the image to be enhanced is a color image, if yes, converting the color image from RGB space to YUV space to obtain Y component and UV component; if not, the image to be enhanced is a black and white image, then directly taking the value of each pixel point in the black and white image as brightness to perform N-level histogram statistics; S1, obtaining brightness information of the image to be enhanced, and generating a corresponding histogram according to the brightness information; S2, determining a pixel quantity threshold corresponding to brightness in the image to be enhanced according to the histogram, and corresponding the pixel quantity threshold to a preset slope of image enhancement transformation one by one, wherein the number of the pixel quantity threshold is at least two; S3, determining the slope corresponding to each segment representing the pixel quantity of each brightness in the image to be enhanced according to the slope and the corresponding pixel quantity threshold; S4, determining the image transformation relationship according to the slope corresponding to each segment, and transforming the brightness of the image to be enhanced according to the image transformation relationship; The step S4 comprises: S41, calculating the transformation value of each segment according to the slope corresponding to each segment: In the formula, Yt represents the transformed luminance value, N represents the total number of segments of the histogram, i represents the i-th segment of the histogram, represents the slope of the i-th segment of the histogram, and Nint represents the number of pixel gray scales contained in each segment of the histogram. S42, obtaining the normalized brightness table by normalizing Yt: wherein denotes the i-th element of the normalized luminance table, denotes the maximum value in Yt, YtNdenotes the gray value of the last sample point of Yt; S43, transforming the brightness of the image to be enhanced according to the normalized brightness table: In the formula, m represents a pixel point the serial number of the histogram section in which the pixel point represents rounding down, and Ye represents the luminance information after the transformation.
6. An image enhancement terminal according to claim 5, characterized in that The step S2 comprises: S21, determining the maximum pixel quantity and the average pixel quantity in each brightness of the image to be enhanced according to the histogram; S22, determining the minimum pixel quantity according to the average pixel quantity; S23, corresponding the maximum pixel quantity and the minimum pixel quantity to the maximum slope and the minimum slope of the preset image enhancement transformation one by one, or corresponding the maximum pixel quantity, the average pixel quantity and the minimum pixel quantity to the maximum slope, the slope 1 and the minimum slope of the preset image enhancement transformation one by one.
7. An image enhancement terminal according to claim 5 or 6, characterised in that, The step S3 comprises: Determining the slope of each segment in the histogram by linear interpolation or curve fitting method according to the slope and the corresponding pixel quantity threshold and the pixel quantity represented by each segment in the histogram.
8. The image enhancement terminal of claim 5 or 6, wherein, The step S4 further comprises: S5, when the image to be enhanced is the color image, converting the color image from YUV space to RGB space according to the UV component and the transformed brightness information; When the image to be enhanced is the black and white image, the enhanced image is the enhanced image.
Citation Information
Patent Citations
Video image processing method
CN101360182A
Dynamic contrast enhancement device and method
CN102231264A