CN-121981884-A - Color interpolation method suitable for industrial vision
Abstract
The invention relates to the technical field of color interpolation, and belongs to a color interpolation method suitable for industrial vision, comprising the following steps of S1, acquiring a Bayer image to be processed; the method comprises the steps of S2, reconstructing a G channel image based on gradient dynamic distribution weight, S3, reconstructing R channel and B channel images based on residual interpolation correction in a G channel gradient guiding direction, S4, carrying out Retinex enhancement on the reconstructed RGB image, and S5, outputting the enhanced RGB image. According to the invention, the G channel image is reconstructed based on the gradient dynamic distribution weight, then the R channel image and the B channel image are reconstructed based on the G channel gradient guiding direction and the residual interpolation correction, the pseudo color and the zipper effect are reduced, and then the reconstructed RGB image is subjected to Retinex enhancement, so that the enhanced Retinex image is obtained, the atomization of the image after interpolation is reduced, and the image quality is improved.
Inventors
- Xiao Longqin
- WU LIUYI
Assignees
- 元途人工智能(杭州)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260408
Claims (5)
- 1. The color interpolation method suitable for industrial vision is characterized by comprising the following steps: s1, acquiring a Bayer image to be processed; s2, reconstructing a G channel image based on the gradient dynamic allocation weight, S3, adding residual interpolation correction based on the G channel gradient guiding direction, and reconstructing R channel and B channel images; s4, carrying out Retinex enhancement on the reconstructed RGB image; s5, outputting the enhanced RGB image.
- 2. The method for color interpolation suitable for industrial vision according to claim 1, wherein in the step S2, the step of reconstructing the G channel image based on the gradient dynamic allocation weights is as follows: s21, calculating gradients in multiple directions; S22, calculating neighborhood G component average values of multiple directions; S23, selecting all known G and R pixel pairs in a preset range I, and calculating chromatic aberration to obtain a neighborhood chromatic aberration sample; s24, carrying out average smoothing on the color difference samples in the S23 within a preset size to obtain local average color difference; s25, calculating preliminary G estimated values in all directions by combining the R value of the current pixel and the average chromatic aberration obtained in the S24, and performing color deviation prevention treatment; s26, dynamically distributing weights of a plurality of directions through gradient reciprocal weighting, and carrying out weight normalization; And S27, finally, calculating an interpolation result of the G channel according to the weight obtained in the step S26, and completing the image reconstruction of the G channel.
- 3. The method for color interpolation suitable for industrial vision according to claim 1, wherein in the step S3, the R-channel and B-channel image reconstruction comprises the following specific steps: s31, calculating the horizontal gradient and the vertical gradient of the G channel in a second preset range; s32, comparing the horizontal gradient and the vertical gradient obtained in the step S31, judging the edge direction of the G channel, and determining the interpolation direction of the R/B channel; s33, according to the guiding direction determined in the S32, interpolation is carried out by using known R/B pixels in a second preset range, and the interpolated value is a preliminary estimated value; s34, defining a local linear fitting coefficient, and performing bilinear interpolation on the residual error in the second preset range to obtain a residual error estimated value of the position to be interpolated; and S35, finally, obtaining a final R/B channel result according to the local linear fitting coefficient.
- 4. The method for color interpolation according to claim 3, wherein in the step S32, specific judgment logic is as follows: If the horizontal gradient is smaller than the vertical gradient, the edge of the G channel is in the vertical direction, the horizontal direction is smooth, and the R/B channel is interpolated along the horizontal direction; if the vertical gradient is smaller than or equal to the horizontal gradient, the edge of the G channel is in the horizontal direction, the vertical direction is smooth, and the R/B channel is interpolated along the vertical direction.
- 5. The method for color interpolation suitable for industrial vision according to claim 1, wherein in the step S4, retinex enhancement is performed as follows: S41, carrying out log transformation on the rebuilt RGB to obtain a log transformed image; s42, carrying out Gaussian blur on the log-transformed image to obtain a Gaussian blurred image; S43, subtracting the image after log transformation from the image after Gaussian blur to obtain an image after illumination removal; s44, performing inverse log transformation on the image subjected to illumination removal to obtain a Retinex enhanced image.
Description
Color interpolation method suitable for industrial vision Technical Field The invention relates to the technical field of color interpolation, and belongs to a color interpolation method suitable for industrial vision. Background If the camera image sensor is equipped with an acquisition structure of three channels of RGB for each pixel, hardware cost and complexity can be greatly improved. Bayer arrays solve this problem by overlaying a specific arrangement of RGB filters over the sensor pixels, typically a 2x 2 RGGB arrangement, with up to 50% green filters and 25% red and blue filters, respectively, because the human eye is most sensitive to green. However, with this design, each pixel can capture only one color of light information, and to obtain a normal color image, the missing two other color channel data must be filled by means of the Bayer removal algorithm. But conventional color interpolation is prone to color distortion and zipper effects. Such as patent CN101197916a (gradient-based edge-enhanced color interpolation method) which performs a gradient-based color interpolation method by setting a gradient threshold, but if the set gradient threshold is artificially controlled poorly, it may generate a false color generation, CN116847211B (a color filter array interpolation method) performs interpolation by interpolating a color filter array of a tower top, and although a high quality image can be obtained, it is a conventional simple color interpolation algorithm as a whole, and this is a high cost in terms of hardware, CN104159091B (an edge-detection-based color interpolation method) performs interpolation by detecting edges based on edge detection to determine edges and texture portions, and performs color difference estimation and gradient weighting according to a color difference law, but the zipper effect per se cannot be improved well. Disclosure of Invention Aiming at the technical problems, the invention provides a color interpolation method suitable for industrial vision. In order to achieve the above purpose, the present invention provides the following technical solutions: the invention provides a color interpolation method suitable for industrial vision, which comprises the following steps: s1, acquiring a Bayer image to be processed; S2, reconstructing a G channel image based on the gradient dynamic allocation weight; S3, adding residual interpolation correction based on the G channel gradient guiding direction, and reconstructing R channel and B channel images; s4, carrying out Retinex enhancement on the reconstructed RGB image; s5, outputting the enhanced RGB image. Preferably, in the step S2, the specific steps for reconstructing the G-channel image based on the gradient dynamic allocation weights are as follows: S21, calculating the gradient of multiple parties; s22, calculating a multidirectional neighborhood G component mean value; s23, selecting all known G and R pixel pairs in a 5 multiplied by 5 window, and calculating chromatic aberration to obtain a neighborhood chromatic aberration sample; s24, carrying out 3X 3 window mean smoothing on the color difference sample in S23 to obtain local average color difference; s25, calculating preliminary G estimated values in all directions by combining the R value of the current pixel and the average chromatic aberration obtained in the S24, and performing color deviation prevention treatment; S26, dynamically distributing weights in 4 directions through gradient reciprocal weighting, and carrying out weight normalization; And S27, finally, calculating an interpolation result of the G channel according to the weight obtained in the step S26, and completing the image reconstruction of the G channel. Preferably, in the step S3, the specific steps of R-channel and B-channel image reconstruction are as follows: s31, calculating the horizontal gradient and the vertical gradient of the G channel in the 3 multiplied by 3 window; s32, comparing the horizontal gradient and the vertical gradient obtained in the step S31, judging the edge direction of the G channel, and determining the interpolation direction of the R/B channel; s33, according to the guiding direction determined in the S32, interpolation is carried out by using known R/B pixels in a 3 multiplied by 3 window, and the interpolated value is a preliminary estimated value; S34, defining a local linear fitting coefficient, and carrying out bilinear interpolation on the residual error in the 3 multiplied by 3 window to obtain a residual error estimated value of the position to be interpolated; and S35, finally, obtaining a final R/B channel result according to the local linear fitting coefficient. Preferably, in the step S32, specific judgment logic is as follows: If the horizontal gradient is smaller than the vertical gradient, the edge of the G channel is in the vertical direction, the horizontal direction is smooth, and the R/B channel is interpolated along the horizontal direction;