Method and device for balancing image green channel

文档序号:738920 发布日期:2021-04-20 浏览:14次 中文

阅读说明:本技术 一种图像绿通道平衡的方法及装置 (Method and device for balancing image green channel ) 是由 朱俊玲 田景军 于 2020-12-22 设计创作,主要内容包括:本申请公开了一种图像处理方法及装置,该方法包括:获取Bayer图像,将Bayer图像划分为多个图像块,根据每个图像块中GR和GB的像素值计算每个图像块的像素绝对值Diffavg;对滑动窗中同通道绿像素点的像素值进行梯度计算得到图像梯度grad;根据对应的grad和Diffavg计算校正系数alpha;根据滑动窗中的同通道绿像素点和异通道绿像素点的像素值计算均值差值offset;根据alpha和offset对待校正的绿像素点进行绿通道平衡校正得到校正后的Bayer图像。通过本申请能解决现有方案中存在的相邻区域出现块效应、造成边界模糊及纹理丢失等问题。(The application discloses an image processing method and device, wherein the method comprises the following steps: acquiring a Bayer image, dividing the Bayer image into a plurality of image blocks, and calculating the pixel absolute value Diffavg of each image block according to the pixel values of GR and GB in each image block; carrying out gradient calculation on pixel values of green pixel points of the same channel in the sliding window to obtain an image gradient grad; calculating a correction coefficient alpha according to the corresponding grad and Diffavg; calculating an average value difference offset according to pixel values of the same-channel green pixel points and different-channel green pixel points in the sliding window; and carrying out green channel balance correction on the green pixel point to be corrected according to the alpha and the offset to obtain a corrected Bayer image. By the method and the device, the problems that adjacent areas in the existing scheme have blocking effects, cause fuzzy boundaries, lose textures and the like can be solved.)

1. A method for image green channel balancing, comprising:

acquiring a Bayer image through an image sensor;

dividing the Bayer image into a plurality of image blocks in an overlapping and crossing mode, and calculating pixel absolute values Diffavg of each image block according to pixel values of GR green pixel points and GB green pixel points in each image block;

performing gradient calculation on pixel values of same-channel green pixel points in a sliding window to obtain corresponding image gradient grad, wherein the sliding window slides in the Bayer image to search green pixel points in the Bayer image, and the same-channel green pixel points are green pixel points of the same type as the central point of the sliding window;

calculating a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block, and determining a green pixel point to be corrected in the sliding window;

calculating the mean difference value offset of green pixels in the sliding window according to the pixel values of the same-channel green pixels and the pixel values of different-channel green pixels in the sliding window, wherein the different-channel green pixels are green pixels of different types from the center point of the sliding window;

and correspondingly carrying out green channel balance correction on the green pixel point to be corrected according to the correction coefficient alpha and the mean difference value offset to obtain a corrected Bayer image.

2. The method according to claim 1, wherein the calculating an absolute pixel value Diffavg of each of the image blocks according to the pixel values of GR green pixel and GB green pixel in each of the image blocks comprises:

determining a target GR green pixel point and a target GB green pixel point which meet a preset condition in each image block, wherein the preset condition is that the absolute value of the difference value of the pixel values of the GR green pixel point and the GB green pixel point in each image block is greater than a preset threshold;

calculating a pixel mean value GRavg of GR green pixels in each image block according to the pixel values and the number of the target GR green pixels in each image block;

calculating a pixel mean value GBavg of a GB green pixel point in each image block according to the pixel value and the number of target GB green pixel points in each image block;

and calculating the pixel absolute value Diffavg of each image block according to the pixel mean value GRavg of the GR green pixel point in each image block and the pixel mean value GBavg of the GB green pixel point in each image block.

3. The method of claim 1, wherein the performing gradient calculation on pixel values of co-channel green pixels in a sliding window to obtain a corresponding image gradient grad comprises:

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point of the row where the central point is located to obtain a first gradient gradH;

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point in the row where the central point is located to obtain a second gradient gradV;

and calculating to obtain a corresponding image gradient grad according to the first gradient gradH and the second gradient gradV.

4. The method of claim 1, wherein said calculating the corresponding correction factor alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each of the image blocks comprises:

calculating a gradient weight alphaGrad according to the corresponding image gradient grad and a preset gradient curve function;

calculating a mean value weight alphaDiff according to the pixel absolute value Diffavg of each image block and a preset mean value curve function;

and calculating to obtain a corresponding correction coefficient alpha according to the gradient weight alphaGrad and the mean weight alphaDiff.

5. The method of claim 1, wherein calculating the mean difference value offset of the green pixels in the sliding window according to the pixel values of the co-channel green pixels and the pixel values of the inter-channel green pixels in the sliding window comprises:

calculating to obtain a pixel mean value Gname of the same-channel green pixel point according to the pixel value of the same-channel green pixel point in the sliding window;

calculating to obtain a pixel mean value Gref of the different-channel green pixel points according to pixel values of the different-channel green pixel points in the sliding window;

and calculating to obtain the mean difference value offset of the green pixel points in the sliding window according to the Gname and the Gref.

6. An apparatus for image green channel balancing, comprising:

the data input unit is used for acquiring a Bayer image through an image sensor;

the average value statistical unit is used for dividing the Bayer image into a plurality of image blocks in an overlapping and crossing mode, and calculating the pixel absolute value Diffavg of each image block according to the pixel values of GR green pixels and GB green pixels in each image block;

the gradient calculation unit is used for carrying out gradient calculation on pixel values of green pixels of the same channel in a sliding window to obtain a corresponding image gradient grad, wherein the sliding window slides in the Bayer image to search green pixels in the Bayer image, and the green pixels of the same channel are green pixels of the same type as the center point of the sliding window;

the weight calculation unit is used for calculating a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block, and determining green pixel points to be corrected in the sliding window;

a difference value calculating unit, configured to calculate a mean difference value offset of green pixel points in the sliding window according to a pixel value of a same-channel green pixel point and a pixel value of an different-channel green pixel point in the sliding window, where the different-channel green pixel point is a different type of green pixel point from the central point;

and the correction output unit is used for correspondingly performing green channel balance correction on the green pixel points to be corrected according to the correction coefficient alpha and the mean difference value offset to obtain corrected Bayer images.

7. The apparatus according to claim 6, wherein the mean statistic unit is specifically configured to:

determining a target GR green pixel point and a target GB green pixel point which meet a preset condition in each image block, wherein the preset condition is that the absolute value of the difference value of the pixel values of the GR green pixel point and the GB green pixel point in each image block is greater than a preset threshold;

calculating a pixel mean value GRavg of GR green pixels in each image block according to the pixel values and the number of the target GR green pixels in each image block;

calculating a pixel mean value GBavg of a GB green pixel point in each image block according to the pixel value and the number of target GB green pixel points in each image block;

and calculating the pixel absolute value Diffavg of each image block according to the pixel mean value GRavg of the GR green pixel point in each image block and the pixel mean value GBavg of the GB green pixel point in each image block.

8. The apparatus for image green channel balancing according to claim 6, wherein the gradient calculating unit is specifically configured to:

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point of the row where the central point is located to obtain a first gradient gradH;

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point in the row where the central point is located to obtain a second gradient gradV;

and calculating to obtain a corresponding image gradient grad according to the first gradient gradH and the second gradient gradV.

9. The apparatus according to claim 6, wherein the weight calculating unit is specifically configured to:

calculating a gradient weight alphaGrad according to the corresponding image gradient grad and a preset gradient curve function;

calculating a mean value weight alphaDiff according to the pixel absolute value Diffavg of each image block and a preset mean value curve function;

and calculating to obtain a corresponding correction coefficient alpha according to the gradient weight alphaGrad and the mean weight alphaDiff.

10. The apparatus according to claim 6, wherein the difference calculating unit is specifically configured to:

calculating to obtain a pixel mean value Gname of the same-channel green pixel point according to the pixel value of the same-channel green pixel point in the sliding window;

calculating to obtain a pixel mean value Gref of the different-channel green pixel points according to pixel values of the different-channel green pixel points in the sliding window;

and calculating to obtain the mean difference value offset of the green pixel points in the sliding window according to the Gname and the Gref.

Technical Field

The present application relates to the field of image processing technologies, and in particular, to a method and an apparatus for balancing an image green channel.

Background

Due to the self-defect of the imaging principle of the image sensor, the adjacent green channels GR and GB can generate different photosensitive intensities, namely green channel imbalance is generated. After color interpolation, a false texture is generated, which is usually represented as a grid in the image. In order to consider the image effect, the balance correction of a green channel is needed in the image acquisition and processing link.

The current schemes for balancing the green channel are mainly the following two. First, the average difference of the green channel in a certain area of the image is calculated, and then the green channel is balance-corrected by using the average difference. However, this scheme is statistically averaged in regions, which tends to cause blocking artifacts in neighboring regions in the image. Second, the balance correction is performed on the green channel by using the absolute value difference of the green channels adjacent to each other in the horizontal (or vertical) direction as a weight. However, this scheme is prone to blurring of image boundaries and loss of texture.

Therefore, a method for better balancing the image green channel is needed.

Disclosure of Invention

In order to overcome the defects of the prior art, the present application aims to provide a method and an apparatus for balancing an image green channel, which can solve the problems of block effect of adjacent areas, blurred image boundaries, texture loss and the like in the existing green channel balancing scheme.

To achieve the above and other objects, the present application provides a method for balancing an image green channel, comprising the steps of:

acquiring a Bayer image through an image sensor;

dividing the Bayer image into a plurality of image blocks in an overlapping and crossing mode, and calculating pixel absolute values Diffavg of each image block according to pixel values of GR green pixel points and GB green pixel points in each image block;

performing gradient calculation on pixel values of same-channel green pixel points in a sliding window to obtain corresponding image gradient grad, wherein the sliding window slides in the Bayer image to search green pixel points in the Bayer image, and the same-channel green pixel points are green pixel points of the same type as the central point of the sliding window;

calculating a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block, and determining a green pixel point to be corrected in the sliding window;

calculating the mean difference value offset of green pixels in the sliding window according to the pixel values of the same-channel green pixels and the pixel values of different-channel green pixels in the sliding window, wherein the different-channel green pixels are green pixels of different types from the center point of the sliding window;

and correspondingly carrying out green channel balance correction on the green pixel point to be corrected according to the correction coefficient alpha and the mean difference value offset to obtain a corrected Bayer image.

Optionally, the calculating an absolute value Diffavg of a pixel of each image block according to a pixel value of a GR green pixel and a pixel value of a GB green pixel in each image block includes:

determining a target GR green pixel point and a target GB green pixel point which meet a preset condition in each image block, wherein the preset condition is that the absolute value of the difference value of the pixel values of the GR green pixel point and the GB green pixel point in each image block is greater than a preset threshold;

calculating a pixel mean value GRavg of GR green pixels in each image block according to the pixel values and the number of the target GR green pixels in each image block;

calculating a pixel mean value GBavg of a GB green pixel point in each image block according to the pixel value and the number of target GB green pixel points in each image block;

and calculating the pixel absolute value Diffavg of each image block according to the pixel mean value GRavg of the GR green pixel point in each image block and the pixel mean value GBavg of the GB green pixel point in each image block.

Optionally, the performing gradient calculation on the pixel value of the green pixel point in the same channel in the sliding window to obtain a corresponding image gradient grad includes:

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point of the row where the central point is located to obtain a first gradient gradH;

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point in the row where the central point is located to obtain a second gradient gradV;

and calculating to obtain a corresponding image gradient grad according to the first gradient gradH and the second gradient gradV.

Optionally, the calculating a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block includes:

calculating a gradient weight alphaGrad according to the corresponding image gradient grad and a preset gradient curve function;

calculating a mean value weight alphaDiff according to the pixel absolute value Diffavg of each image block and a preset mean value curve function;

and calculating to obtain a correction coefficient alpha of the green pixel point to be corrected in the sliding window according to the gradient weight alphaGrad and the mean weight alphaDiff.

Optionally, the calculating a mean difference value offset of the green pixels in the sliding window according to the pixel values of the green pixels in the same channel and the green pixels in the different channel in the sliding window includes:

calculating to obtain a pixel mean value Gname of the same-channel green pixel point according to the pixel value of the same-channel green pixel point in the sliding window;

calculating to obtain a pixel mean value Gref of the different-channel green pixel points according to pixel values of the different-channel green pixel points in the sliding window;

and calculating to obtain the mean difference value offset of the green pixel points in the sliding window according to the Gname and the Gref.

To achieve the above and other objects, the present application also provides an apparatus for image green channel balancing, comprising:

the data input unit is used for acquiring a Bayer image through an image sensor;

the average value statistical unit is used for dividing the Bayer image into a plurality of image blocks in an overlapping and crossing mode, and calculating the pixel absolute value Diffavg of each image block according to the pixel values of GR green pixels and GB green pixels in each image block;

the gradient calculation unit is used for carrying out gradient calculation on pixel values of green pixels of the same channel in a sliding window to obtain a corresponding image gradient grad, wherein the sliding window slides in the Bayer image to search green pixels in the Bayer image, and the green pixels of the same channel are green pixels of the same type as the center point of the sliding window;

the weight calculation unit is used for calculating a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block, and determining green pixel points to be corrected in the sliding window;

a difference value calculating unit, configured to calculate a mean difference value offset of green pixel points in the sliding window according to a pixel value of a same-channel green pixel point and a pixel value of an different-channel green pixel point in the sliding window, where the different-channel green pixel point is a different type of green pixel point from the central point;

and the correction output unit is used for correspondingly performing green channel balance correction on the green pixel points to be corrected according to the correction coefficient alpha and the mean difference value offset to obtain corrected Bayer images.

Optionally, the mean statistical unit is specifically configured to:

determining a target GR green pixel point and a target GB green pixel point which meet a preset condition in each image block, wherein the preset condition is that the absolute value of the difference value of the pixel values of the GR green pixel point and the GB green pixel point in each image block is greater than a preset threshold;

calculating a pixel mean value GRavg of GR green pixels in each image block according to the pixel values and the number of the target GR green pixels in each image block;

calculating a pixel mean value GBavg of a GB green pixel point in each image block according to the pixel value and the number of target GB green pixel points in each image block;

and calculating the pixel absolute value Diffavg of each image block according to the pixel mean value GRavg of the GR green pixel point in each image block and the pixel mean value GBavg of the GB green pixel point in each image block.

Optionally, the gradient calculating unit is specifically configured to:

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point of the row where the central point is located to obtain a first gradient gradH;

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point in the row where the central point is located to obtain a second gradient gradV;

and calculating to obtain a corresponding image gradient grad according to the first gradient gradH and the second gradient gradV.

Optionally, the weight calculating unit is specifically configured to:

calculating a gradient weight alphaGrad according to the corresponding image gradient grad and a preset gradient curve function;

calculating a mean value weight alphaDiff according to the pixel absolute value Diffavg of each image block and a preset mean value curve function;

and calculating to obtain a corresponding correction coefficient alpha according to the gradient weight alphaGrad and the mean weight alphaDiff.

Optionally, the difference calculating unit is specifically configured to:

calculating to obtain a pixel mean value Gname of the same-channel green pixel point according to the pixel value of the same-channel green pixel point in the sliding window;

calculating to obtain a pixel mean value Gref of the different-channel green pixel points according to pixel values of the different-channel green pixel points in the sliding window;

and calculating to obtain the mean difference value offset of the green pixel points in the sliding window according to the Gname and the Gref.

It can be seen from the above that the present application provides a method and an apparatus for balancing an image green channel, which can achieve the following beneficial effects: the method can solve the problems of blocking effect of adjacent areas, image boundary blurring, texture loss and the like in the existing green channel balancing scheme, can also maximally protect image edge details while correcting the green channel of the image, and keeps the resolution of the image.

Drawings

Fig. 1 is a schematic flowchart of a method for balancing an image green channel according to an embodiment of the present disclosure.

Fig. 2 is a schematic view of a 5 × 5 sliding window provided in an embodiment of the present application.

Fig. 3 is a schematic representation of a preset gradient curve function provided in an embodiment of the present application.

Fig. 4 is a schematic representation of a preset mean curve function provided in an embodiment of the present application.

Fig. 5 is a schematic structural diagram of an apparatus for balancing an image green channel according to an embodiment of the present disclosure.

Detailed Description

Other advantages and effects of the present application will become apparent to those skilled in the art from the present disclosure, which is made apparent from the following detailed description of the embodiments given by way of example only and taken in conjunction with the accompanying drawings. The present application is capable of other and different embodiments and its several details are capable of modification in various other respects, all without departing from the spirit and scope of the present application.

In order to solve the above problems in the conventional image green channel balancing scheme, the present application provides another image green channel balancing method and apparatus. The image definition and the green channel balance are originally spear bodies, and the existing algorithm generally loses certain image resolution while solving the problem of image green channel imbalance, and needs to balance the relationship between the image definition and the green channel balance. The application provides a green channel balancing method based on a Bayer format image, and the method can be used for protecting the edge details of the image to the maximum extent and keeping the resolution of the image while correcting the green channel. In addition, the key of the green channel balance correction is to judge the green pixel point to be corrected in the sliding window (i.e. judge the correction area), and then correct the green pixel point by using a proper correction method. If the area judgment error or the correction method is not proper, the loss of the image resolution ratio is easily caused, and the image is blurred. Therefore, the present disclosure is directed to provide a method for determining a calibration area and calibrating a green channel of an image more accurately, thereby protecting the image boundary to the maximum and maintaining the image resolution.

Fig. 1 is a schematic flow chart illustrating a method for balancing an image green channel according to an embodiment of the present disclosure. The method as shown in fig. 1 comprises the following implementation steps.

And S101, acquiring a Bayer image through an image sensor.

The Bayer image is acquired through an image sensor, and the image is an image before color interpolation.

S102, dividing the Bayer image into a plurality of image blocks in an overlapping and crossing mode, and calculating pixel absolute values Diffavg of each image block according to pixel values of GR green pixel points and GB green pixel points in each image block.

The Bayer image can be divided into M x N image blocks in an overlapping and crossing mode. The division method can effectively avoid the image blocking effect when the adjacent two image blocks have an overlapping area of 1/a, such as 1/2 overlapping area. The size of each image block is blockW × blockH. Taking the adjacent image block overlap 1/2 as an example, blockW is 2 × Width/M; and (4) blocking H is 2 × Height/N. The size of the last column is: block W (block H/2); the size of the last row is (blockW/2) × blockH; wherein Width is the image Width and Height is the image Height.

As a possible implementation manner, the method may first determine a target GR green pixel point and a target GB green pixel point that satisfy a preset condition in each of the image blocks, where the preset condition is that an absolute value of a difference between a pixel value of the GR green pixel point and a pixel value of the GB green pixel point is greater than a certain preset threshold. Then calculating the pixel mean value GRavg of the GR green pixel points in each image block according to the pixel value of the GR green pixel points in each image block and the number of the GR green pixel points in each image block; calculating a pixel mean value GBavg of GB green pixels in each image block according to the pixel value of the target GB green pixels in each image block and the number of the target GB green pixels; and finally, calculating the pixel absolute value Diffavg of each image block according to the pixel mean value GRavg of the GR green pixel points in each image block and the pixel mean value GBavg of the GB green pixel points in each image block. Optionally, an absolute value of a difference between GRavg and GBavg is used as Diffavg, and a specific calculation formula thereof is shown in the following formula (1):

diffavg ═ GRavg-GBavg | equation (1)

The difference absolute value that satisfies GR, GB pixel value in this application will slide window is greater than the GR of certain predetermined threshold value, the green pixel point of GB, as the target GR that accords with the predetermined condition, the green pixel point of GB. Then, the pixel mean value of the GR and GB green pixels in each image block that meets the preset condition is counted according to the GR and GB green pixels of the target, and the pixel mean value corresponding to each image block is calculated specifically by using the following formula (2):

where GR is the pixel value of a GR green pixel, GB is the pixel value of a GB green pixel, Gorith1 is a certain threshold, and cnt is the number (or value of a counter).

It should be noted that, in the Bayer image of the present application, the green component (i.e., the green pixel point) adjacent to the red component in the horizontal direction is represented by GR, and the green component adjacent to the blue component in the horizontal direction is represented by GB.

S103, carrying out gradient calculation on pixel values of green pixels in the same channel in the sliding window to obtain a corresponding image gradient grad. The sliding window slides in the Bayer image to search green pixel points in the Bayer image, and the green pixel points in the same channel are green pixel points of the same type as the center point of the sliding window.

This application uses the sliding window to slide green pixel point one by one in the Bayer image, and wherein the central point of sliding window is the green pixel point of waiting for further definite waiting to rectify. The size of the sliding window is not limited, and the length and the width of the sliding window are both odd numbers, and can be the same value or different values, such as a sliding window of 5 × 5.

As a possible implementation manner, according to the pixel value of the green pixel point of the same channel of the row where the central point is located, performing gradient calculation on the sliding window to obtain a first gradient gradH (which may also be referred to as a horizontal direction gradient); and performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point in the row where the central point is located to obtain a second gradient gradV (also referred to as a vertical gradient). That is, the same-channel green pixel point where the center point is located in the row must participate in the calculation when calculating gradH, and the same-channel green pixel point where the center point is located in the column must participate in the calculation when calculating gradV. And then calculating to obtain a corresponding image gradient grad according to the first gradient gradH and the second gradient gradV. Optionally, the present application may take the maximum value of gradH and gradV as grad.

In a specific embodiment, the present application may accumulate absolute values of differences between respective pixel values of at least one same-channel pixel point located in different columns in the same row and a same-channel green pixel point located in a column where the center point is located in the same row according to a preset first ratio, and calculate a first gradient gradH. In other words, the absolute value of the difference between the green pixel point in the column where the same channel is located and the green pixel point in the same row corresponding to the column where the center point is located is obtained, and the difference is accumulated according to a certain proportion to obtain gradH.

The preset first ratio may be specifically set by a system user, or may be set according to user experience, and is not limited. In practical application, the value rule of the preset first proportion is as follows: the closer to the center row, the larger the preset first ratio value. When the preset first ratio is 1, gradH may be the sum of absolute differences between several columns of the same channel and the central column, or the sum of absolute differences between each column and the central column.

In another embodiment, the present application may add absolute difference values of pixel values of at least one co-channel pixel point located in different rows in the same column and a co-channel green pixel point of a row where the central point is located in the same column according to a preset second ratio, and calculate a second gradient gradV. In other words, the absolute value of the difference between the green pixel point in the row where the same channel is located and the green pixel point in the same column corresponding to the row where the center point is located is obtained, and the difference is accumulated according to a certain proportion to obtain gradV.

The preset second proportion may be specifically set by a system user, or may be set according to user experience, and is not limited. In practical application, the value rule of the preset second proportion is as follows: the closer to the central column, the larger the preset first ratio value. When the preset second ratio is 1, gradV may be the sum of absolute differences between several rows of the same channel and the central row, or the sum of absolute differences between each row and the central row.

For example, referring to fig. 2, a sliding window of 5 × 5 is shown, and the image gradient grad can be obtained by the following formula (3).

WhereinPreferably ω hi ω vi 1/8, i 1, 3, 4, 6.ω hi ω vi 1/4, i 2, 5.

S104, calculating a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block, and determining a green pixel point to be corrected in the sliding window.

As a possible implementation manner, the present application calculates a gradient weight alphaGrad according to the corresponding image gradient grad and a preset gradient curve function, calculates a mean weight alphaDiff according to a pixel absolute value Diffavg of each image block and a preset mean curve function, and finally calculates a corresponding correction coefficient alpha according to the gradient weight alphaGrad and the mean weight alphaDiff.

The gradient curve function is set by the system in a self-defining way, n1 thresholds can be set, and the gradient curve function has n1+1 broken lines, wherein n1 is greater than or equal to 2. Taking two thresholds DiffthL and DiffthH as examples, the gradient curve function is specifically shown in fig. 3. When Diffavg is less than or equal to threshold DiffthL, alphaDiff takes minimum value 0; alphaDiff takes a maximum value of 1 when Diffavg is greater than threshold DiffthH; alphaDiff ═ when Diffavg is in the middle of the two thresholds (Diffavg-diffhl)/(diffhhh-diffhl). Wherein DiffthL is less than or equal to DiffthH. It can be seen that the above-mentioned mean weight alphaDiff is calculated as shown in the following formula (4):

similar to the above-mentioned mean curve function, n2 thresholds can be set, and the mean curve function has n2+1 segments of broken lines, where n2 is greater than or equal to 2. Taking two thresholds gradthL and gradthH as examples, the corresponding mean curve function is specifically shown in FIG. 4, where DiffthL is less than or equal to DiffthH. When the gradient grad is less than or equal to the threshold gradthL, the alphagrad takes the maximum value of 1; when the gradient grad is larger than the threshold gradthH, the alphaGrad takes the minimum value of 0 so as to better protect the image edge details; when the gradient grad is intermediate the two thresholds, alphaGrad ═ gradth-grad)/(gradthH-gradthL). It can be seen that the gradient weight alphaGrad is calculated as shown in the following equation (5):

in one embodiment, the application takes the product of the gradient weight alphaGrad and the mean weight alphaDiff as the correction factor alpha, which is calculated as shown in equation (7):

alpha ═ alphaDiff × alphaGrad formula (7)

Understandably, the more thresholds are set in the curve function, the more accurate the balance correction of each threshold interval. Considering the calculation amount, an appropriate threshold value needs to be selected for balance correction. The experimental results show that the two threshold values are the best choice, and the final correction coefficient is the product of the mean weight and the gradient weight.

Further, the present application may also determine a calibration region (i.e. determine a green pixel to be calibrated in the sliding window) according to the grad and the Diffavg, and specifically may determine the calibration region by using the calibration coefficient alpha, for example, when the alpha value is larger, if the difference between the pixel value of the green pixel after alpha calibration and the pixel value before calibration is larger, it indicates that the green pixel is the green pixel to be calibrated in the sliding window. If the difference between the pixel value of the green pixel point after the alpha correction and the pixel value before the alpha correction is not large, the green pixel point is not required to be corrected, namely, the green pixel point to be corrected in the sliding window is not.

And S105, calculating the average difference value offset of the green pixel points in the sliding window according to the pixel values of the same-channel green pixel points and the pixel values of different-channel green pixel points in the sliding window. The same-channel green pixel points are green pixel points of the same type as the center point of the sliding window, and the different-channel green pixel points are green pixel points of different types from the center point of the sliding window.

As a possible implementation manner, calculating a pixel mean value Gsame of the co-channel green pixel point according to a pixel value of the co-channel green pixel point in the sliding window; calculating to obtain a pixel mean value Gref of the different-channel green pixel points according to the pixel values of the different-channel green pixel points in the sliding window; and calculating to obtain the mean difference value offset of the green pixel points in the sliding window according to the Gname and the Gref. Preferably, the mean difference offset is half the difference between Gref and Gsame. The calculation modes of the Gname and the Gref are not unique, and all pixel points of green pixel points of the same channel or different channels in the sliding window can participate in calculation, and part of the pixel points can also participate in calculation.

For example, referring to the example of the 5 × 5 sliding window shown in fig. 2, if the center point of the sliding window in fig. 2 is G (green) 7, and the pixels adjacent to the center point G7 are R pixels in the drawing, the green (G) pixels adjacent to the R pixels are the G pixels in the same channel; and the rest other G pixel points in the sliding window are different-channel G pixel points. Specifically, the same-channel green pixels in the sliding window in the figure are G6, G8, G1, G2, G3, G11, G12 and G13, and the different-channel green pixels are G4, G5, G9 and G10.

If all the same-channel G pixel points and different-channel G pixel points in the sliding window participate in calculation, the mean difference value offset is obtained through calculation according to the following formula (6).

Where Gi is the pixel value of the green pixel i, and i is 1, 2, 3 … 13.

Optionally, Gsame and Gref are not calculated uniquely. If part of the pixel points in the sliding window and the G pixel points in the channel participate in the Gsame calculation, taking the 5 × 5 sliding window shown in fig. 2 as an example, the Gsame calculation formula may be: gsame(G2+ G6+ G7+ G8+ G12)/5, or Gsame(G1+ G3+ G7+ G11+ G13)/5, or other similar calculation formula.

Similarly, if part of the different-channel G pixels in the sliding window participate in Gref calculation, taking the 5 × 5 sliding window shown in fig. 2 as an example, Gref may be calculated as: gref(G4+ G10)/, or Gref(G5+ G9)/, or other similar calculation formula.

S106, correspondingly carrying out green channel balance correction on the green pixel point to be corrected according to the correction coefficient alpha and the mean difference value offset to obtain a corrected Bayer image.

According to the method and the device, the correction coefficient alpha and the mean difference value offset are used for carrying out self-adaptive balance correction on the green channel to obtain a correction result. Specifically, the pixel value of the central point of the sliding window is subjected to balance correction by utilizing alpha and offset to obtain the pixel value of the central point after correction, and the green channel balance correction can be realized on each green pixel point to be corrected in the image according to the principle, so that the corrected Bayer image is obtained. The calculation formula is specifically shown in the following formula (8):

gout is given as Gin + offset x alpha formula (8)

Wherein Gin is the pixel value of the center point of the sliding window, i.e. the pixel value of the green pixel point to be corrected. Gout is the pixel value of the corrected center point.

By implementing the method and the device, the problems that adjacent areas in the existing green channel balance scheme have blocking effects, image boundary blurring and texture loss are caused can be solved, the image green channel is corrected, image edge details are protected to the maximum extent, and the image resolution is kept.

Fig. 5 is a schematic structural diagram of an image green channel balancing apparatus according to an embodiment of the present disclosure. The apparatus 500 shown in fig. 5 comprises:

a data input unit 501 for acquiring a Bayer image by an image sensor;

the mean value statistics unit 502 is configured to divide the Bayer image into a plurality of image blocks in an overlapping and crossing manner, and calculate a pixel absolute value Diffavg of each image block according to a pixel value of a GR green pixel and a pixel value of a GB green pixel in each image block;

the gradient calculation unit 503 is configured to perform gradient calculation on pixel values of green pixels in the same channel in the sliding window to obtain a corresponding image gradient grad; the sliding window slides in the Bayer image to search green pixel points in the Bayer image, and the green pixel points in the same channel are green pixel points of the same type as the center point of the sliding window;

a weight calculation unit 504, configured to calculate a corresponding correction coefficient alpha according to the corresponding image gradient grad and the pixel absolute value Diffavg of each image block, and determine a green pixel point to be corrected in the sliding window;

a difference value calculating unit 505, configured to calculate a mean difference value offset of green pixel points in the sliding window according to a pixel value of a same-channel green pixel point and a pixel value of an different-channel green pixel point in the sliding window, where the different-channel green pixel point is a different type of green pixel point from the central point;

and the correction output unit 506 is configured to perform green channel balance correction on the green pixel point to be corrected correspondingly according to the correction coefficient alpha and the mean difference offset, so as to obtain a corrected Bayer image.

Optionally, the mean statistical unit 502 is specifically configured to:

determining a target GR green pixel point and a target GB green pixel point which meet a preset condition in each image block, wherein the preset condition is that the absolute value of the difference value of the pixel values of the GR green pixel point and the GB green pixel point in each image block is greater than a preset threshold;

calculating a pixel mean value GRavg of GR green pixels in each image block according to the pixel values and the number of the target GR green pixels in each image block;

calculating a pixel mean value GBavg of a GB green pixel point in each image block according to the pixel value and the number of target GB green pixel points in each image block;

and calculating the pixel absolute value Diffavg of each image block according to the pixel mean value GRavg of the GR green pixel point in each image block and the pixel mean value GBavg of the GB green pixel point in each image block.

Optionally, the gradient calculating unit 503 is specifically configured to:

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point of the row where the central point is located to obtain a first gradient gradH;

performing gradient calculation on the sliding window according to the pixel value of the same-channel green pixel point in the row where the central point is located to obtain a second gradient gradV;

and calculating to obtain a corresponding image gradient grad according to the first gradient gradH and the second gradient gradV.

Optionally, the weight calculating unit 504 is specifically configured to:

calculating a gradient weight alphaGrad according to the corresponding image gradient grad and a preset gradient curve function;

calculating a mean value weight alphaDiff according to the pixel absolute value Diffavg of each image block and a preset mean value curve function;

and calculating to obtain a corresponding correction coefficient alpha according to the gradient weight alphaGrad and the mean weight alphaDiff.

Optionally, the difference calculating unit 505 is specifically configured to:

calculating to obtain a pixel mean value Gname of the same-channel green pixel point according to the pixel value of the same-channel green pixel point in the sliding window;

calculating to obtain a pixel mean value Gref of the different-channel green pixel points according to pixel values of the different-channel green pixel points in the sliding window;

and calculating to obtain the mean difference value offset of the green pixel points in the sliding window according to the Gname and the Gref.

By implementing the method and the device, the problems that adjacent areas in the existing green channel balance scheme have blocking effects, image boundary blurring and texture loss are caused can be solved, the image green channel is corrected, image edge details are protected to the maximum extent, and the image resolution is kept.

The above embodiments are merely illustrative of the principles and utilities of the present application and are not intended to limit the application. Modifications and variations can be made to the above-described embodiments by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be as set forth in the claims.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种便于虚拟现实对象控制的低延迟控制方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类