A FPGA method and system for realizing color image enhancement
By using adaptive limited histogram equalization and threshold-protected gamma transform in the HSI color space, combined with guided filter combination detail enhancement, the color cast and noise amplification in ultra-high-definition color image processing are solved, achieving resource saving and flexibility. deal with.
Patent Information
- Application Number
- CN202210228483.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2024-10-29
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN114663319B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of ultra-high definition color image enhancement processing, and specifically relates to an FPGA method and system for realizing color image enhancement. Background Art
[0002] As image resolution is upgraded from high-definition resolution (1920*1080) to ultra-high-definition resolution (3840*2160), the real-time processing enhancement effect of ultra-high-definition images is limited by the performance of serial-architecture general-purpose processors. The present invention adopts a parallel-architecture FPGA as the core processor.
[0003] Color images are enhanced by processing the three color channels R, G and B. However, the three color channels R, G and B are not independent of each other. Processing the three color channels R, G and B separately will cause color cast and pseudo color problems. The present invention performs image enhancement adjustment on the brightness channel I and the saturation channel S respectively in the HSI color space where the color channels are independent of each other.
[0004] In terms of image contrast enhancement, traditional enhancement methods use transformation algorithms based on nonlinear functions, adjustment algorithms based on histograms, or Retinex image enhancement algorithms based on color constancy theory. For transformation algorithms based on nonlinear functions, the nonlinear function cannot be uniquely determined. For the Retinex image enhancement algorithm based on color constancy theory, the hardware structure needs to cache multiple lines of ultra-high-definition image data, which consumes thousands of Kb of on-chip resources on the FPGA. For traditional global histogram adjustment, over-enhancement will occur when adjusting images with large local contrast. Based on the above problems, the present invention uses adaptive restricted histogram equalization to achieve image contrast enhancement.
[0005] In terms of image saturation enhancement, saturation enhancement can be achieved by using a convex function such as gamma transform as a mapping function to process the saturation component S. However, in actual scenes, white light and dark areas are both low-saturation areas, and are areas where saturation should not be adjusted. The gamma transform function is modified by increasing the threshold parameter T to adjust the threshold of the low-saturation protection area. The parameter z adjusts the degree of overall saturation enhancement. For the gamma transform of a specific parameter z, FPGA can use a lookup table to implement the gamma transform mapping function, but for gamma transforms of multiple parameters z, using a lookup table wastes a lot of resources. The present invention uses a logarithmic function and an exponential function with a base of 2 to implement the gamma transform of any threshold parameter T and any parameter z through multiplication and shift operations, which can save logic resources.
[0006] In terms of image detail enhancement, traditional detail enhancement methods use Sobel operators and Laplacian operators to perform differential sharpening on images. Differential sharpening methods will also amplify image noise when enhancing details. The present invention uses guided filtering as a low-pass filter to perform low-pass filtering on the image to obtain the basic layer of the image; uses the basic layer of the original image to perform subtraction operations through the unsharp mask module to obtain the detail layer of the image; and fuses the basic layer of the image and the detail layer of the image to achieve image detail enhancement. The noise problem in the detail enhancement process can be effectively reduced. Summary of the invention
[0007] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide an FPGA method and system for realizing color image enhancement.
[0008] In order to achieve the above object, the present invention adopts the following technical solutions:
[0009] One aspect of the present invention provides an FPGA method for implementing color image enhancement, comprising the following steps:
[0010] Extract the brightness I, saturation S, and chroma H of the color image to be processed;
[0011] Performing contrast enhancement based on adaptive restricted histogram equalization in the brightness I channel, wherein the adaptive restricted histogram equalization includes adaptive restricted histogram statistics and histogram equalization;
[0012] Saturation enhancement based on threshold-protected gamma transform is performed in the saturation S channel;
[0013] Based on the effect of contrast enhancement, detail enhancement is performed based on the combination of unsharp masking and guided filtering;
[0014] Keeping the chromaticity H unchanged, the enhanced color image is obtained.
[0015] As a preferred technical solution, the adaptive restricted histogram statistics specifically includes the following steps:
[0016] Divide the brightness I channel of the color image to be processed into M*N equal parts of small area images;
[0017] Calculate the histogram statistics of M*N area images, and store the M*N histogram statistics in the on-chip RAM inside the FPGA;
[0018] Crop the histogram statistics of M*N regional images: Set the histogram amplitude limit value Limit, compare the calculated histogram statistics of M*N regional images with Limit, crop the part of the histogram statistics that is greater than the Limit value, and divide it equally into the entire histogram range;
[0019] Further trimming the trimmed result so that the maximum value of the trimmed histogram statistical result is not greater than Limit; updating the final trimmed histogram statistical result to the on-chip RAM inside the FPGA;
[0020] Outputting the accumulated histogram statistics: after the M*N cropped histogram statistics are completed, before the next frame of image arrives, the M*N cropped histogram statistics are accumulated and updated to the accumulated histogram statistics of the histogram equalization part, using the on-chip RAM inside another FPGA;
[0021] Clear the on-chip RAM values in the M*N FPGAs in the adaptive limit histogram statistics part.
[0022] As a preferred technical solution, the histogram equalization specifically includes the following steps:
[0023] Receiving the accumulated histogram statistics results of the M*N regional images of the adaptive restricted histogram statistics part;
[0024] According to the size of the current image pixel value, the final balanced value is mapped by accumulating the histogram statistics; according to the balanced values mapped by the adjacent 4 area images, the corresponding interpolation algorithm is selected to calculate the final balanced value.
[0025] As a preferred technical solution, the saturation enhancement based on threshold-protected gamma transform in the saturation S channel is specifically as follows:
[0026] As follows:
[0027]
[0028] Where S(i,j) is the information of the saturation channel S, T is the protection threshold of saturation adjustment, z is the degree of enhancement of the overall saturation, S(i,j) enhanced is the data after saturation enhancement, S(i,j), T,z, S(i,j) enhanced The value range of is [0,1];
[0029] By using the fixed-point method, S(i,j) and T are expanded by 2 N Multiples, the enhancement formula is as follows:
[0030]
[0031] S, T, S after fixed point processing enhanced The value range is [0,2 N ];
[0032] in, In FPGA, it is decomposed into a logarithmic function and an exponential function with base 2. The decomposition formula is as follows:
[0033]
[0034] Calculate the saturation-adjusted S by multiplication, addition, subtraction, and shift operations enhanced .
[0035] As a preferred technical solution, the detail enhancement based on the combination of unsharp masking and guided filtering on the contrast enhancement effect is specifically as follows:
[0036] The result based on adaptive restricted histogram equalization is used as the detail enhanced input image p, and a guided filtering operation is performed on the input image p to obtain a guided filtering coefficient a within any square window size. k
[0037] and b k , guided filter coefficient a k and b k The calculation formula is as follows:
[0038]
[0039] in, is the input image data in window W k The mean of It is the square of the input image data in the window W k The mean of is the input image data in window W k The variance of k and b k Is the guided filter module in the window W k The calculated coefficient; ε is the threshold for defining the smooth area and edge area of the image, which is a regularization parameter;
[0040] Calculate each window W k All guided filter coefficients a within k and b k The weighted mean ave_a k and ave_b k , and use the weighted mean guided filter coefficient to calculate the guided filter image basic layer q, for each pixel data:
[0041] q i =ave_a k *p i +ave_b k ,i∈W k
[0042] where pi W is in the window k The center pixel of the input image, q i W is in the window k The original image data of the central pixel point is output by the guided filtering module, and the output data is the basic layer q of the image;
[0043] Unsharp masking, subtracting the image after contrast enhancement based on adaptive restricted histogram equalization from the basic layer q of the image to obtain the detail layer d of the image;
[0044] Image fusion uses the detail enhancement coefficient K1 and the brightness enhancement coefficient K2 to multiply the basic layer q and the detail layer d of the image respectively to achieve image detail enhancement.
[0045] Another aspect of the present invention provides an FPGA system for implementing color image enhancement, which is applied to the above-mentioned FPGA method for implementing color image enhancement, and includes an adaptive limited histogram equalization module, a threshold-protected gamma transformation module, and a detail enhancement module of an unsharp mask and a guided filter combination;
[0046] The adaptive restricted histogram equalization module includes a histogram statistics module and a histogram equalization module, the input of the histogram statistics module is the brightness of the image to be processed, and the output of the histogram statistics module is connected to the input of the histogram equalization module; the histogram statistics module is used to perform histogram statistics, merging and clipping on the image to be processed to generate a cumulative histogram of the entire image to be processed; the histogram equalization module is used to adjust the currently input image data according to the cumulative histogram information of the entire image to be processed to obtain contrast-enhanced image data;
[0047] The input of the detail enhancement module of the unsharp mask and guided filter combination is connected to the output of the histogram equalization module, and is used to perform detail enhancement based on the unsharp mask and guided filter combination on the effect of contrast enhancement;
[0048] The input of the threshold-protected gamma transform module is the saturation of the image to be processed, and is used to enhance the saturation component of the color image to be processed.
[0049] As a preferred technical solution, the adaptive restricted histogram equalization module includes an adaptive restricted histogram statistics part and a histogram equalization part;
[0050] The specific steps of the adaptive limiting histogram statistics part are as follows:
[0051] Divide the brightness I channel of the color image to be processed into M*N equal parts of small area images;
[0052] Calculate the histogram statistics of M*N area images, and store the M*N histogram statistics in the on-chip RAM inside the FPGA;
[0053] Crop the histogram statistics of M*N regional images: Set the histogram amplitude limit value Limit, compare the obtained histogram statistics of M*N regional images with Limit, crop the part of the histogram statistics that is greater than the Limit value, and divide it equally into the entire histogram range;
[0054] Further trimming the trimmed result so that the maximum value of the trimmed histogram statistical result is not greater than Limit; updating the final trimmed histogram statistical result to the on-chip RAM inside the FPGA;
[0055] Output the accumulated histogram statistics: after the M*N cropped histogram statistics are completed, before the next frame of image arrives, the M*N cropped histogram statistics are accumulated and updated to the accumulated histogram statistics of the histogram equalization part, using the on-chip RAM inside another FPGA, and at the same time clearing the on-chip RAM values inside the M*N FPGAs of the adaptive limit histogram statistics part.
[0056] As a preferred technical solution, the specific steps of the histogram equalization part are as follows:
[0057] Receiving the accumulated histogram statistics results of the M*N regional images of the adaptive restricted histogram statistics part;
[0058] According to the size of the current image pixel value, the final balanced value is mapped by accumulating the histogram statistics; according to the balanced values mapped by the adjacent 4 area images, the corresponding interpolation algorithm is selected to calculate the final balanced value.
[0059] As a preferred technical solution, the detail enhancement module of the unsharp mask and guided filter combination includes a guided filter module, an unsharp mask module and an image fusion module;
[0060] The guided filtering module performs low-pass filtering on the output image of the adaptive restricted histogram equalization module to obtain a basic layer of the image;
[0061] The unsharp mask module performs a subtraction operation on the image output by the adaptive restricted histogram equalization module and the basic layer of the image to obtain a detail layer of the image;
[0062] The image fusion module uses two weighting coefficients K1 and K2 to multiply the basic layer of the image and the detail layer of the image respectively, thereby achieving image detail enhancement.
[0063] As a preferred technical solution, the detail enhancement module of the unsharp mask and guided filtering combination is used to simultaneously process the odd and even original images in parallel, taking the result based on adaptive restricted histogram equalization as the detail enhanced input image, performing guided filtering operation on the input image, calculating the weighted mean of all guided filtering coefficients in each window, and using the weighted mean guided filtering coefficient to calculate the guided filtering image basic layer, and finally performing weighted adjustment on the guided filtering image basic layer and the original image.
[0064] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0065] (1) The present invention can solve the color cast problem in the image enhancement process by processing the color image in the HSI color space.
[0066] (2) The present invention crops the image into M*N equal parts of small area images, uses adaptive restricted histogram equalization, counts the histogram results of each sub-image respectively, and crops them, and finally obtains the enhanced image after equalization through bilinear interpolation, which effectively solves the problem of over-enhancement of the original image with large local contrast.
[0067] (3) The present invention realizes saturation enhancement by using a gamma transform based on threshold protection on the saturation component S, only adjusting the images in the medium and high saturation areas, and not adjusting the images in the low saturation areas, thereby avoiding the pseudo-color problem caused by the traditional method of adjusting the low saturation areas. The logic circuit proposed by the present invention uses a logarithmic function and an exponential function with a base of 2, and realizes the gamma transform of any threshold parameter T and any parameter z through multiplication and shift operations, thereby solving the problem of high consumption of logic resources based on traditional lookup table mapping.
[0068] (4) The present invention achieves detail enhancement by using a combination of unsharp masking and guided filtering on the effect of contrast enhancement. Using guided filtering as a low-pass filter can not only enhance the details, but also reduce the noise amplification problem caused by traditional differential operator sharpening. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 It is a flowchart of the overall implementation of an FPGA method for color image enhancement according to an embodiment of the present invention;
[0070] Figure 2 is a schematic diagram of image segmentation using adaptive restricted histogram equalization according to an embodiment of the present invention;
[0071] Figure 3 Schematic diagram of histogram statistics of adaptive restricted histogram equalization according to an embodiment of the present invention;
[0072] Figure 4Schematic diagram of histogram clipping of adaptive restricted histogram equalization according to an embodiment of the present invention;
[0073] Figure 5 It is a logic implementation circuit of the gamma conversion module of the threshold protection in the embodiment of the present invention;
[0074] Figure 6 is a block diagram of an implementation of a guided filtering module according to an embodiment of the present invention;
[0075] Figure 7 is a block diagram of an implementation of a detail enhancement module combining unsharp masking and guided filtering according to an embodiment of the present invention;
[0076] Figure 8 This is a diagram showing the effects of the image enhancement before and after the present invention is implemented; wherein, Figure 8 (a) is the original color image before image enhancement. Figure 8 (b) is the color image after image enhancement
[0077] Fig. 9 The present invention is a flowchart of an FPGA system for implementing color image enhancement according to an embodiment of the present invention. DETAILED DESCRIPTION
[0078] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0079] Example
[0080] like Figure 1 As shown, this embodiment provides an FPGA method for implementing color image enhancement, comprising the following steps:
[0081] S1, extract the brightness I, saturation S, and chroma H of the color image to be processed;
[0082] In this embodiment, the output signal H originally has a value range of [0, 2*π]. Now the range is expanded by 360*2 / (2*π) times, and the value range is [0, 720], represented by a 10-bit register. When the H channel register increases by 1, the hue H increases by 0.5° when converted into an angle.
[0083] S2, performing contrast enhancement based on adaptive restricted histogram equalization in the brightness I channel, wherein the adaptive restricted histogram equalization includes adaptive restricted histogram statistics and histogram equalization;
[0084] The adaptive limiting histogram statistics specifically includes the following steps:
[0085] S2.1, dividing the brightness I channel of the color image to be processed into M*N equal small area images;
[0086] S2.2, calculating the histogram statistics of the M*N regional images, and storing the M*N histogram statistics in the on-chip RAM inside the FPGA;
[0087] In this embodiment, the 4K resolution image (3840*2160) is divided into 8*6 equal parts, and the image resolution size of each area is 480*360. Figure 2 As shown in , the entire image can be divided into three types of regions: corner region (CR), edge region (BR), and internal region (IR). Figure 3 As shown in the figure, the histogram of the 480*360 block size is counted and the statistical results are saved in the dual-port RAM. The total number of pixels in each block is 172800, the dual-port RAM data bit width is 18, and the address depth is 256. Since the internal block RAM of Xilinx FPGA can be configured to 18*2048 size, it can be Figure 8 The statistical results of the blocks are stored in the same block RAM. Then 6 block RAMs can store the histogram statistical results of the 3840*2160 size image.
[0088] In order to meet the real-time processing requirements, two pixel data are input for each clock, and the two pixels need to be counted separately. Eight block RAMs are used to store the histogram statistics. Block RAM0 stores the histogram statistics of odd pixels in rows 1-360, and block RAM6 stores the histogram statistics of even pixels in rows 1-360. Similarly, RAM1 and RAM7 are used to store the histogram statistics of odd and even pixels in rows 361-720.
[0089] S2.3, the histogram statistics of the cropped M*N region images, such as Figure 4 As shown: Set the histogram amplitude limit value Limit, compare the histogram statistical results of the M*N regional images obtained by S2.2 with Limit, crop the part of the histogram statistical result greater than the Limit value, and divide it equally into the entire histogram range.
[0090] S2.4, further trimming the result of trimming in S2.3 so that the maximum value of the histogram statistical result after trimming is not greater than Limit; updating the final trimmed histogram statistical result to the on-chip RAM inside the FPGA.
[0091] S2.5. Output the accumulated histogram statistics: After the M*N cropped histogram statistics are completed, before the next frame of image arrives, the M*N cropped histogram statistics are accumulated and updated to the accumulated histogram statistics of the histogram equalization part, using the on-chip RAM inside another FPGA.
[0092] S2.6, clearing the on-chip RAM values in the M*N FPGAs in the statistics part of the adaptive limit histogram, which is performed synchronously after step S2.5.
[0093] The histogram equalization specifically comprises the following steps:
[0094] S2.7, receiving the accumulated histogram statistics results of the M*N area images of the adaptive restricted histogram statistics part;
[0095] S2.8, according to the size of the current image pixel value, the final balanced value is mapped by accumulating the histogram statistics; according to the balanced values mapped by the adjacent 4 region images, the corresponding interpolation algorithm is selected to calculate the final balanced value, specifically:
[0096] 1) For the pixels in the four corner areas of the image block 1, 8, 41, and 48, take the CR of image block 1 as an example.
[0097] Each pixel q of CR in image block 1 eq =block1(q ori )*256 / (total number of block pixels 480*360)
[0098] where q eq is the balanced output, q ori is the value of the original pixel, block1 is the RAM statistical value of image block 1, and by mapping the address of block1, the address is equal to q ori The RAM statistics value of the final result processing block has a total of 480*360 pixels. This is the balanced value output by the area.
[0099] 2) For the boundary point BR of the image block, take the BR of image block 1 as an example.
[0100] Each pixel q of the image block 1 output block eq 1 =block1(q ori )*256 / (total number of block pixels 480*360)
[0101] Each pixel q of the image block 2 output block eq 2 =block2(q ori )*256 / (total number of block pixels 480*360)
[0102] The final balanced output result is q eq 1 and q eq 2 The weighted average of the pixels is the distance from the pixel to the center.
[0103] 3) For the internal area points IR of the image block, take the IR of image block 1 as an example.
[0104] Each pixel q of the image block 1 output block eq 1 =block1(q ori )*256 / (total number of block pixels 480*360)
[0105] Each pixel q of the image block 2 output block eq 2 =block2(q ori )*256 / (total number of block pixels 480*360)
[0106] Each pixel q of the image block 9 outputs eq 9 =block9(q ori )*256 / (total number of block pixels 480*360)
[0107] Each pixel q of the image block 10 outputs eq 10 =block10(q ori )*256 / (total number of block pixels 480*360)
[0108] The final balanced output result is q eq 1 and q eq 2 and q eq9 and q eq10 The weighted average of the pixels is the distance from the pixel to the center.
[0109] S3. Perform saturation enhancement based on threshold-protected gamma transform in the saturation S channel, specifically:
[0110] Protect low-saturation areas and enhance medium- and high-saturation areas. Adjust the low-saturation threshold through parameter T and adjust the overall saturation enhancement through parameter z, as shown in the following formula:
[0111]
[0112] Where S(i,j) is the information of the saturation channel S, T is the protection threshold of saturation adjustment, z is the degree of enhancement of the overall saturation, S(i,j) enhanced is the data after saturation enhancement, S(i,j), T,z, S(i,j) enhanced The value range of is [0,1];
[0113] By using the fixed-point method, S(i,j) and T are expanded by 2 N Multiple, (here N = 10), the enhancement formula is as follows:
[0114]
[0115] S, T, S after fixed point processing enhanced The value range is [0,2 N ];
[0116] in, In FPGA, it is decomposed into a logarithmic function and an exponential function with base 2. The decomposition formula is as follows:
[0117]
[0118] Calculate the saturation-adjusted S by multiplication, addition, subtraction, and shift operations enhanced .
[0119] In order to solve First, we need to solve exist Figure 5 In the example, the input parameters are ST, 2 N -T, and saturation control intensity z, where S is the saturation component of the input, T is the threshold, 2 N It is the multiple of each parameter fixed-point processing. Here N10 means all parameters are expanded by 1024. log2[k] is the FPGA lookup table. The input range of the log2[k] lookup table is [0,1023]. The result of ST lookup mapping by log2[k] is subtracted by 2. N -T finds the result of the mapping by log2[k] and multiplies it by the control intensity z. The result is In order to get It is also necessary to Calculation, under the condition that N = 10 and Z is in the range of (0,1), z*(log2(ST)-log2(2 N -T)) is in the range of (-N, 0), which is a non-positive number D. This non-positive number can be split into a positive decimal n between (0, 1) and a negative integer -m:
[0120] D = nm
[0121] So 2 D =2 n *2 -m Convert to 2 D =2 n / 2 m , m is a positive integer, n ranges from (0,1), first calculate 2 n, and then shift the result right by m bits, where 2 n Use the lookup table to calculate, the mapping expression of the lookup table is 2 [k] .exist Figure 5 The corresponding Expression, and finally multiply the result by 2 N -T plus T, that is That is, the result after saturation enhancement S enhanced .
[0122] S4, based on the contrast enhancement effect, detail enhancement based on the combination of unsharp masking and guided filtering is performed, such as Figure 7 As shown, specifically:
[0123] S4.1, using the result based on adaptive restricted histogram equalization as the detail enhanced input image p, performing a guided filtering operation on the input image p, and obtaining a guided filtering coefficient a within any square window size k
[0124] and b k , guided filter coefficient a k and b k The calculation formula is as follows:
[0125]
[0126] in, is the input image data in window W k The mean of It is the square of the input image data in the window W k The mean of is the input image data in window W k The variance of k and b k Is the guided filter module in the window W k The calculated coefficient; ε is the threshold for defining the smooth area and edge area of the image, which is a regularization parameter;
[0127] Figure 6This is a block diagram for implementing the guided filtering of this embodiment. Each row of the original image p can be divided into odd pixel data o and even pixel data e according to the position; the 3*3 window data centered on the odd pixel data o and the template 1 [1,1,1; 1,1,1; 1,1,1] are convolved to obtain the sum of the 9 image data in the 3*3 window centered on the odd pixel data o, sum_o; at the same time, the 3*3 window data centered on the even pixel data e and the template 1 [1,1,1; 1,1,1; 1,1,1] are convolved to obtain the sum of the 9 image data in the 3*3 window centered on the even pixel data e, sum_e; sum_o and sum_e are both 12-bit registers, where 12 bits represent integers. The result of multiplying sum_o and sum_o is multiplied by 103563, and the result is ave_op, the square of the mean value in the 3*3 window centered on the odd pixel data o; at the same time, the result of multiplying sum_e and sum_e is multiplied by 103563, and the result is ave_ep, the square of the mean value in the 3*3 window centered on the even pixel data e; ave_op and ave_ep are both 39-bit registers, the upper 16 bits represent integers, and the lower 23 bits represent decimals.
[0128] In parallel, the square operation result of each pixel data of the original image p is convolved with the template 1 [1,1,1; 1,1,1; 1,1,1] to obtain the sum sum_po in the 3*3 window centered on the odd pixel data o, and the sum sum_pe in the 3*3 window centered on the even pixel data e; where sum_po and sum_pe are both 20-bit registers, and the upper 20 bits represent integers. sum_po and sum_pe are multiplied by 116508 at the same time to obtain the average values ave_po and ave_pe of sum_po and sum_pe, where ave_po and ave_pe are both 36-bit registers, the upper 16 bits represent integers, and the lower 20 bits represent decimals.
[0129] At the same time, the difference between ave_po and ave_op is vari_o, which represents the variance of the 3*3 window data centered on the odd pixel data o, and the difference between ave_pe and ave_e is vari_e, which represents the variance of the 3*3 window data centered on the even pixel data e, where vari_o and vari_e are 16-bit registers, and all 16 bits represent integers.
[0130] vari_o is divided by the sum of vari_o and the regularization parameter ε to obtain the guided filter module coefficient ak_o of the 3*3 window data centered on the odd pixel data o, and vari_e is divided by the sum of vari_e and the regularization parameter ε to obtain the guided filter module coefficient ak_e of the 3*3 window data centered on the even pixel data e; ak_o and ak_e are both 12-bit registers, and all 12 bits represent decimals, representing decimals between 0 and 1.
[0131] The result of subtracting ak_o from the value 1 and multiplying it by ave_o, obtains the guided filter module coefficient bk_o of the 3*3 window data centered on the odd pixel data o, where ave_o is the mean of sum_o, and the guided filter module coefficient bk_o is a 12-bit register, with the upper 8 bits representing integers and the lower 4 bits representing decimals. The result of subtracting ak_e from the value 1 and multiplying it by ave_e, obtains the guided filter module coefficient bk_e of the 3*3 window data centered on the odd pixel data e, where ave_e is the mean of sum_e, and the guided filter module coefficient bk_e is a 12-bit register, with the upper 8 bits representing integers and the lower 4 bits representing decimals.
[0132] bk_e, bk_o, ak_o and ak_e are all 12-bit registers. A 12-bit wide FIFO buffer is used to form a 3-row window. In the 3*3 window of the buffer, the 3*3 window where ak_o and ak_e are located is convolved with the template 2[1,2,1; 2,4,2; 1,2,1] to obtain the weighted average values ave_ak_e and ave_ak_o of the coefficients ak of the guided filter module. At the same time, the 3*3 window where bk_o and bk_e are located is convolved with the template 2[1,2,1; 2,4,2; 1,2,1] to obtain the weighted average values ave_bk_e and ave_bk_o of the coefficients bk of the guided filter module. The weighted average guided filter coefficient ave_ak is finally calculated by ave_ak_e and ave_ak_o, and the guided filter coefficient ave_bk is composed of ave_bk_e and ave_bk_o.
[0133] S4.2. Calculate each window W k All guided filter coefficients a within k and b k The weighted mean ave_a k and ave_b k , and use the weighted mean guided filter coefficient to calculate the guided filter image basic layer q, for each pixel data:
[0134] q i =ave_a k *p i +ave_b k,i∈W k
[0135] where p i W is in the window k The center pixel of the input image, q i W is in the window k The original image data of the central pixel point is output by the guided filtering module, and the output data is the basic layer q of the image;
[0136] [ε is the threshold for defining the smooth area and edge area of the image. There are two cases:
[0137] 1) Smooth area of the image: within the window W k The variance of the original image P is small relative to the parameter ε, then a k Close to 0, b k Close to Then the image output q i satisfy This is equivalent to performing mean filtering in this area.
[0138] 2) Edge area of the image: variance of the original image P is large relative to the parameter ε, then a k Close to 1, b k is close to 0, the image output q i Satisfaction formula q i ≈p i , which is equivalent to maintaining the edge information of the area. 】
[0139] S4.3, unsharp masking, performing a subtraction operation on the image after contrast enhancement based on adaptive restricted histogram equalization and the basic layer q of the image to obtain a detail layer d of the image;
[0140] S4.3, image fusion, use detail enhancement coefficient K1 and brightness enhancement coefficient K2, multiply the basic layer q and detail layer d of the image respectively, to achieve image detail enhancement. K1 is generally set to 1, K2 can be set to 1.2, 1.5, 2, 2.5, etc., according to different coefficients, the detail level of the entire image can be adjusted.
[0141] In particular, in this embodiment:
[0142] 1) Process even and odd original images simultaneously and in parallel.
[0143] 2) The algorithmic template 2 is suggested to be an average template of all 1s. The present invention uses the approximate template 2 to simplify the hardware design because the multiplication of 1 2 4 is easy to implement in hardware.
[0144] 3) Cache the 3-row window to obtain the coefficients ave_ak and ave_bk required for the guided filter. Finally, calculate the guided filtered image q.
[0145] S5. Keep the chromaticity H unchanged to obtain the enhanced color image.
[0146] Figure 8 These are the effect diagrams before and after the image enhancement of the present invention is realized. Figure 8 (a) is the original color image before image enhancement. Figure 8 (b) is a color image after image enhancement. It is obvious that the effect of the image processed by the image enhancement algorithm of the present invention is greatly improved.
[0147] like Fig. 9 As shown, in another embodiment of the present application, an FPGA system for implementing color image enhancement is provided, the system comprising an adaptive limited histogram equalization module, a threshold-protected gamma transform module, and a detail enhancement module of an unsharp mask and a guided filter combination;
[0148] The adaptive restricted histogram equalization module includes a histogram statistics module and a histogram equalization module, the input of the histogram statistics module is the brightness of the image to be processed, and the output of the histogram statistics module is connected to the input of the histogram equalization module; the histogram statistics module is used to perform histogram statistics, merging and clipping on the image to be processed to generate a cumulative histogram of the entire image to be processed; the histogram equalization module is used to adjust the currently input image data according to the cumulative histogram information of the entire image to be processed to obtain contrast-enhanced image data;
[0149] The input of the detail enhancement module of the unsharp mask and guided filter combination is connected to the output of the histogram equalization module, and is used to perform detail enhancement based on the unsharp mask and guided filter combination on the effect of contrast enhancement;
[0150] The input of the threshold-protected gamma transform module is the saturation of the image to be processed, which is used to enhance the saturation component (detail component, or sharpening component) of the color image to be processed;
[0151] As a preferred technical solution, the adaptive restricted histogram equalization module includes an adaptive restricted histogram statistics part and a histogram equalization part;
[0152] The specific steps of the adaptive limiting histogram statistics part are as follows:
[0153] The image to be processed converted to the HSI color space is divided into M*N equal parts of small area images, where 8*8 or 8*6 equal parts are selected;
[0154] Calculate the histogram results of M*N area images, and store the M*N histogram results in the on-chip RAM inside the FPGA;
[0155] Crop the histogram statistics results of M*N regional images: set the histogram amplitude limit value Limit, compare the obtained histogram statistics results of M*N regional images with Limit, crop the part of the histogram statistics result greater than the Limit value, and divide it equally into the entire histogram range.
[0156] Further trimming is performed on the trimmed result so that the maximum value of the trimmed histogram statistical result is not greater than Limit; and the final trimmed histogram statistical result is updated to the on-chip RAM inside the FPGA.
[0157] Output the accumulated histogram statistics: after the M*N cropped histogram statistics are completed, before the next frame of image arrives, the M*N cropped histogram statistics are accumulated and updated to the accumulated histogram statistics of the histogram equalization part, using the on-chip RAM inside another FPGA, and at the same time clearing the on-chip RAM values inside the M*N FPGAs of the adaptive limit histogram statistics part.
[0158] As a preferred technical solution, the specific steps of the histogram equalization part are as follows:
[0159] Receiving the accumulated histogram statistics results of the M*N regional images of the adaptive restricted histogram statistics part;
[0160] According to the size of the current image pixel value, the final balanced value is mapped by accumulating the histogram statistics; according to the balanced values mapped by the adjacent 4 area images, the corresponding interpolation algorithm is selected to calculate the final balanced value.
[0161] As a preferred technical solution, the detail enhancement module of the unsharp mask and guided filter combination includes a guided filter module, an unsharp mask module and an image fusion module;
[0162] The guided filtering module performs low-pass filtering on the output image of the adaptive restricted histogram equalization module to obtain a basic layer of the image;
[0163] The unsharp mask module performs a subtraction operation on the image output by the adaptive restricted histogram equalization module and the basic layer of the image to obtain a detail layer of the image;
[0164] The image fusion module uses two weighting coefficients K1 and K2 to multiply the basic layer of the image and the detail layer of the image respectively, thereby achieving image detail enhancement.
[0165] As a preferred technical solution, the detail enhancement module of the unsharp mask and guided filtering combination is used to simultaneously process odd and even original images in parallel, taking the result based on adaptive restricted histogram equalization as the detail enhanced input image, performing guided filtering operation on the input image, calculating the weighted mean of all guided filtering coefficients in each window, and using the weighted mean guided filtering coefficient to calculate, and finally performing weighted adjustment on the basic layer of the guided filtering image and the original image.
[0166] It should be noted here that the system provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure is divided into different functional modules to complete all or part of the functions described above. The system is an FPGA method for realizing color image enhancement applied to the above embodiment.
[0167] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A color image enhancement method based on FPGA, characterized in that: The following steps are involved: Extract the brightness I, saturation S, and chroma H of the color image to be processed; Performing contrast enhancement based on adaptive restricted histogram equalization in the brightness I channel, wherein the adaptive restricted histogram equalization includes adaptive restricted histogram statistics and histogram equalization; The saturation enhancement based on the threshold protection gamma transform is performed in the saturation S channel as follows: Where S(i,j) is the information of the saturation channel S, T is the protection threshold of saturation adjustment, z is the degree of enhancement of the overall saturation, S(i,j) enhanced is the data after saturation enhancement, S(i,j), T,z, S(i,j) enhanced The value range of is [0,1]; By using the fixed-point method, S(i,j) and T are expanded by 2 N′ The enhancement formula is as follows: S, T, S after fixed point processing enhanced The value range is [0,2 N′ ]; in, In FPGA, it is decomposed into a logarithmic function and an exponential function with base 2. The decomposition formula is as follows: Calculate the saturation-adjusted S by multiplication, addition, subtraction, and shift operations enhanced ; Based on the effect of contrast enhancement, detail enhancement is performed based on the combination of unsharp masking and guided filtering; Keeping the chromaticity H unchanged, the enhanced color image is obtained.
2. The color image enhancement method based on FPGA according to claim 1, characterized in that: The adaptive limiting histogram statistics specifically includes the following steps: Divide the brightness I channel of the color image to be processed into M*N equal parts of small area images; Calculate the histogram statistics of M*N area images, and store the M*N histogram statistics in the on-chip RAM inside the FPGA; Crop the histogram statistics of M*N regional images: Set the histogram amplitude limit value Limit, compare the calculated histogram statistics of M*N regional images with Limit, crop the part of the histogram statistics that is greater than the Limit value, and divide it equally into the entire histogram range; Further trimming the trimmed result so that the maximum value of the trimmed histogram statistical result is not greater than Limit; updating the final trimmed histogram statistical result to the on-chip RAM inside the FPGA; Outputting the accumulated histogram statistics: after the M*N cropped histogram statistics are completed, before the next frame of image arrives, the M*N cropped histogram statistics are accumulated and updated to the accumulated histogram statistics of the histogram equalization part, using the on-chip RAM inside another FPGA; Clear the on-chip RAM values in the M*N FPGAs in the adaptive limit histogram statistics part.
3. The color image enhancement method based on FPGA according to claim 2, characterized in that: The histogram equalization specifically comprises the following steps: Receiving the accumulated histogram statistics results of the M*N regional images of the adaptive restricted histogram statistics part; According to the size of the current image pixel value, the final balanced value is mapped by accumulating the histogram statistics; according to the balanced values mapped by the adjacent 4 area images, the corresponding interpolation algorithm is selected to calculate the final balanced value.
4. The color image enhancement method based on FPGA according to claim 1, characterized in that: The detail enhancement based on the combination of unsharp masking and guided filtering on the contrast enhancement effect is specifically as follows: The result based on adaptive restricted histogram equalization is used as the detail enhanced input image p, and a guided filtering operation is performed on the input image p to obtain a guided filtering coefficient a within any square window size. k and b k , guided filter coefficient a k and b k The calculation formula is as follows: in, is the input image data in window W k The mean of It is the square of the input image data in the window W k The mean of is the input image data in window W k The variance of k and b k Is the guided filter module in the window W k The calculated coefficient; ε is the threshold for defining the smooth area and edge area of the image, which is a regularization parameter; Calculate each window W k All guided filter coefficients a within k and b k The weighted mean ave_a k and ave_b k , and use the weighted mean guided filter coefficient to calculate the guided filter image basic layer q, for each pixel data: q i =ave_a k *p i +ave_b k ,i∈W k where p i W is in the window k The center pixel of the input image, q i W is in the window k The original image data of the central pixel point is output by the guided filtering module, and the output data is the basic layer q of the image; Unsharp masking, subtracting the image after contrast enhancement based on adaptive restricted histogram equalization from the basic layer q of the image to obtain the detail layer d of the image; Image fusion uses the detail enhancement coefficient K1 and the brightness enhancement coefficient K2 to multiply the basic layer q and the detail layer d of the image respectively to achieve image detail enhancement.
5. An FPGA system for implementing color image enhancement, characterized in that: A color image enhancement method based on FPGA implemented as claimed in any one of claims 1 to 4, comprising an adaptive limited histogram equalization module, a threshold-protected gamma transformation module, and a detail enhancement module of an unsharp mask and guided filtering combination; The adaptive restricted histogram equalization module comprises a histogram statistics module and a histogram equalization module, the input of the histogram statistics module is the brightness of the image to be processed, and the output of the histogram statistics module is connected to the input of the histogram equalization module; The histogram statistics module is used to perform histogram statistics, merging and cropping on the image to be processed, and generate a cumulative histogram of the entire image to be processed; The histogram equalization module is used to adjust the currently input image data according to the accumulated histogram information of the entire image to be processed to obtain contrast-enhanced image data; The input of the detail enhancement module of the unsharp mask and guided filter combination is connected to the output of the histogram equalization module, and is used to perform detail enhancement based on the unsharp mask and guided filter combination on the effect of contrast enhancement; The input of the threshold-protected gamma transform module is the saturation of the image to be processed, and is used to enhance the saturation component of the color image to be processed.
6. The FPGA system for implementing color image enhancement according to claim 5, characterized in that: The adaptive restricted histogram equalization module includes an adaptive restricted histogram statistics part and a histogram equalization part; The specific steps of the adaptive limiting histogram statistics part are as follows: Divide the brightness I channel of the color image to be processed into M*N equal parts of small area images; Calculate the histogram statistics of M*N area images, and store the M*N histogram statistics in the on-chip RAM inside the FPGA; Crop the histogram statistics of M*N regional images: Set the histogram amplitude limit value Limit, compare the obtained histogram statistics of M*N regional images with Limit, crop the part of the histogram statistics that is greater than the Limit value, and divide it equally into the entire histogram range; Further trimming the trimmed result so that the maximum value of the trimmed histogram statistical result is not greater than Limit; updating the final trimmed histogram statistical result to the on-chip RAM inside the FPGA; Output the accumulated histogram statistics: after the M*N cropped histogram statistics are completed, before the next frame of image arrives, the M*N cropped histogram statistics are accumulated and updated to the accumulated histogram statistics of the histogram equalization part, using the on-chip RAM inside another FPGA, and at the same time clearing the on-chip RAM values inside the M*N FPGAs of the adaptive limit histogram statistics part.
7. The FPGA system for implementing color image enhancement according to claim 6, characterized in that: The specific steps of the histogram equalization part are as follows: Receiving the accumulated histogram statistics results of the M*N regional images of the adaptive restricted histogram statistics part; According to the size of the current image pixel value, the final balanced value is mapped by accumulating the histogram statistics; according to the balanced values mapped by the adjacent 4 area images, the corresponding interpolation algorithm is selected to calculate the final balanced value.
8. The FPGA system for implementing color image enhancement according to claim 5, characterized in that: The detail enhancement module of the unsharp mask and guided filter combination includes a guided filter module, an unsharp mask module and an image fusion module; The guided filtering module performs low-pass filtering on the output image of the adaptive restricted histogram equalization module to obtain a basic layer of the image; The unsharp mask module performs a subtraction operation on the image output by the adaptive restricted histogram equalization module and the basic layer of the image to obtain a detail layer of the image; The image fusion module uses two weighting coefficients K1 and K2 to multiply the basic layer of the image and the detail layer of the image respectively, thereby achieving image detail enhancement.
9. The FPGA system for implementing color image enhancement according to claim 5, characterized in that: The detail enhancement module of the unsharp mask and guided filtering combination is used to process the odd and even original images in parallel at the same time, taking the result based on adaptive restricted histogram equalization as the detail enhancement input image, performing guided filtering operation on the input image, calculating the weighted mean of all guided filtering coefficients in each window, and using the weighted mean guided filtering coefficient to calculate the guided filtering image basic layer, and finally performing weighted adjustment on the guided filtering image basic layer and the original image.
Citation Information
Patent Citations
Food image color enhancement method based on color space characteristics
CN105184757A
Improved HSI space information low-illumination color image enhancement algorithm
CN106504212A
Bilateral adaptive image visualization enhancement method and imaging system
CN111462024A
Banana bunch identification method based on background saturation compression and difference threshold segmentation fusion
CN113361315A
