Lens distortion correction method and device, program product and storage medium

By converting the color image to the ycocg color space and compressing the channels, only the brightness and mixed color channels are corrected for lens distortion, which solves the problem of high resource consumption in traditional methods and achieves more efficient lens distortion correction.

CN118612558APending Publication Date: 2024-09-06BRIGATES MICROELECTRONICS (KUNSHAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410684227.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

The traditional lens distortion correction scheme for color images is performed in the RGB color space, which consumes a lot of calculations and resources, and consumes high power.

Method used

Convert the color image to be processed to the ycocg color space, compress the first and second color channels into mixed color channels, perform lens distortion correction only on the brightness channel and mixed color channels, and obtain the corrected color channels through decompression.

Benefits of technology

It effectively reduces the resources and power consumption required for lens distortion correction and improves processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118612558A
    Figure CN118612558A
Patent Text Reader

Abstract

The invention discloses a lens distortion correction method and device, a program product and a storage medium, and the method comprises the steps: converting a to-be-processed color image from an rgb color space to a ycocg color space, and obtaining a brightness channel y, a first color channel co and a second color channel cg corresponding to the to-be-processed color image; co and cg are compressed into a mixed color channel; performing lens distortion correction on the y to obtain a corrected brightness channel dst; and performing lens distortion correction on the mixed color channel to obtain a corrected mixed color channel, decompressing the corrected mixed color channel to obtain a corrected first color channel dstco and a corrected second color channel dstcg; and converting the dsty, the dstco and the dstcg from the ycocg color space to the rgb color space to obtain a target color image. By adopting the scheme, resources required by lens distortion correction can be reduced, and power consumption is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a lens distortion correction method and device, a program product, and a storage medium. Background Art

[0002] Lens distortion refers to the degree of distortion of the image formed by an optical lens relative to the object itself. The direct reason is that the magnification of the edge and the middle of the optical lens is different. Lens distortion will cause the straight lines in the image to deform, affecting the image quality. Usually, it is necessary to correct the lens distortion of the captured image.

[0003] Traditional lens distortion correction schemes for color images are usually completed in the RGB color space, that is, lens distortion correction is performed separately on the red (r) channel, green (g) channel, and blue (b) channel of the image. The required computational effort and line cache are three times that of a single-channel image, resulting in large resource consumption and high power consumption. Summary of the invention

[0004] An objective of the embodiments of the present invention is at least to provide a lens distortion correction method, which can reduce the resources required for lens distortion correction and reduce power consumption.

[0005] In a first aspect, the present invention provides a lens distortion correction method, comprising: converting a color image to be processed from an RGB color space to a YCOCG color space, obtaining a brightness channel Y, a first color channel CO, and a second color channel CG corresponding to the color image to be processed; compressing the CO and the CG into a mixed color channel; performing lens distortion correction on the Y to obtain a corrected brightness channel dst_y; and performing lens distortion correction on the mixed color channel to obtain a corrected mixed color channel; decompressing the corrected mixed color channel to obtain a corrected first color channel dst_co and a corrected second color channel dst_cg; converting the dst_y, the dst_co, and the dst_cg from the YCOCG color space to the RGB color space to obtain a target color image.

[0006] The color image to be processed is converted from the RGB color space to the YCOCG color space to obtain the brightness channel, the first color channel and the second color channel corresponding to the color image to be processed, and the first color channel and the second color channel are compressed into a mixed color channel. Lens distortion correction is performed on the brightness channel and the mixed color channel respectively, and the corrected mixed color channel is decompressed to obtain the corrected first color channel and the corrected second color channel, and then the corrected brightness channel, the corrected first color channel and the corrected second color channel are converted from the YCOCG color space to the RGB color space to obtain the target color image (that is, the color image after lens distortion correction). By compressing the first color channel and the second color channel into a mixed color channel, performing lens distortion correction on the mixed color channel to obtain the corrected mixed color channel, and decompressing the corrected mixed color channel to obtain the corrected first color channel and the corrected second color channel, it is only necessary to perform lens distortion correction on the brightness channel and the mixed color channel, that is, only two channels need to be corrected. Therefore, the resources required for lens distortion correction can be effectively reduced, and power consumption can be reduced.

[0007] Optionally, performing lens distortion correction on the mixed color channel to obtain a corrected mixed color channel includes: obtaining a mapping point of a target pixel in the target color image in the mixed color channel; determining the nearest neighbor pixel in the mixed color channel, the nearest neighbor pixel including: N pixels that are closest to the mapping point in the horizontal direction, and M pixels that are closest to the mapping point in the vertical direction; obtaining a co pixel value and a cg pixel value of the nearest neighbor pixel; and determining a co pixel value and a cg pixel value corresponding to the target pixel based on a horizontal distance and a vertical distance between the mapping point and the nearest neighbor pixel, as well as a co pixel value and a cg pixel value of the nearest neighbor pixel.

[0008] Optionally, obtaining the co pixel value and cg pixel value of the nearest neighbor pixel point includes: the co pixel value of the mapping point is obtained by: obtaining the co pixel value corresponding to the N pixel points closest to the mapping point; if the i-th pixel point among the N pixel points closest to the mapping point is a cg pixel point, then the co pixel value of the i-th pixel point is: co i,j =(co i,j-1 +co i,j+1 ) / 2; among them, co i,j-1 is the pixel value of co of the pixel point adjacent to the left of the i-th pixel point in the mixed color channel; i,j+1is the co pixel value of the co pixel point adjacent to the right side of the i-th pixel point in the mixed color channel; the cg pixel value of the mapping point is obtained by obtaining the cg pixel values ​​corresponding to the N pixels closest to the mapping point; if the i-th pixel point among the N pixels closest to the mapping point is the co pixel point, then the cg pixel value of the i-th pixel point is: cg i,j =(cg i,j-1 +cg i,j+1 ) / 2; where cg i,j-1 is the cg pixel value of the cg pixel point adjacent to the left side of the i-th pixel point in the mixed color channel; cg i,j+1 is the cg pixel value of the cg pixel point adjacent to the right of the i-th pixel point in the mixed color channel.

[0009] Since the first color channel and the second color channel are arranged alternately in the mixed color channel, when calculating the co pixel value and the cg pixel value of the mapping point, it is necessary to obtain the co pixel value of the cg pixel in the nearest neighbor pixel and the cg pixel value of the co pixel in the nearest neighbor pixel. Furthermore, an implementation scheme is provided for how to obtain the co pixel value of the cg pixel in the nearest neighbor pixel and the cg pixel value of the co pixel in the nearest neighbor pixel.

[0010] Optionally, compressing the co and the cg into a mixed color channel includes: downsampling the co by 1 / 2 in the horizontal direction, and using the first downsampling result as the even columns of the mixed color channel; and downsampling the cg by 1 / 2, and using the second downsampling result as the odd columns of the mixed color channel.

[0011] Optionally, decompressing the corrected mixed color channel includes: in the horizontal direction, upsampling the even columns of the corrected mixed color channel by 2 times to obtain the corrected first color channel; and upsampling the odd columns of the corrected mixed color channel by 2 times to obtain the corrected second color channel.

[0012] Optionally, compressing the co and the cg into a mixed color channel includes: downsampling the co by 1 / 2 in the horizontal direction, and using the first downsampling result as the odd columns of the mixed color channel; and downsampling the cg by 1 / 2, and using the second downsampling result as the even columns of the mixed color channel.

[0013] Optionally, decompressing the corrected mixed color channel includes: horizontally upsampling the odd columns of the corrected mixed color channel by 2 times to obtain the corrected first color channel; and upsampling the even columns of the corrected mixed color channel by 2 times to obtain the corrected second color channel.

[0014] In the horizontal direction, the first color channel and the second color channel are respectively downsampled by 1 / 2, and the first downsampling result corresponding to the first color channel is used as the even-numbered column of the mixed color channel, and the second downsampling result corresponding to the second color channel is used as the odd-numbered column of the mixed color channel. Thus, the size of the obtained mixed color channel is the same as the size of the first color channel / the second color channel.

[0015] Furthermore, an up-sampling method corresponding to the down-sampling is adopted to decompress the corrected mixed color channel to obtain a corrected first color channel and a corrected second color channel.

[0016] Optionally, the step of converting the color image to be processed from the RGB color space to the YCOCG color space includes: in the color image to be processed, the y corresponding to the i-th pixel i is: y i =(r i +2*g i +b i ) / 4; the pixel point corresponding to co i For: i =(r i -b i ) / 2+2 n-1 ; The cg corresponding to the pixel i For: cg i =(-r i +2*g i -b i ) / 4+2 n-1 ; Among them, r i is the red pixel value corresponding to the i-th pixel point, g i is the green pixel value corresponding to the i-th pixel, b i is the blue pixel value corresponding to the i-th pixel point, and n is the channel width.

[0017] Optionally, the converting of the dst_y, dst_co and dst_cg from the ycocg color space to the rgb color space includes: in the target color image, the red pixel value dst_r corresponding to the i-th pixel point i For: dst_r i =dst_y i +dst_coi -dst_cg i ; The green pixel value dst_g corresponding to the i-th pixel i For: dst_g i =dst_y i +dst_cg i -2 n-1 ; The blue pixel value dst_b corresponding to the i-th pixel i For: dst_b i =dst_y i -(dst_co i -2 n-1 )-(dst_cg i -2 n-1 ).

[0018] In a second aspect, the present invention provides a lens distortion correction device, comprising: a first conversion unit, used to convert a color image to be processed from an RGB color space to a YCOCG color space, and obtain a brightness channel Y, a first color channel CO, and a second color channel CG corresponding to the color image to be processed; a compression unit, used to compress the CO and the CG into a mixed color channel; a distortion correction unit, used to perform lens distortion correction on the Y to obtain a corrected brightness channel dst_y; and, perform lens distortion correction on the mixed color channel to obtain a corrected mixed color channel; a decompression unit, used to decompress the corrected mixed color channel to obtain a corrected first color channel dst_co and a corrected second color channel dst_cg; a second conversion unit, used to convert the dst_y, the dst_co, and the dst_cg from the YCOCG color space to the RGB color space to obtain a target color image.

[0019] In a third aspect, the present invention further provides a computer-readable storage medium, which is a non-volatile storage medium or a non-transient storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the above-mentioned lens distortion correction methods are executed.

[0020] In a fourth aspect, the present invention further provides a computer program product, comprising a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the steps of any one of the above-mentioned lens distortion correction methods are performed.

[0021] In a fifth aspect, the present invention also provides another lens distortion correction device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor runs the computer program, the steps of any one of the above-mentioned lens distortion correction methods are executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a flow chart of a lens distortion correction method in an embodiment of the present invention;

[0023] Figure 2 is a schematic diagram of the positional relationship between a mapping point p and its nearest neighboring pixel point in an embodiment of the present invention;

[0024] Figure 3 is a schematic diagram of a mapping point in a mixed color channel in an embodiment of the present invention;

[0025] Figure 4 is a schematic diagram of another mapping point in a mixed color channel in an embodiment of the present invention;

[0026] Figure 5 It is a structural schematic diagram of a lens distortion correction device in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] As described in the background technology, the traditional lens distortion correction solution for color images needs to perform lens distortion correction on the r channel, g channel and b channel respectively. The required computational effort and line cache are three times that of a single-channel image, resulting in large resource consumption and high power consumption.

[0028] In the embodiment of the present invention, the first color channel and the second color channel are compressed into a mixed color channel, the mixed color channel is subjected to lens distortion correction to obtain a corrected mixed color channel, and the corrected mixed color channel is decompressed to obtain a corrected first color channel and a corrected second color channel. Thus, when performing lens distortion correction, it is only necessary to perform lens distortion correction on the brightness channel and the mixed color channel. In other words, when performing lens distortion correction on a color image, it is only necessary to perform lens distortion correction operations on two channels (brightness channel and mixed color channel), so it is possible to effectively reduce the resources required for lens distortion correction and reduce power consumption.

[0029] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0030] The embodiment of the present invention provides a lens distortion correction method, referring to Figure 1 , the following is a detailed description through specific steps.

[0031] In a specific implementation, the lens distortion correction method described below can be performed by an image processing device in an image acquisition device (such as a camera), and the image processing device can also be referred to as a lens distortion correction device. The image processing device can be a chip with image processing capabilities, or a chip module with image processing capabilities.

[0032] Step 101: convert the color image to be processed from the RGB color space to the YCOCG color space, and obtain the brightness channel y, the first color channel co, and the second color channel cg corresponding to the color image to be processed.

[0033] In the embodiment of the present invention, the color image to be processed is the color image that currently needs to be corrected for lens distortion. In other words, the color image to be processed is the color image with lens distortion. In other words, the image to be processed is the original image captured by the camera, and the original image has lens distortion.

[0034] In a specific implementation, after obtaining the color image to be processed, the color image to be processed can be converted from the RGB color space to the YCOCG color space to obtain the brightness channel y, the first color channel and the second color channel corresponding to the color image to be processed. The first color channel is the chromaticity orange channel co, and the second color channel is the chromaticity green channel cg.

[0035] In a specific implementation, for the i-th pixel point p in the color image to be processed i , in the RGB color space, the corresponding red pixel value is r i , the green pixel value is g i , the blue pixel value is b i . Set pixel p i Convert from RGB color space to YCOCG color space. In YCOCG color space, the pixel point p i The corresponding brightness channel y i is: y i =(r i +2*g i +b i ) / 4, the corresponding co i For co i =(r i -b i ) / 2+2 n-1 , the corresponding cg i For cg i =(-r i +2*g i -b i ) / 4+2 n-1 ; Where n is the channel width.

[0036] By adopting the above conversion method from RGB color space to YCOCG color space, the conversion from RGB color space to YCOCG color space can be realized only by shifters and adders, without using multipliers. Compared with the traditional conversion from RGB color space to YCOCG color space, hardware resources can be saved.

[0037] In some embodiments, the value of n is 8, then the pixel point p i The corresponding co in the ycocg color space i =(r i -b i ) / 2+128, corresponding to cg i =(-r i +2*g i -b i ) / 4+128.

[0038] In some other embodiments, the value of n is 10, then the pixel point p i The corresponding co in the ycocg color space i =(r i -b i ) / 2+512, corresponding to cg i =(-r i +2*g i -b i ) / 4+512.

[0039] Step 102: compress the first color channel co and the second color channel cg into a mixed color channel.

[0040] In the embodiment of the present invention, the size of the mixed color channel is the same as the size of the first color channel co and the size of the second color channel cg.

[0041] In a specific implementation, the first color channel co can be downsampled by 1 / 2 in the horizontal direction to obtain a first downsampling result, and the first downsampling result can be used as the even column of the mixed color channel; and the second color channel cg can be downsampled by 1 / 2 to obtain a second downsampling result, and the second downsampling result can be used as the odd column of the mixed color channel.

[0042] Specifically, downsampling the first color channel co / the second color channel cg by 1 / 2 in the horizontal direction may refer to downsampling every other column of the first color channel co / the second color channel cg in the horizontal direction. Downsampling every other column of the first color channel co / the second color channel cg may refer to selecting only odd columns of the first color channel co / the second color channel cg; or selecting only even columns of the first color channel co / the second color channel cg.

[0043] For example, in the horizontal direction, the value of the first color channel co is 10010010, and the first down-sampling result obtained after 1 / 2 down-sampling is 0100.

[0044] In some embodiments, the numbering of each column of the mixed color channel starts from 0, and the even-numbered columns of the mixed color channel mentioned above may refer to the 0th column, the 2nd column, the 4th column, ... of the mixed color channel; the odd-numbered columns of the mixed color channel mentioned above may refer to the 1st column, the 3rd column, the 5th column, ... of the mixed color channel.

[0045] For example, in the horizontal direction, the value of the first color channel co is 10010010, and the value of the second color channel cg is 01110011. The first color channel co is downsampled by 1 / 2, and the first downsampling result is 0100; the second color channel cg is downsampled by 1 / 2, and the second downsampling result is 1101, and the obtained mixed color channel is 01110001.

[0046] In a specific implementation, the first down-sampling result may be used as an odd-numbered column of a mixed color channel, and the second down-sampling result may be used as an even-numbered column of a mixed color channel.

[0047] For example, in the horizontal direction, the value of the first color channel co is 10010010, and the value of the second color channel cg is 01110011. The first color channel co is downsampled by 1 / 2, and the first downsampling result is 0100; the second color channel cg is downsampled by 1 / 2, and the second downsampling result is 1101, so the obtained mixed color channel is 10110010.

[0048] In the embodiment of the present invention, before the first color channel co and the second color channel cg are respectively down-sampled by 1 / 2, the first color channel co and the second color channel cg may be respectively filtered in the horizontal direction. Thus, the first color channel co that is down-sampled by 1 / 2 has been filtered in the horizontal direction; and the second color channel cg that is down-sampled by 1 / 2 has also been filtered in the horizontal direction.

[0049] In some embodiments, the following filter kernel may be used to perform horizontal filtering on the first color channel co / the second color channel cg: kernel = [1, 4, 6, 4, 1] / 16. When the filter kernel is used, when the filter corresponding to the filter kernel is implemented in hardware, only a shifter and an adder are needed, without a multiplier.

[0050] Step 103, performing lens distortion correction on the brightness channel y to obtain a corrected brightness channel dst_y; and performing lens distortion correction on the mixed color channel to obtain a corrected mixed color channel.

[0051] In an embodiment of the present invention, lens distortion correction can be performed on the brightness channel y and the mixed color channel respectively, thereby obtaining a brightness channel after lens distortion correction (hereinafter referred to as the corrected brightness channel) dst_y and a mixed color channel after lens distortion correction (hereinafter referred to as the corrected mixed color channel) respectively.

[0052] In a specific implementation, for a pixel point p' with coordinates (x, y) in the target color image, there is a corresponding mapping point p in the color image to be processed, and the coordinates of the mapping point p are (x d ,y d ). The target color image is the color image obtained after the lens distortion correction is performed on the image to be processed. The values ​​of x and y are both integers, x d ,y d The value of x can be a floating point number or an integer. d ,y d The value of is a floating point number.

[0053] That is to say, corresponding to any pixel point in the target color image, there is a pixel point in the image to be processed that corresponds to it one by one.

[0054] In a specific implementation, a mapping relationship between each pixel in the target color image and the corresponding pixel in the image to be processed can be established in advance. Through the preset mapping relationship, the horizontal coordinate x corresponding to the mapping point p can be determined. d With the vertical coordinate y d Typically, the above mapping relationship can be represented by a coordinate mapping table.

[0055] Therefore, after obtaining the horizontal coordinate x and the vertical coordinate y of the pixel point p', the horizontal coordinate x of the pixel point p can be determined based on the preset coordinate mapping table. d With the vertical coordinate y d .

[0056] In a specific application, the above mapping relationship (i.e., coordinate mapping table) is associated with the parameters of the optical lens in the camera. When the camera intrinsic parameters and lens distortion parameters are known, the coordinate mapping table is generated as follows:

[0057] x'=x(1+k1*r 2 +k2*r 4 +k3*r 6 )+2*p1*x*y+p2(r 2 +2*x2 );

[0058] y'=y(1+k1*r 2 +k2*r 4 +k3*r 6 )+2*p1*x*y+p2(r 2 +2*y 2 );

[0059] x d =f x *x'+c x ;

[0060] y d =f y *y'+c y ;

[0061] In the above expression, r 2 =x 2 +y 2 ; x is the horizontal coordinate of the pixel point p' in the target color image, y is the vertical coordinate of the pixel point p', x d is the horizontal coordinate of the mapping point p, y d is the ordinate of the mapping point p; k1, k2, k3 are radial distortion coefficients, p1, p2 are tangential distortion coefficients, and the radial distortion coefficient and tangential distortion coefficient can be calculated by shooting the chessboard and the regression mean method; f x 、f y 、c x 、c y is the camera internal parameter, f x is the focal length in pixels in the x direction, f y is the focal length in pixels in the y direction, c x 、c y is the image center coordinate in pixels. The camera intrinsic parameters can also be calculated by shooting a chessboard or using the regression mean method.

[0062] By traversing each pixel in the target color image, the floating point coordinates on the corresponding image to be processed can be obtained, and finally a coordinate mapping table can be obtained.

[0063] It should be noted that the specific implementation process of establishing the mapping relationship (coordinate mapping table) can refer to the prior art. In the embodiment of the present invention, the process and principle of establishing the mapping relationship are not changed.

[0064] In the embodiment of the present invention, for any pixel point in the target color image, after determining its corresponding mapping point, a preset interpolation algorithm can be used to obtain the pixel value of the mapping point based on the pixel values ​​of several integer coordinates of the nearest neighbors of the mapping point, and then use it as the pixel value of the pixel point. After obtaining the pixel values ​​of all the pixels in the target color image, the target color image can be obtained.

[0065] In specific applications, pixel interpolation algorithms may include bilinear interpolation algorithm, bicubic interpolation algorithm, lanczos algorithm, etc., wherein the bilinear interpolation algorithm requires the pixel values ​​of 2×2 pixels of the nearest neighbor of the mapping point, the bicubic interpolation algorithm requires the pixel values ​​of 4×4 pixels of the nearest neighbor of the mapping point, and the lanczos algorithm requires the pixel values ​​of 6×6 pixels of the nearest neighbor of the mapping point or the pixel values ​​of 8×8 pixels of the nearest neighbor. Relatively speaking, the more the number of nearest neighbor pixels selected, the higher the interpolation effect. The above-mentioned interpolation algorithms can all be existing interpolation algorithms, and the specific calculation process and principle are known to those skilled in the art.

[0066] In a specific implementation, lens distortion correction can be performed on the brightness channel y and the mixed color channel respectively. Lens distortion correction is performed on the brightness channel y to obtain a corrected brightness channel dst_y; lens distortion correction is performed on the mixed color channel to obtain a corrected mixed color channel.

[0067] Taking bilinear interpolation as an example, determine the 4 nearest pixel points of the mapping point p in the image to be processed, and obtain the brightness values ​​of the 4 nearest pixel points. Based on the horizontal distance and vertical distance between the mapping point p and the 4 pixels and the brightness values ​​of the 4 nearest pixel points, the brightness value of the mapping point p is obtained, which is the brightness value of the pixel point p' in the target color image.

[0068] Reference Figure 2 , a schematic diagram of the positional relationship between a mapping point p and its nearest neighboring pixel point in an embodiment of the present invention is given.

[0069] Figure 2 In the figure, the intersection of the two dotted lines is the mapping point p. The two pixels closest to the mapping point p are obtained in the horizontal direction, and the two pixels closest to the mapping point p are obtained in the vertical direction. Thus, the pixels closest to the mapping point p include: 00 , pixel p 01 , pixel p 10 , pixel p 11 Pixel p 00 The brightness value is y 00 , pixel p 01 The brightness value is y 01 , pixel p 10The brightness value is y 10 , pixel p 11 The brightness value is y 11 In the vertical direction, the number of points closest to the mapping point is 2; in the horizontal direction,

[0070] Based on the horizontal distance and vertical distance between the mapping point p and the above four nearest neighboring pixels and the brightness values ​​of the above four nearest neighboring pixels, the brightness value corresponding to the mapping point p is obtained, that is, the brightness value of the pixel point p'.

[0071] In a specific implementation, when performing lens distortion correction on a mixed color channel, the nearest neighbor pixel point to the mapping point in the mixed color channel can be determined, and the nearest neighbor pixel points include: the N pixel points that are closest to the mapping point in the horizontal direction, and the N pixel points that are closest to the mapping point in the vertical direction. The co pixel value and cg pixel value of the nearest neighbor pixel point are obtained, and based on the horizontal distance and vertical distance between the mapping point and the nearest neighbor pixel point, the co pixel value of the nearest neighbor pixel point, and the cg pixel value of the nearest neighbor pixel point, the co pixel value and cg pixel value corresponding to the mapping point are obtained, which are the co pixel value and cg pixel value corresponding to the target pixel point.

[0072] Reference Figure 3 , a schematic diagram of a mapping point in a mixed color channel in an embodiment of the present invention is given.

[0073] Figure 3 In the mixed color channel, the cg pixels and the co pixels are spaced apart. If the bilinear interpolation method is used, the nearest neighbor pixels of the mapping point p include 2 cg pixels and 2 co pixels. In other words, the nearest neighbor pixels of the mapping point do not belong to the same color channel.

[0074] However, when the CG pixel value of the mapping point P is calculated by the interpolation algorithm, it is necessary to base it on the CG pixel value of the nearest neighbor pixel, but the nearest neighbor pixel includes the CO pixel. Correspondingly, when the CO pixel value of the mapping point P is calculated by the interpolation algorithm, it is necessary to base it on the CO pixel value of the nearest neighbor pixel, but the nearest neighbor pixel includes the CG pixel.

[0075] Therefore, it is necessary to determine the cg pixel value corresponding to the co pixel point and the co pixel value corresponding to the cg pixel point.

[0076] In the embodiment of the present invention, the co pixel value of the mapping point p can be obtained in the following manner: obtain the co pixel values ​​corresponding to the N pixels closest to the mapping point in the horizontal direction; if the i-th pixel among the N pixels closest to the mapping point is the cg pixel, then the co pixel value corresponding to the i-th pixel can be calculated as co i,j =(co i,j-1 +coi,j+1 ) / 2; among them, co i,j-1 is the pixel value of co of the pixel point co that is located to the left of the i-th pixel point in the horizontal direction and is closest to the i-th pixel point in the mixed color channel; i,j+1 is the pixel value of co of the pixel point co that is located to the right of the pixel point in the horizontal direction and is closest to the i-th pixel point in the mixed color channel;

[0077] The cg pixel value of the mapping point p can be obtained as follows: obtain the cg pixel values ​​corresponding to the N pixels closest to the mapping point in the horizontal direction; if the i-th pixel among the N pixels closest to the mapping point is the co pixel, then the cg pixel value corresponding to the i-th pixel can be calculated as cg i,j =(cg i,j-1 +cg i,j+1 ) / 2; where cg i,j-1 is the cg pixel value of the cg pixel point in the mixed color channel that is located to the left of the i-th pixel point in the horizontal direction and is closest to the i-th pixel point; cg i,j+1 is the cg pixel value of the cg pixel point which is located on the right side of the pixel point in the horizontal direction and is closest to the i-th pixel point in the mixed color channel.

[0078] In a specific implementation, N is associated with the interpolation algorithm. For example, if the bilinear interpolation algorithm is used, N=2; if the bicubic interpolation algorithm is used, N=4.

[0079] After obtaining the co pixel value and cg pixel value corresponding to the mapping point p, the co pixel value and cg pixel value corresponding to the target pixel are obtained. After obtaining the co pixel value and cg pixel value corresponding to all mapping points, the corrected mixed color channel can be obtained.

[0080] The following is an example to illustrate the correction of mixed color channels.

[0081] Reference Figure 4 , a schematic diagram of another mapping point in a mixed color channel in an embodiment of the present invention is given. Figure 4 In , the interpolation algorithm is the bilinear interpolation algorithm.

[0082] Figure 4 In the horizontal direction, the two pixels closest to the mapping point p are cg 11 With co 12 ; In the vertical direction, the two pixels closest to the mapping point p are cg 21 With cg 22 .

[0083] To calculate the pixel value of co at the mapping point p, we need to calculate the pixel value of the mapping point p and cg 11 The horizontal distance and vertical distance, mapping point p and co 12 The horizontal distance and vertical distance, mapping point p and cg 21 The horizontal distance and vertical distance, mapping point p and co 22 The horizontal and vertical distances of cg 11 The corresponding pixel value of co, cg 21 The corresponding co pixel value, where:

[0084] cg 11 The corresponding co pixel value is: co 11 =(co 10 +co 12 ) / 2;

[0085] cg 21 The corresponding co pixel value is: co 21 =(co 20 +co 22 ) / 2.

[0086] To calculate the cg pixel value of the mapping point p, you need to calculate the mapping point p and cg 11 The horizontal distance and vertical distance, mapping point p and co 12 The horizontal distance and vertical distance, mapping point p and cg 21 The horizontal distance and vertical distance, mapping point p and co 22 The horizontal and vertical distances, as well as the co 12 The corresponding cg pixel value, cg 22 The corresponding cg pixel value, where:

[0087] co 12 The corresponding cg pixel value is: cg 12 =(cg 11 +cg 13 ) / 2;

[0088] co 21 The corresponding cg pixel value is: cg 22 =(cg 21 +cg 23 ) / 2.

[0089] It is understandable that the number of nearest neighbor pixels is related to the interpolation algorithm. When calculating the CG pixel value corresponding to the above-mentioned CO pixel, if the bicubic interpolation algorithm is used, the number of nearest neighbor pixels is 4×4. When calculating the CO pixel value of the mapping point, it is necessary to calculate the CO pixel value of the CG pixel among the nearest neighbor pixels; when calculating the CG pixel value of the mapping point, it is necessary to calculate the CG value of the CO pixel among the nearest neighbor pixels.

[0090] By adopting the solution in step 103, the brightness values, co pixel values ​​and cg pixel values ​​corresponding to all mapping points can be obtained. Thus, the corrected brightness channel dst_y and the corrected mixed color channel are obtained.

[0091] Step 104 , decompressing the corrected mixed color channel to obtain a corrected first color channel dst_co and a corrected second color channel dst_cg.

[0092] In the embodiment of the present invention, after obtaining the corrected mixed color channel, the corrected mixed color channel may be decompressed to obtain the corrected first color channel dst_co and the corrected second color channel dst_cg.

[0093] Specifically, the even columns and odd columns of the corrected mixed color channel may be upsampled by a factor of 2 in the horizontal direction to obtain the corrected first color channel dst_co and the corrected second color channel dst_cg.

[0094] In a specific implementation, the decompression in step 104 corresponds to the compression in step 102 .

[0095] If in step 102, the first sampling result is used as the even column of the mixed color channel and the second sampling result is used as the odd column of the mixed color channel, then: the even column of the corrected mixed color channel is upsampled by 2 times, and the upsampled result is used as the corrected first color channel dst_co; the odd column of the corrected mixed color channel is upsampled by 2 times, and the upsampled result is used as the corrected second color channel dst_cg.

[0096] If in step 102, the first sampling result is used as the odd columns of the mixed color channel and the second sampling result is used as the even columns of the mixed color channel, then: the odd columns of the corrected mixed color channel are upsampled by 2 times, and the upsampled result is used as the corrected first color channel dst_co; the even columns of the corrected mixed color channel are upsampled by 2 times, and the upsampled result is used as the corrected second color channel dst_cg.

[0097] In a specific implementation, an existing 2x upsampling method can be used to upsample the even columns and odd columns of the corrected mixed color channel by 2x. Specifically, the 2x upsampling can be achieved by filling the odd columns with 0.

[0098] For example, for the following bit stream 01010101, after 2 times upsampling, the upsampling result is 0010001000100010.

[0099] Combination Figure 3 It can be seen that in the mixed color channel, the co pixels and the cg pixels are arranged alternately. If a solution similar to the lens distortion correction for the brightness channel y is adopted, the arrangement of the co pixels and the cg pixels in the corrected mixed channel is chaotic, and it is difficult to decompress the corrected mixed color channel to obtain the corrected first color channel dst_co and the corrected second color channel dst_cg.

[0100] The solution provided by the above embodiment of the present invention (see step 103 to step 104) is adopted to calculate the co pixel value of the cg pixel point in the nearest neighboring pixel point / the cg pixel value of the co pixel point. When calculating the co pixel value of the mapping point, it is based on the co pixel value of the nearest neighboring pixel point; when calculating the cg pixel value of the mapping point, it is based on the cg pixel value of the nearest neighboring pixel point. Thus, in the corrected mixed color channel obtained, the co pixels and the cg pixels are still arranged in an orderly manner at intervals. Then, the corrected mixed color channel is decompressed, and the corrected first color channel dst_co and the corrected second color channel dst_cg can be obtained by upsampling.

[0101] Step 105, convert dst_y, dst_co and dst_cg from the ycocg color space to the rgb color space to obtain a target color image.

[0102] In the embodiment of the present invention, after obtaining the corrected brightness channel dst_y, the corrected first color channel dst_co and the corrected second color channel dst_cg, the red pixel value corresponding to the i-th pixel point in the target color image can be determined as dst_r i =dst_y i +dst_co i -dst_cg i ; Determine the green pixel value dst_g corresponding to the i-th pixel in the target color image i For: dst_g i =dst_y i +dst_cg i -2 n-1 ; The blue pixel value dst_b corresponding to the i-th pixel in the target color image i For: dst_b i =dst_y i -(dst_co i -2 n-1 )-(dst_cg i -2 n-1 ), where n is the channel width.

[0103] By adopting the above conversion method from the YCOCG color space to the RGB color space, the conversion from the YCOCG color space to the RGB color space can be realized only by a shifter and an adder, without using a multiplier. Compared with the traditional conversion from the YCOCG color space to the RGB color space, hardware resources can be saved.

[0104] In summary, the first color channel and the second color channel are compressed into a mixed color channel, the mixed color channel is subjected to lens distortion correction to obtain a corrected mixed color channel, and the corrected mixed color channel is decompressed to obtain a corrected first color channel and a corrected second color channel. Therefore, when performing lens distortion correction, only the brightness channel and the mixed color channel need to be subjected to lens distortion correction, so that the resources required for lens distortion correction can be effectively reduced, and power consumption can be reduced.

[0105] Reference Figure 5 , a lens distortion correction device 50 in an embodiment of the present invention is provided, comprising: a first conversion unit 501, a compression unit 502, a distortion correction unit 503, a decompression unit 504 and a second conversion unit 505, wherein:

[0106] The first conversion unit 501 is used to convert the color image to be processed from the RGB color space to the YCOCG color space, and obtain the brightness channel y, the first color channel co and the second color channel cg corresponding to the color image to be processed;

[0107] A compression unit 502, used for compressing the co and the cg into a mixed color channel;

[0108] The distortion correction unit 503 is used to perform lens distortion correction on the y to obtain a corrected brightness channel dst_y; and perform lens distortion correction on the mixed color channel to obtain a corrected mixed color channel;

[0109] A decompression unit 504 is used to decompress the corrected mixed color channel to obtain a corrected first color channel dst_co and a corrected second color channel dst_cg;

[0110] The second conversion unit 505 is used to convert the dst_y, the dst_co and the dst_cg from the ycocg color space to the rgb color space to obtain a target color image.

[0111] In a specific implementation, the specific execution process of the first conversion unit 501, the compression unit 502, the distortion correction unit 503, the decompression unit 504 and the second conversion unit 505 can correspond to step 101 to step 105, which will not be repeated here.

[0112] In a specific implementation, each module / unit included in each device or product described in the above embodiments may be a software module / unit or a hardware module / unit, or may be partly a software module / unit and partly a hardware module / unit.

[0113] For example, for each device or product applied to or integrated in a chip, each module / unit contained therein may be implemented in the form of hardware such as circuits, or at least some of the modules / units may be implemented in the form of software programs, which run on a processor integrated inside the chip, and the remaining (if any) modules / units may be implemented in the form of hardware such as circuits; for each device or product applied to or integrated in a chip module, each module / unit contained therein may be implemented in the form of hardware such as circuits, and different modules / units may be located in the same component (such as a chip, circuit module, etc.) or different components of the chip module, or at least some of the modules / units may be implemented in the form of software programs. The element can be implemented in the form of a software program, which runs on a processor integrated inside the chip module, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits; for various devices and products applied to or integrated in the terminal, the various modules / units contained therein can be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component (for example, chip, circuit module, etc.) or in different components in the terminal, or, at least some modules / units can be implemented in the form of a software program, which runs on a processor integrated inside the terminal, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits.

[0114] An embodiment of the present invention further provides a computer-readable storage medium, which is a non-volatile storage medium or a non-transient storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the lens distortion correction method provided in any of the above embodiments are executed.

[0115] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the lens distortion correction method provided in any of the above embodiments when executed by a processor.

[0116] An embodiment of the present invention further provides another lens distortion correction device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor runs the computer program, the steps of the lens distortion correction method provided in any of the above embodiments are executed.

[0117] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the relevant hardware through a program, and the program may be stored in a computer-readable storage medium, which may include: ROM, RAM, disk or CD, etc.

[0118] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.

Claims

1. A lens distortion correction method, It is characterized in that include: Convert the color image to be processed from the rgb color space to the ycocg color space, and obtain the brightness channel y, the first color channel co, and the second color channel cg corresponding to the color image to be processed; Compressing the co and the cg into a mixed color channel; Performing lens distortion correction on the y to obtain a corrected brightness channel dst_y; and performing lens distortion correction on the mixed color channel to obtain a corrected mixed color channel; Decompressing the corrected mixed color channel to obtain a corrected first color channel dst_co and a corrected second color channel dst_cg; The dst_y, the dst_co, and the dst_cg are converted from the ycocg color space to the rgb color space to obtain a target color image.

2. The lens distortion correction method according to claim 1, It is characterized in that The performing lens distortion correction on the mixed color channel to obtain a corrected mixed color channel includes: Obtaining a mapping point of a target pixel point in the target color image in the mixed color channel; Determine the nearest neighbor pixel points in the mixed color channel, the nearest neighbor pixel points including: N pixel points that are closest to the mapping point in the horizontal direction, and M pixel points that are closest to the mapping point in the vertical direction; Obtain the co pixel value and cg pixel value of the nearest neighbor pixel; Based on the horizontal distance and vertical distance between the mapping point and the nearest neighbor pixel point, as well as the co pixel value and cg pixel value of the nearest neighbor pixel point, the co pixel value and cg pixel value corresponding to the target pixel point are determined.

3. The lens distortion correction method according to claim 2, It is characterized in that The obtaining of the co pixel value and the cg pixel value of the nearest neighbor pixel point includes: The co pixel value of the mapping point is obtained by: obtaining the co pixel values ​​corresponding to the N pixels closest to the mapping point; if the i-th pixel among the N pixels closest to the mapping point is the cg pixel, then the co pixel value of the i-th pixel is: co i,j =(co i,j-1 +co i,j+1 ) / 2; among them, co i,j-1 is the pixel value of co of the pixel point adjacent to the left of the i-th pixel point in the mixed color channel; i,j+1 is the pixel value of co of the pixel point adjacent to the right of the i-th pixel point in the mixed color channel; The cg pixel value of the mapping point is obtained by: obtaining the cg pixel values ​​corresponding to the N pixels closest to the mapping point; if the i-th pixel among the N pixels closest to the mapping point is the co pixel, then the cg pixel value of the i-th pixel is: cg i,j =(cg i,j-1 +cg i,j+1 ) / 2; where cg i,j-1 is the cg pixel value of the cg pixel point adjacent to the left side of the i-th pixel point in the mixed color channel; cg i,j+1 is the cg pixel value of the cg pixel point adjacent to the right of the i-th pixel point in the mixed color channel.

4. The lens distortion correction method according to claim 1, It is characterized in that The compressing the co and the cg into a mixed color channel comprises: In the horizontal direction, the co is downsampled by 1 / 2, and the first downsampling result is used as the even columns of the mixed color channel; and The cg is downsampled by 1 / 2, and the obtained second downsampling result is used as the odd columns of the mixed color channel.

5. The lens distortion correction method according to claim 4, It is characterized in that The decompressing the corrected mixed color channel comprises: In the horizontal direction, upsampling the even columns of the corrected mixed color channel by a factor of 2 to obtain the corrected first color channel; and The odd columns of the corrected mixed color channel are upsampled by a factor of 2 to obtain the corrected second color channel.

6. The lens distortion correction method according to claim 1, It is characterized in that The compressing the co and the cg into a mixed color channel comprises: In the horizontal direction, the co is downsampled by 1 / 2, and the obtained first downsampling result is used as the odd columns of the mixed color channel; and The cg is downsampled by 1 / 2, and the obtained second downsampling result is used as the even-numbered columns of the mixed color channel.

7. The lens distortion correction method according to claim 6, It is characterized in that The decompressing the corrected mixed color channel comprises: In the horizontal direction, upsampling the odd columns of the corrected mixed color channel by a factor of 2 to obtain the corrected first color channel; and The even columns of the corrected mixed color channel are upsampled by a factor of 2 to obtain the corrected second color channel.

8. The lens distortion correction method according to claim 1, It is characterized in that The step of converting the color image to be processed from the rgb color space to the ycocg color space comprises: In the color image to be processed, the y corresponding to the i-th pixel i is: y i =(r i +2*g i +b i ) / 4; the pixel point corresponding to co i For: i =(r i -b i ) / 2+2 n-1 ; The cg corresponding to the pixel i For: cg i =(-r i +2*g i -b i ) / 4+2 n-1 ; Among them, r i is the red pixel value corresponding to the i-th pixel point, g i is the green pixel value corresponding to the i-th pixel, b i is the blue pixel value corresponding to the i-th pixel point, and n is the channel width.

9. The lens distortion correction method according to claim 8, It is characterized in that The converting of the dst_y, dst_co and dst_cg from the ycocg color space to the rgb color space comprises: in the target color image, the red pixel value dst_r corresponding to the i-th pixel point i For: dst_r i =dst_y i +dst_co i -dst_cg i ; The green pixel value dst_g corresponding to the i-th pixel i For: dst_g i =dst_y i +dst_cg i -2 n-1 ; The blue pixel value dst_b corresponding to the i-th pixel i For: dst_b i =dst_y i -(dst_co i -2 n-1 )-(dst_cg i -2 n-1 ).

10. A lens distortion correction device, It is characterized in that include: A first conversion unit is used to convert the color image to be processed from the RGB color space to the YCOCG color space, and obtain the brightness channel y, the first color channel co and the second color channel cg corresponding to the color image to be processed; A compression unit, used for compressing the co and the cg into a mixed color channel; A distortion correction unit, configured to perform lens distortion correction on the y to obtain a corrected brightness channel dst_y; and perform lens distortion correction on the mixed color channel to obtain a corrected mixed color channel; A decompression unit, used for decompressing the corrected mixed color channel to obtain a corrected first color channel dst_co and a corrected second color channel dst_cg; The second conversion unit is used to convert the dst_y, the dst_co and the dst_cg from the ycocg color space to the rgb color space to obtain a target color image.

11. A computer-readable storage medium, wherein the computer-readable storage medium is a non-volatile storage medium or a non-transient storage medium, and a computer program is stored thereon. It is characterized in that When the computer program is executed by a processor, the steps of the lens distortion correction method according to any one of claims 1 to 9 are executed.

12. A computer program product comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the steps of the lens distortion correction method according to any one of claims 1 to 9 are implemented.

13. A lens distortion correction device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, It is characterized in that When the processor runs the computer program, the steps of the lens distortion correction method according to any one of claims 1 to 9 are performed.