This application claims priority of No. 097134971 filed in Taiwan R.O.C. on Sep. 12, 2008 under 35 USC 119, the entire content of which is hereby incorporated by reference.
1. Field of Invention
The present invention relates to the image processing technology, and more particularly to an image enhancement method using the local gain correction.
2. Related Art
Recently, the progress of the technology makes the types of multimedia become more and more diversified. As for the digital video, such as a digital photo, a digital display, a digital film or the digital video broadcasting technology, the image enhancement technology is greatly emphasized. The image processing is to make various changes of the image frames on the color, the brightness, the focal length and the like of the obtained digital image according to the functions provided by the image processing operation technology, or even to synthesize two photos through the more complicated operation procedures. For example, it is possible to quickly transform a sunshiny photo into a rainy photo according to some functions of image processing (e.g., the functions of changing of the brightness and the contrast). Alternatively, it is possible to stealthily substitute one thing for another according to two photos by way of the image processing procedures of selecting, cutting and pasting. Thus, the original look of the image may be changed. Therefore, the image processing is to change or analyze the data on the image.
As for the image processing, which needs to distinguish between the brightness of different images, the brightness distribution of the image is often used for the analysis.
In step S101, the method starts.
In step S102, an input frame is acquired.
In step S103, a brightness histogram of the input frame is detected.
In step S104, a curve function is obtained according to the brightness histogram.
In step S105, the pixels of the input frame are substituted into the curve function to achieve the effect of enhancing the contrast ratio or the dynamic range of the image.
In step S106, the method ends.
In addition, in order to solve the above-mentioned problems, methods of enhancing the image using algorithms have been proposed. For example, the methods disclosed in [1] and [2] have to transform the image from the spatial domain to the frequency domain by way of, for example, Fast Fourier Transform (FFT) or Discrete Cosine Transform (DCT). Although the method can obtain the image with the better dynamic range, the operation needs the greater calculation load. If the method is implemented in the product, the layout area of the integrated circuit is inevitably increased. In addition, the power consumption is also increased with the increase of the calculation load.
[1] Lee, Sangkeun; Ha, Hyeong-Seok V.; Kim, Yeong-Hwa “Dynamic range compression and contrast enhancement for digital images in the compressed domain” Optical Engineering, Publication Date: February 2006, On page(s): 1-14 Vol. 45.
[2] Hau Ngo; Li Tao; Vijayan Asari “Design of an Efficient Architecture for Real-time Image Enhancement Based on a Luma-Dependent Nonlinear Approach” ITCC 2004. International Conference on Publication Date: April 2004, On page(s): 656-660 Vol. 1.
It is therefore an objective of the present invention to provide an image enhancement method for enhancing an image using the local gain correction.
Another objective of the present invention is to provide an image enhancement method for adaptively enhancing an image so that the enhanced image is still clear even if the brightness difference of the image is extremely great.
Still another objective of the present invention is to provide an image enhancement method for adaptively enhancing an image with the reduced calculation load.
To achieve the above-identified or other objectives, the present invention provides an image enhancement method. The method includes the steps of: replacing a value of a pixel of a digital image with luminance (combination of R, G, and B pixels) of the pixel; selecting a specific pixel from the pixels of the digital image; selecting some of the pixels surrounding the specific pixel to constitute a specific block; calculating an average of values of the pixels of the specific block; providing multiple curve functions; obtaining a corresponding one of the curve functions according to the average of the specific block, and substituting the values of the R, G, and B pixels of the image into the curve functions to obtain new output R, G, and B values.
In the image enhancement method according to the preferred embodiment of the present invention, the step of providing the curve functions includes providing a plurality of curve look-up-tables to represent the curve functions. In one embodiment, the method further includes the step of substituting a pixel value of the specific pixel into the specific curve function to obtain a corrected pixel value. In one embodiment, the method further includes the steps of: providing a curve index image; and recording a curve index of the specific curve function in the curve index image, wherein positions of pixels of the curve index image are the same as positions of the pixels of the digital image, and the curve index of the specific curve function is recorded at a corresponding position corresponding to the specific pixel. In one embodiment, the method further includes the step of eliminating the specific pixel, wherein the above-mentioned steps are repeated until all of the pixels have been extracted to fill the positions of the pixels of the curve index image. In one embodiment, the method further includes the step of substituting each of the pixels of the digital image into a corresponding one of the curve functions according to the curve index stored in the curve index image to obtain a corrected digital image.
In the image enhancement method according to the preferred embodiment of the present invention, the digital image includes M×N pixels, and the curve index image includes corresponding M×N pixels, and the step of substituting each of the pixels of the digital image into the corresponding one of the curve functions according to the curve index stored in the curve index image to obtain the corrected digital image includes the sub-steps of: (a) finding the corresponding curve function from the (i, j)th curve index of the curve index image; (b) substituting the (i, j)th pixel of the digital image into the curve function corresponding to the (i, j)th curve index of the curve index image to obtain the (i, j)th pixel of the corrected digital image; and (c) eliminating the extracted pixel, wherein the sub-steps (a) to (c) are repeated until all the pixels have been extracted, wherein M, N, i and j are natural numbers, 0<=i<=M−1, and 0<=j<=N−1.
The present invention further provides an image enhancement method. The method includes the steps of: replacing a value of a pixel of a digital image with luminance (combination of R, G, and B pixels) of the pixel; dividing the pixels of the digital image into multiple specific blocks; calculating an average of values of the pixels of the specific block; providing multiple curve functions; obtaining a corresponding one of the curve functions according to the average of the specific block, and substituting the value of the R, G, and B pixels of the image into the curve functions to obtain new output R, G, and B values.
In the image enhancement method according to the preferred embodiment of the present invention, the step of providing the curve functions includes providing a plurality of curve look-up-tables to represent the curve functions. In one embodiment, the method further includes the step of: obtaining the corresponding curve function according to the average of the specific block and substituting the value of the pixel into the curve functions to obtain new output brightness values. In one embodiment, the method further includes the step of recording a curve index of the specific curve function in the curve index image, wherein positions of the pixels of the curve index image are the same as positions of the blocks of the digital image. In one embodiment, the method further includes eliminating the specific block, wherein the above-mentioned steps are repeated until all of the blocks have been extracted to fill the positions of the pixels of the curve index image. In one embodiment, the method further includes the step of substituting each of the pixels of the digital image into a corresponding one of the curve functions according to the curve index stored in the curve index image to obtain a corrected digital image.
In the image enhancement method according to the preferred embodiment of the present invention, the digital image includes M×N blocks, and the curve index image includes corresponding M×N pixels. The step of substituting each of the pixels of the digital image into the corresponding one of the curve functions according to the curve index stored in the curve index image to obtain the corrected digital image includes the sub-steps of: (a) upscaling the curve index image to obtain a corrected curve index image, wherein the number of pixels of the corrected curve index image is the same as the number of pixels of the digital image; (b) finding a corresponding one of the curve functions from the (i, j)th curve index of the corrected curve index image; (c) substituting the (i, j)th pixel of the digital image into the curve function corresponding to the (i, j)th curve index of the corrected curve index image to obtain the (i, j)th pixel of the corrected digital image; and (d) eliminating the extracted pixel, wherein the sub-steps (b) to (d) are repeated until all the pixels have been extracted, wherein M, N, i and j are natural numbers, 0<=i<=M−1, and 0<=j<=N−1.
The spirit of the present invention is to find out the preferred curve function corresponding to the corrected unit in a manner of analyzing the brightness of the block brightness. Thus, even if the image has the extremely great brightness difference, the enhanced image still may be clear. In addition, the present invention has the following advantages. First, only the simple calculation is needed because the simple operations of addition, subtraction, multiplication and division are needed. Second, the smaller memory is needed because it is unnecessary to store reference images in advance.
Further scope of the applicability of the present invention will become apparent from the detailed description given hereinafter. However, it should be understood that the detailed description and specific examples, while indicating preferred embodiments of the invention, are given by way of illustration only, since various changes and modifications within the spirit and scope of the invention will become apparent to those skilled in the art from this detailed description.
The present invention will become more fully understood from the detailed description given hereinbelow and the accompanying drawings which are given by way of illustration only, and thus are not limitative of the present invention.
The present invention will be apparent from the following detailed description, which proceeds with reference to the accompanying drawings, wherein the same references relate to the same elements.
In step S301, the method starts.
In step S302, a digital image is acquired, wherein the digital image has many pixels P(1, 1) to P(M, N), wherein M and N are respectively the total number of horizontal pixels and the total number of vertical pixels. In this embodiment, each pixel has three sub-pixels, which are respectively red R, green G and blue B sub-pixels. In order to enhance the effect using the method of this embodiment of the present invention applied to the image processing, the luminance (combination of R, G, and B pixels) of the pixel represents the pixel value of each pixel.
In step S304, multiple curve functions are provided.
In step S305, a specific pixel P(i, j) is selected from the pixels of the digital image, wherein P(i, j) represents the pixel located at the ith column and the jth row.
In step S306, multiple pixels surrounding the specific pixel are selected to constitute a specific block.
In step S307, an average AV of values of the pixels of the specific block is calculated. The sum of the pixel values of the pixels of the block is divided by the number of pixels to obtain the average of the block. In this embodiment, the luminance (combination of R, G, and B pixels) of the pixel serves as the pixel value.
In step S308, multiple output brightness values are obtained by substituting the average AV of the specific block into the curve functions. In step S309, a specific output brightness value closest to a specific brightness value is found from the output brightness values so that a specific curve function corresponding to the specific output brightness value is found. Herein, it is possible to set the brightness value, which may be comfortably felt by the human eyes, as the specific brightness value. Next, the brightness values obtained in the step S308 are respectively compared with the specific brightness value so that the output brightness value closest to the specific brightness value can be found. Then, the corresponding curve function can be found according to the output brightness value closest to the specific brightness value. Because the pixels surrounding the specific pixel P(i, j) usually closely relate to the specific pixel P(i, j), the found curve function may be regarded as the preferred curve function corresponding to the specific pixel P(i, j).
In step S310, the curve index of the specific curve function is recorded in the curve image, wherein the curve index of the specific curve function is recorded at the position corresponding to the specific pixel.
In step S311, it is judged whether there is a pixel, which has not been extracted. If the judgement is yes, the extracted pixel, such as the specific pixel P(i, j), is eliminated. The steps S302 to S310 are repeated until all the pixels P(1, 1) to P(M, N) have been extracted to fill the positions of the pixels of the curve index image. If all the pixels have been extracted, step S312 is performed.
In the step S312, a spatial filter operation is performed on the curve index image. If the curve index image is directly used to compensate the digital image, the textures of the image may disappear. Thus, the spatial Filter operation has to be performed on the curve index image. Generally speaking, the spatial operation is a low-pass operation. In the technological field of image processing, the spatial filter operation may be performed in many ways, and detailed description thereof will be omitted.
In step S313, each pixel of the digital image is substituted into the corresponding curve function according to the curve index stored in the curve index image to obtain a corrected digital image.
In addition,
In step S314, the method ends.
The step S313 may be simply divided into several sub-steps.
In sub-step S801, a curve function corresponding to the (i, j)th curve index, hereinafter referred to as γ(i, j), is found from the curve index image.
In sub-step S802, the (i, j)th pixel P(i, j) of the digital image is substituted into the curve function corresponding to the (i, j)th curve index γ(i, j) of the curve index image to obtain the (i, j)th pixel of the corrected digital image.
In sub-step S803, it is judged whether all the pixels of the digital image have been extracted. If not, the procedure goes back to the sub-step S801 until all the pixels have been extracted so that the corrected digital image can be obtained.
In the above-mentioned embodiment, the image enhancement is performed by firstly constituting the curve index image and then performing the compensation. However, one of ordinary skill in the art may understand that the specific pixel P(i, j) may be substituted into the corresponding specific curve function after the specific curve function corresponding to the specific pixel P(i, j) is obtained in the step S308. Thus, the present invention is not limited to the step. In addition, one of ordinary skill in the art may understand that the spatial filter operation is not the essential step, and may be optional according to the requirement on the image quality of the product or the operation speed. So, the present invention is not limited thereto.
It is to be noted that the method for performing the image enhancement operation uses the pixel as the unit in the above-mentioned embodiment. However, one of ordinary skill in the art may understand that the image enhancement operation may be performed using the block as the unit according to the same rule. Thus, the present invention is not restricted to this possible aspect. Next, another embodiment, in which the image enhancement operation is performed using the block as the unit, will be illustrated so that one of ordinary skill in the art may implement the present invention according to the spirit of the present invention.
In step S901, the method starts.
In step S902, a digital image is acquired.
In step S903, the digital image is divided into a plurality of blocks.
In step S905, a plurality of curve functions is provided. Similarly, the curve functions shown in
In step S906, a specific block is selected from the blocks of the digital image.
In step S907, an average AV of values of the pixels of the specific block is calculated. Similarly, the average is calculated by dividing the sum of the pixel values of the pixels by the number of pixels in this block. Herein, the pixel value is defined by the luminance (combination of R, G, and B pixels) of the pixel.
In step S908, the average of the specific block is substituted into the curve functions provided by the step S905 so that a plurality of output brightness values is obtained.
In step S909, a specific output brightness value closest to a specific brightness value is found from the output brightness values so that a specific curve function corresponding to the specific output brightness value can be found. Similarly, it is possible to set the brightness value, which may be comfortably felt by the human eyes, as the specific brightness value. Next, the brightness values obtained in the step S908 are respectively compared with the specific brightness value so that the output brightness value closest to the specific brightness value can be found. Then, the corresponding curve function can be found according to the output brightness value closest to the specific brightness value.
In step S910, the curve index of the specific curve function is recorded in the curve index image, wherein the curve index of the specific curve function is recorded at the corresponding position corresponding to the specific block.
In step S911, it is judged whether there is a block that has not been extracted. If yes, the extracted block is eliminated, and the above-mentioned steps S906 to S910 are repeated until all the blocks have been extracted to fill the positions of the pixels of the curve index image. If all the pixels have been extracted, step S912 is performed.
In the step S912, a spatial filter operation is performed on the curve index image. Similarly, if the curve index image is directly used to compensate the digital image, the textures of the image may disappear. Thus, the spatial filter operation has to be performed on the curve index image. Generally speaking, the spatial operation is a low-pass operation. In the technological field of image processing, the spatial filter operation may be performed in many ways, and detailed description thereof will be omitted.
In step S913: each pixel of the digital image is substituted into the corresponding curve function according to the curve index stored in the curve index image to obtain a corrected digital image.
In step S914, the method ends.
The different between this embodiment and the embodiment of
Referring again to
In sub-step S1201, the curve index image is upscaled to obtain a corrected curve index image, wherein the number of pixels of the corrected curve index image is the same as the number of pixels of the digital image. Generally speaking, this upscaling method is to obtain the pixel, which is not originally obtained, by way of interpolation.
In sub-step S1202, the corresponding curve function is found from the (i, j)th curve index of the corrected curve index image, hereinafter referred to as γ2 (i, j) (γ2 is the upscaled curve index image).
In sub-step S1203, the (i, j)th pixel of the digital image is substituted into the curve function corresponding to the (i, j)th curve index γ2 (i, j) of the corrected curve index image to obtain the (i, j)th block of the corrected digital image.
In sub-step S1204, it is judged whether all the pixels of the digital image have been extracted. If not, the procedure goes back to the sub-step S1202 until all the pixels have been extracted so that the corrected digital image can be obtained.
In the above-mentioned embodiments, the luminance (combination of R, G, and B pixels) of the pixels serves as the pixel value. However, one of ordinary skill in the art may understand that the determination of the pixel value is not limited thereto. Instead, the average of the pixel values of the red, green and blue sub-pixels or the maximum of the pixel values of the red, green and blue sub-pixels may serve as the pixel value, or the image may be directly divided into red, green and blue images, which are respectively processed using the above-mentioned steps of the methods. The methods mentioned hereinabove only pertain to the design choices to one of ordinary skill in the art, so detailed descriptions thereof will be omitted.
In summary, the spirit of the present invention is to find out the preferred curve function corresponding to the corrected unit in a manner of analyzing the brightness of the block brightness. Thus, even if the image has the extremely great brightness difference, the enhanced image still may be clear. In addition, the present invention has the following advantages. First, only the simple calculation is needed because the simple operations of addition, subtraction, multiplication and division are needed. Second, the smaller memory is needed because it is unnecessary to store reference images in advance.
While the invention has been described by way of examples and in terms of preferred embodiments, it is to be understood that the invention is not limited thereto. To the contrary, it is intended to cover various modifications. Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications.
Number | Date | Country | Kind |
---|---|---|---|
097134971 | Sep 2008 | TW | national |