CN115760653A - Image correction method, device, equipment and readable storage medium - Google Patents

Image correction method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN115760653A
CN115760653A CN202310028630.9A CN202310028630A CN115760653A CN 115760653 A CN115760653 A CN 115760653A CN 202310028630 A CN202310028630 A CN 202310028630A CN 115760653 A CN115760653 A CN 115760653A
Authority
CN
China
Prior art keywords
image
gray value
calibration
detected
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202310028630.9A
Other languages
Chinese (zh)
Other versions
CN115760653B (en
Inventor
孙杰
张国栋
杨义禄
李波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Zhongdao Optoelectronic Equipment Co ltd
Original Assignee
Wuhan Zhongdao Optoelectronic Equipment Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Zhongdao Optoelectronic Equipment Co ltd filed Critical Wuhan Zhongdao Optoelectronic Equipment Co ltd
Priority to CN202310028630.9A priority Critical patent/CN115760653B/en
Publication of CN115760653A publication Critical patent/CN115760653A/en
Application granted granted Critical
Publication of CN115760653B publication Critical patent/CN115760653B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Processing (AREA)

Abstract

The invention provides an image correction method, an image correction device, image correction equipment and a readable storage medium. The method comprises the following steps: acquiring a black image and a plurality of calibration images; calculating a scaling coefficient of each pixel gray value in each calibration image; selecting a target first average gray value which is closest to a calculation result obtained by calculating based on a second average gray value and variance of pixel points in a bright area of the image to be detected from a plurality of first average gray values corresponding to the plurality of calibration images; and correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected. The invention solves the problem that the prior art can not obtain an accurate correction result when the difference between the absorption and reflection of a product to be detected on light and a calibrated object is large.

Description

Image correction method, device, equipment and readable storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an image correction method, an image correction apparatus, an image correction device, and a readable storage medium.
Background
Ideally, when a camera images a target with uniform brightness, the gray values of all the pixel points in the obtained image should be theoretically the same, however, in practice, the gray values of the pixel points in the image often have large differences.
At present, a flat field correction method is usually adopted to correct the gray value of each pixel point in an image, wherein the most common flat field correction method is a two-point correction method, that is, a scaling coefficient is obtained based on a calibration object with uniform gray level, and the gray value of each pixel point in the image is corrected through the scaling coefficient.
Disclosure of Invention
The invention mainly aims to provide an image correction method, an image correction device, image correction equipment and a readable storage medium, and aims to solve the problem that the prior art cannot obtain an accurate correction result when the absorption and reflection of a product to be detected to light and the absorption and reflection of a calibration object to light are different greatly.
In a first aspect, the present invention provides an image correction method, including:
acquiring a black image and a plurality of calibration images, wherein the black image is an image acquired when a camera lens is completely shielded, the calibration images are images of calibration objects with uniform gray levels acquired when the camera lens is not shielded under different preset illuminations, and the preset illuminations correspond to the calibration images one to one;
calculating a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel points in each calibration image;
determining a bright area of an image to be detected, and calculating a second average gray value of pixel points in the bright area and a variance of the gray values of the pixel points in the bright area;
calculating to obtain a calculation result based on the second average gray value and the variance;
selecting a target first average gray value closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, wherein the calibration images correspond to the first average gray values one to one;
and correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected.
Optionally, the step of calculating a scaling factor of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image, and the first average gray value of the pixel point in each calibration image includes:
respectively calculating the difference value of the gray value of each pixel point in each calibration image minus the gray value of each corresponding pixel point in the black image to obtain a plurality of difference values;
and calculating a quotient of dividing each difference value by the first average gray value of the pixel points in each calibration image, and taking each quotient as a scaling coefficient of the gray value of each corresponding pixel point in each calibration image.
Optionally, the step of determining the bright area of the image to be detected includes:
counting the gray value of each pixel point in the image to be detected to obtain a gray histogram;
determining the maximum gray value with the number larger than a threshold value corresponding to the gray value from the gray histogram as a target gray value;
and determining the area where the pixel points with the gray values larger than the target gray value in the image to be detected are located as a bright area.
Optionally, the step of obtaining a calculation result based on the second average gray-scale value and the variance includes:
and calculating the sum of the quotient of dividing the variance by 3 times of the second average gray value and the second average gray value to obtain a calculation result.
Optionally, the step of calibrating, based on the standard, the scaling factor of the gray value of each pixel in the image, the gray value of each pixel in the black image, and the gray value of each pixel in the image to be detected, to correct the image to be detected, so as to obtain a corrected image to be detected includes:
calculating the product of the gray value of each pixel point of the image to be detected and the scaling coefficient of the gray value of each corresponding pixel point in the standard calibration image;
and obtaining the gray value of each pixel point in the corrected image to be detected by utilizing the product and the gray value of each corresponding pixel point in the black image.
Optionally, after the step of obtaining the black image and the plurality of calibration images, the method includes:
and determining abnormal pixel points in each calibration image, and recording coordinates of the abnormal pixel points, wherein the pixel points with the gray values outside the preset gray value range are the abnormal pixel points.
Optionally, after the step of correcting the image to be detected based on the scaling coefficient of the gray value of each pixel in the standard calibration image, the gray value of each pixel in the black image, and the gray value of each pixel in the image to be detected by using the calibration image corresponding to the target first average gray value as the standard calibration image to obtain the corrected image to be detected, the method includes:
determining abnormal pixel points in the corrected image to be detected based on the coordinates of the abnormal pixel points in the standard calibration image, wherein the coordinates of the abnormal pixel points in the corrected image to be detected are the same as the coordinates of the abnormal pixel points in the standard calibration image;
respectively filtering the gray values of the abnormal pixel points in the corrected image to be detected based on N filters to obtain N new gray values corresponding to each abnormal pixel point in the corrected image to be detected, wherein N is a positive integer, and the window size of each filter is different;
and replacing the gray value of the abnormal pixel point in the corrected image to be detected with the mean value of the N new gray values corresponding to each abnormal pixel point in the corrected image to be detected.
In a second aspect, the present invention also provides an image correction apparatus comprising:
the camera comprises an acquisition module, a calibration module and a control module, wherein the acquisition module is used for acquiring a black image and a plurality of calibration images, the black image is acquired when a camera lens is completely shielded, the calibration images are acquired when the camera lens is not shielded under different preset illuminations, the gray levels of the calibration images are uniform, and the preset illuminations correspond to the calibration images one to one;
the first calculation module is used for calculating and obtaining a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel point in each calibration image;
the determining module is used for determining a bright area of the image to be detected and calculating a second average gray value of the pixels in the bright area and the variance of the gray values of the pixels in the bright area;
the second calculation module is used for calculating to obtain a calculation result based on the second average gray value and the variance;
the selecting module is used for selecting a target first average gray value which is closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, wherein the calibration images correspond to the first average gray values one by one;
and the correcting module is used for correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected by taking the calibration image corresponding to the target first average gray value as the standard calibration image to obtain the corrected image to be detected.
In a third aspect, the present invention also provides an image correction apparatus comprising a processor, a memory, and an image correction program stored on the memory and executable by the processor, wherein the image correction program, when executed by the processor, implements the steps of the image correction method as described above.
In a fourth aspect, the present invention also provides a readable storage medium, on which an image correction program is stored, wherein the image correction program, when executed by a processor, implements the steps of the image correction method as described above.
The method comprises the steps of obtaining a black image and a plurality of calibration images, wherein the black image is an image collected when a camera lens is completely shielded, the plurality of calibration images are images of calibration objects with uniform gray levels collected when the camera lens is not shielded under different preset illuminations, and the preset illuminations correspond to the calibration images one to one; calculating a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel point in each calibration image; determining a bright area of an image to be detected, and calculating a second average gray value of pixel points in the bright area and a variance of the gray values of the pixel points in the bright area; calculating to obtain a calculation result based on the second average gray value and the variance; selecting a target first average gray value closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, wherein the calibration images correspond to the first average gray values one to one; and correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected. According to the invention, the images of a plurality of calibration objects with different illumination absorption and reflection are simulated by using the images of the calibration objects under different preset illumination, then the standard calibration image corresponding to the target first average gray value closest to the calculation result is obtained by calculating based on the second average gray value and the variance of the pixel points in the bright area of the image to be detected, the standard calibration image is the image of the calibration object with the closest gray value to the illumination absorption and reflection of the image to be detected, and finally the calibration image is corrected based on the scaling coefficient of the gray value of each pixel point in the image of the calibration object with the closest gray value to the illumination absorption and reflection of the image to be detected, namely the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected, so that the problem that the gray value of each pixel point in the image cannot be corrected by correcting the scaling coefficient obtained based on the calibration object when the uniform gray value of the detection product has great difference between the absorption and reflection of the calibration object to the light and the absorption and reflection of the calibration object in the detection product can be detected in the prior art can be solved.
Drawings
Fig. 1 is a schematic diagram of a hardware configuration of an image correction apparatus according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of an image correction method according to the present invention;
FIG. 3 is a flowchart illustrating a second embodiment of an image correction method according to the present invention;
FIG. 4 is a flowchart illustrating a third embodiment of an image correction method according to the present invention;
FIG. 5 is a functional block diagram of an image correction apparatus according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In a first aspect, embodiments of the present invention provide an image correction apparatus, which may be an apparatus having a data processing function, such as a Personal Computer (PC), a notebook computer, or a server.
Referring to fig. 1, fig. 1 is a schematic diagram of a hardware structure of an image correction apparatus according to an embodiment of the present invention. In the embodiment of the present invention, the image correction apparatus may include a processor 1001 (e.g., a Central Processing Unit (CPU)), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used for implementing connection communication among the components; the user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard); the network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WI-FI interface, WI-FI interface); the memory 1005 may be a Random Access Memory (RAM) or a non-volatile memory (non-volatile memory), such as a magnetic disk memory, and the memory 1005 may optionally be a storage device independent of the processor 1001. Those skilled in the art will appreciate that the hardware configuration depicted in FIG. 1 is not intended to be limiting of the present invention, and may include more or less components than those shown, or some components in combination, or a different arrangement of components.
With continued reference to FIG. 1, the memory 1005 of FIG. 1, which is one type of computer storage medium, may include an operating system, a network communication module, a user interface module, and an image correction program. The processor 1001 may call an image correction program stored in the memory 1005, and execute the image correction method provided by the embodiment of the present invention.
In a second aspect, an embodiment of the present invention provides an image correction method.
In an embodiment, referring to fig. 2, fig. 2 is a flowchart illustrating an image correction method according to a first embodiment of the present invention. As shown in fig. 2, the image correction method includes:
step S10, acquiring a black image and a plurality of calibration images, wherein the black image is an image acquired when a camera lens is completely shielded, the calibration images are images of calibration objects with uniform gray levels acquired when the camera lens is not shielded under different preset illuminations, and the preset illuminations correspond to the calibration images one to one;
in this embodiment, a black image shot by the camera when the camera lens is completely shielded and calibration images of calibration objects with uniform gray levels acquired when the camera lens is not shielded under different preset illuminations are obtained, and it is easily conceivable that there are several calibration images with several preset illuminations, that is, the preset illuminations correspond to the calibration images one to one.
Step S20, calculating to obtain a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel points in each calibration image;
in this embodiment, the gray Value _ Offset of each pixel point in the black image, the gray Value _ Current of each pixel point in each calibration image, calculating to obtain the Average gray Value of the pixel points in each calibration image based on the gray Value of each pixel point in each calibration image, recording the Average gray Value of the pixel points in the calibration image as the first Average gray Value _ Average, based on the gray Value _ Offset of each pixel point in the black image, the gray Value _ Current of each pixel point in each calibration image, and the first Average gray Value _ Average of the pixel points in each calibration image, the scaling coefficient of the gray Value of each pixel point in each calibration image can be calculated. It is easy to think that there are several calibration images with several first average gray-scale values, i.e. the number of calibration images corresponds to the number of first average gray-scale values one to one.
Further, in an embodiment, the step S20 includes:
respectively calculating the difference value of the gray value of each pixel point in each calibration image minus the gray value of each corresponding pixel point in the black image to obtain a plurality of difference values;
and calculating a quotient of dividing each difference value by the first average gray value of the pixel points in each calibration image, and taking each quotient as a scaling coefficient of the gray value of each corresponding pixel point in each calibration image.
In this embodiment, to calibrateTaking 5 images as an example, the images are respectively a calibration image a, a calibration image B, a calibration image C, a calibration image D and a calibration image E, based on that a plurality of differences of the gray value of each pixel in the calibration image a minus the gray value of each pixel at the corresponding position in the black image are respectively divided by a first average gray value of the pixel in the calibration image a, the obtained quotient is a scaling coefficient of the gray value of each pixel corresponding to the calibration image a, that is, the pixel q in the first row and the first column in the black image is scaled by 1 Gray value of (2), pixel point a in first row and first column in calibration image A 1 Substituting the gray value of the image A and the first average gray value of the pixel points in the calibration image A into a formula
Figure 986131DEST_PATH_IMAGE001
And calculating to obtain a pixel point a in the calibration image A 1 The scaling factor is analogized by substituting the gray value of each pixel point in the black image, the gray value of each pixel point in the calibration image A and the first average gray value of the pixel points in the calibration image A into a formula respectively
Figure 78851DEST_PATH_IMAGE001
Then, by analogy, the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel point in each calibration image are respectively calculated by the above formula, and then the scaling coefficient of the gray value of each pixel point in each calibration image can be calculated. The gray Value of each pixel point in the black image is represented by Value _ Offset, the gray Value of each pixel point in each calibration image is represented by Value _ Current, the first Average gray Value of the pixel points in each calibration image is represented by Value _ Average, and the scaling coefficient of the gray Value of each corresponding pixel point in each calibration image is represented by scale.
Step S30, determining a bright area of an image to be detected, and calculating a second average gray value of pixel points in the bright area and a variance of the gray values of the pixel points in the bright area;
in this embodiment, an image to be detected of an article to be detected is obtained, and a bright area of the image to be detected is determined. Calculating to obtain the average gray value of the pixels in the bright area of the image to be detected based on the gray value of each pixel in the bright area of the image to be detected, and marking the average gray value of the pixels in the bright area of the image to be detected as a second average gray value
Figure 722060DEST_PATH_IMAGE002
And the variance of the gray value of the pixel points in the bright area of the image to be detected
Figure 632247DEST_PATH_IMAGE003
Further, in an embodiment, referring to fig. 3, fig. 3 is a flowchart illustrating an image correction method according to a second embodiment of the present invention. As shown in fig. 3, the step of determining the bright area of the image to be detected includes:
step S301, counting the gray value of each pixel point in an image to be detected to obtain a gray histogram;
step S302, determining the maximum gray value with the number larger than the threshold value corresponding to the gray value from the gray histogram as the target gray value;
step S303, determining the area where the pixel points with the gray value larger than the target gray value in the image to be detected are located as a bright area.
In this embodiment, the gray value of each pixel point in the image to be detected is counted to obtain a gray histogram, where a horizontal axis of the gray histogram represents the gray value, and a vertical axis of the gray histogram represents the number corresponding to each gray value.
And determining the maximum gray value in the gray value with the number larger than the threshold value from the gray histogram of the image to be detected as the target gray value. Taking the threshold as 5 as an example, if several peaks in the polygonal line gray level histogram are: and determining that the maximum gray value 220 in the gray values with the number larger than the threshold value is the target gray value if the number of the pixel points with the gray value of 50 is 3, the number of the pixel points with the gray value of 100 is 50, the number of the pixel points with the gray value of 150 is 60, the number of the pixel points with the gray value of 220 is 40, and the number of the pixel points with the gray value of 245 is 2.
Step S40, calculating to obtain a calculation result based on the second average gray value and the variance;
in this embodiment, the second average gray value of the pixel points in the bright area of the image to be detected is obtained
Figure 229582DEST_PATH_IMAGE002
And the variance of the gray value of the pixel points in the bright area of the image to be detected
Figure 860415DEST_PATH_IMAGE003
Then, based on the second average gray value of the pixel points in the bright area of the image to be detected
Figure 718649DEST_PATH_IMAGE002
And the variance of the gray value of the pixel points in the bright area of the image to be detected
Figure 675104DEST_PATH_IMAGE003
And calculating to obtain a calculation result.
Further, in an embodiment, step S40 includes:
and calculating the sum of the quotient of dividing the variance by 3 times of the second average gray value and the second average gray value to obtain a calculation result.
In this embodiment, based on the 3 sigma principle, the calculated variance of the gray value of the pixel point in the bright area of the image to be detected, which is 3 times as large as the sum of the quotient of the second average gray value of the pixel point in the bright area of the image to be detected and the second average gray value of the pixel point in the bright area of the image to be detected, is divided to obtain a calculation result. Namely, the second average gray value of the pixel points in the bright area of the image to be detected
Figure 258270DEST_PATH_IMAGE002
And the variance of the gray value of the pixel points in the bright area of the image to be detected
Figure 958372DEST_PATH_IMAGE003
Substituting into formula
Figure 936693DEST_PATH_IMAGE004
Obtaining a calculation result
Figure 532890DEST_PATH_IMAGE005
S50, selecting a target first average gray value closest to a calculation result from a plurality of first average gray values corresponding to a plurality of calibration images, wherein the calibration images correspond to the first average gray values one by one;
in this embodiment, since the number of the calibration images corresponds to the number of the first Average gray values one by one, if there are 5 calibration images, the result is selected and calculated from the 5 first Average gray values Value _ Average corresponding to the 5 calibration images
Figure 104817DEST_PATH_IMAGE005
The closest target first average gray value. It will be appreciated that the number of calibration images is provided herein by reference only, and not by limitation.
And S60, taking the calibration image corresponding to the target first average gray value as a standard calibration image, and correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected.
In this embodiment, each first average gray value has its corresponding calibration image, so after the target first average gray value is selected, the calibration image corresponding to the target first average gray value is used as a standard calibration image, and each pixel point at a corresponding position in the to-be-detected image is corrected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image, and the gray value of each pixel point in the to-be-detected image, so as to obtain the corrected to-be-detected image.
Further, in an embodiment, the calibrating, based on the standard, a scaling coefficient of a gray value of each pixel in the image, a gray value of each pixel in the black image, and a gray value of each pixel in the image to be detected to correct the image to be detected, so as to obtain a corrected image to be detected includes:
calculating the product of the gray value of each pixel point of the image to be detected and the scaling coefficient of the gray value of each corresponding pixel point in the standard calibration image;
and obtaining the gray value of each pixel point in the corrected image to be detected by using the product and the gray value of each corresponding pixel point in the black image.
In this embodiment, the gray value of the pixel a in the first row and the second row in the image to be detected is multiplied by the pixel a in the first row and the second row in the standard calibration image
Figure 467665DEST_PATH_IMAGE006
Based on the product of scaling factors
Figure 939973DEST_PATH_IMAGE007
Adding the first row and the second column of pixel points in the black image
Figure 972651DEST_PATH_IMAGE008
The gray value of the first row and the second row of the pixel points a in the image to be detected is corrected, namely the gray value of the first row and the second row of the pixel points a in the image to be detected and the gray value of the first row and the second row of the pixel points a in the standard calibration image are obtained
Figure 31874DEST_PATH_IMAGE006
The scaling factor and the pixel points of the first row and the second column in the black image
Figure 932833DEST_PATH_IMAGE008
Is substituted into the formula
Figure 495533DEST_PATH_IMAGE009
And calculating to obtain the gray value of the pixel points a in the first row and the second row in the corrected image to be detected. Wherein, the first and the second end of the pipe are connected with each other,
Figure 463227DEST_PATH_IMAGE010
expressing the gray value of the pixel point a of the first row and the second row in the corrected image to be detected,
Figure 868800DEST_PATH_IMAGE011
representing the gray value of the pixel point a of the first row and the second column in the image to be detected,
Figure 714396DEST_PATH_IMAGE012
pixel point for expressing first row and second column in standard calibration image
Figure 397182DEST_PATH_IMAGE006
The scaling factor of the gray-value of (b),
Figure 37242DEST_PATH_IMAGE013
pixel point for representing first row and second column in black image
Figure 664532DEST_PATH_IMAGE008
Of the gray scale value of (a). By analogy, the gray value of each pixel point of the image to be detected, the scaling factor of the gray value of each corresponding pixel point in the standard calibration image and the gray value of each corresponding pixel point in the black image are respectively substituted into a formula
Figure 546775DEST_PATH_IMAGE014
And obtaining the gray value of each pixel point in the corrected image to be detected.
In the embodiment, a black image and a plurality of calibration images are obtained, wherein the black image is an image acquired when a camera lens is completely shielded, the plurality of calibration images are images of calibration objects with uniform gray levels acquired when the camera lens is not shielded under different preset illuminations, and the preset illuminations correspond to the calibration images one to one; calculating a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel points in each calibration image; determining a bright area of an image to be detected, and calculating a second average gray value of pixel points in the bright area and a variance of the gray values of the pixel points in the bright area; calculating to obtain a calculation result based on the second average gray value and the variance; selecting a target first average gray value closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, wherein the calibration images correspond to the first average gray values one to one; and correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected. According to the embodiment, the images of the calibration objects with different absorption and reflection of illumination and uniform gray levels are simulated by using the images of the calibration objects under different preset illumination, the standard calibration image corresponding to the target first average gray level closest to the calculation result is obtained by calculating the second average gray level and the variance of the pixel points in the bright area of the image to be detected, the standard calibration image is the image of the calibration object with uniform gray levels closest to the absorption and reflection of illumination of the image to be detected, and the calibration image is corrected based on the scaling coefficients of the gray levels of the pixel points in the image of the calibration object with uniform gray levels closest to the absorption and reflection of illumination of the image to be detected, namely the scaling coefficient of the gray level of each pixel point in the standard calibration image, the gray level of each pixel point in the black image and the gray level of each pixel point in the calibration image to be detected.
Further, in an embodiment, referring to fig. 4, fig. 4 is a schematic flowchart of an image correction method according to a third embodiment of the present invention. As shown in fig. 4, after the step of acquiring the black image and the plurality of calibration images, the method includes:
step S70, determining abnormal pixel points in each calibration image, and recording coordinates of the abnormal pixel points, wherein the pixel points with the gray values outside the preset gray value range are the abnormal pixel points.
In this embodiment, the gray values of the pixels in each calibration image are respectively detected, and if there is a pixel with a gray value outside the preset gray value range, the pixel with a gray value outside the preset gray value range is an abnormal pixel. And after the abnormal pixel points in each calibration image are determined, recording the coordinates of the abnormal pixel points in the calibration image. It should be noted that step S70 may be executed after step S10, and may also be executed after step S60, and step S70 is executed before step S80.
Further, in an embodiment, with continued reference to fig. 4, after step S60, the method includes:
step S80, determining abnormal pixel points in the corrected image to be detected based on the coordinates of the abnormal pixel points in the standard calibration image, wherein the coordinates of the abnormal pixel points in the corrected image to be detected are the same as the coordinates of the abnormal pixel points in the standard calibration image;
s90, respectively filtering the gray values of the abnormal pixel points in the corrected image to be detected based on N filters to obtain N new gray values corresponding to each abnormal pixel point in the corrected image to be detected, wherein N is a positive integer, and the window size of each filter is different;
and step S110, replacing the gray value of the abnormal pixel point in the corrected image to be detected with the mean value of N new gray values corresponding to each abnormal pixel point in the corrected image to be detected.
In this embodiment, taking the window sizes of 3,3 filters of N as 3 × 3,5 × 5,7 × 7, and the coordinates of the abnormal pixel points in the standard calibration image as (0, 1), (10, 3), and (15, 20), for example, after the coordinates of the abnormal pixel points in each calibration image are recorded, the abnormal pixel points of the pixel points at the corresponding positions in the corrected image to be detected are determined according to the positions of the abnormal pixel points in the standard calibration image, that is, if the coordinates of the abnormal pixel points in the standard calibration image are (0, 1), (10, 3), and (15, 20), the 3 pixel points of the corrected image to be detected having the coordinates of (0, 1), (10, 3), and (15, 20) are also abnormal pixel points, that is, the coordinates of the abnormal pixel points in the corrected image to be detected are the same as the coordinates of the abnormal pixel points in the standard calibration image.
Based on the 3 filters, gaussian filtering is respectively performed on the gray values of the 3 abnormal pixel points with the coordinates (0, 1), (10, 3) and (15, 20) in the corrected image to be detected, and after filtering, the corrected abnormal pixel points with the coordinates (0, 1), (10, 3) and (15, 20) in the image to be detected all correspond to 3 new gray values. It is easy to think that, can also use other filtering methods to the gray value of the abnormal pixel in the corrected image to be detected to filter. Replacing the gray value of the corrected abnormal pixel point with the mean value of 3 new gray values corresponding to the abnormal pixel point with the coordinate of (0, 1) in the corrected image to be detected, replacing the coordinate of (10, 3) in the corrected image to be detected with the mean value of 3 new gray values corresponding to the abnormal pixel point with the coordinate of (10, 3) in the corrected image to be detected, and replacing the coordinate of (15, 20) in the corrected image to be detected with the mean value of 3 new gray values corresponding to the abnormal pixel point with the coordinate of (15, 20) in the corrected image to be detected. The gray values of abnormal pixel points in the corrected image to be detected are filtered through N filters respectively, the gray values of the abnormal pixel points in the corrected image to be detected are replaced by the mean value of N new gray values corresponding to each abnormal pixel point in the corrected image to be detected, the correction of the gray values of the abnormal pixel points in the corrected image to be detected is completed, and the probability that the gray values of the pixel points at corresponding positions in the corrected image to be detected are inaccurate due to the abnormal pixel points existing in a standard calibration image when the image to be detected is corrected is reduced.
In a third aspect, an embodiment of the present invention further provides an image correction apparatus.
In an embodiment, referring to fig. 5, fig. 5 is a functional module schematic diagram of an embodiment of an image correction apparatus according to the present invention. As shown in fig. 5, the image correction apparatus includes:
the system comprises an acquisition module 10, a calibration module and a control module, wherein the acquisition module is used for acquiring a black image and a plurality of calibration images, the black image is acquired when a camera lens is completely shielded, the calibration images are acquired when the camera lens is not shielded under different preset illuminations, the gray levels of the calibration images are uniform, and the preset illuminations correspond to the calibration images one to one;
the first calculation module 20 is configured to calculate a scaling factor of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image, and the first average gray value of the pixel point in each calibration image;
the determining module 30 is configured to determine a bright area of the image to be detected, and calculate a second average gray value of the pixel points in the bright area and a variance of the gray values of the pixel points in the bright area;
a second calculating module 40, configured to calculate a calculation result based on the second average gray-scale value and the variance;
a selecting module 50, configured to select a target first average gray value closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, where the calibration images correspond to the first average gray values one to one;
the correcting module 60 is configured to correct the image to be detected based on the scaling coefficient of the gray value of each pixel in the standard calibration image, the gray value of each pixel in the black image, and the gray value of each pixel in the image to be detected, by using the calibration image corresponding to the target first average gray value as the standard calibration image, to obtain the corrected image to be detected.
Further, in an embodiment, the first calculating module 20 is configured to:
respectively calculating the difference value of the gray value of each pixel point in each calibration image minus the gray value of each corresponding pixel point in the black image to obtain a plurality of difference values;
and calculating a quotient of dividing each difference value by the first average gray value of the pixel points in each calibration image, and taking each quotient as a scaling coefficient of the gray value of each corresponding pixel point in each calibration image.
Further, in an embodiment, the determining module 30 is configured to:
counting the gray value of each pixel point in the image to be detected to obtain a gray histogram;
determining the maximum gray value with the number larger than a threshold value corresponding to the gray value from the gray histogram as a target gray value;
and determining the area where the pixel points with the gray values larger than the target gray value in the image to be detected are located as a bright area.
Further, in an embodiment, the second calculating module 40 is configured to:
and calculating the sum of the quotient of dividing the variance by 3 times of the second average gray value and the second average gray value to obtain a calculation result.
Further, in an embodiment, the correcting module 60 is configured to:
calculating the product of the gray value of each pixel point of the image to be detected and the scaling coefficient of the gray value of each corresponding pixel point in the standard calibration image;
and obtaining the gray value of each pixel point in the corrected image to be detected by using the product and the gray value of each corresponding pixel point in the black image.
Further, in an embodiment, the determining module 30 is further configured to:
and determining abnormal pixel points in each calibration image, and recording coordinates of the abnormal pixel points, wherein the pixel points with the gray values outside the preset gray value range are the abnormal pixel points.
Further, in an embodiment, the correcting module 60 is further configured to:
determining abnormal pixel points in the corrected image to be detected based on coordinates of the abnormal pixel points in the standard calibration image, wherein the coordinates of the abnormal pixel points in the corrected image to be detected are the same as the coordinates of the abnormal pixel points in the standard calibration image;
respectively filtering the gray values of the abnormal pixel points in the corrected image to be detected based on N filters to obtain N new gray values corresponding to each abnormal pixel point in the corrected image to be detected, wherein N is a positive integer, and the window size of each filter is different;
and replacing the gray value of the abnormal pixel point in the corrected image to be detected with the mean value of the N new gray values corresponding to each abnormal pixel point in the corrected image to be detected.
The function implementation of each module in the image correction device corresponds to each step in the image correction method embodiment, and the function and implementation process thereof are not described in detail herein.
In a fourth aspect, an embodiment of the present invention further provides a readable storage medium.
The readable storage medium of the present invention stores an image correction program, wherein the image correction program, when executed by a processor, implements the steps of the image correction method as described above.
The method for implementing the image correction program when executed may refer to various embodiments of the image correction method of the present invention, and will not be described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for causing a terminal device to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. An image correction method, characterized in that the image correction method comprises:
acquiring a black image and a plurality of calibration images, wherein the black image is an image acquired when a camera lens is completely shielded, the plurality of calibration images are images of calibration objects with uniform gray levels acquired when the camera lens is not shielded under different preset illuminations, and the preset illuminations correspond to the calibration images one to one;
calculating a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel point in each calibration image;
determining a bright area of an image to be detected, and calculating a second average gray value of pixel points in the bright area and a variance of the gray values of the pixel points in the bright area;
calculating to obtain a calculation result based on the second average gray value and the variance;
selecting a target first average gray value closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, wherein the calibration images correspond to the first average gray values one to one;
and correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected.
2. The image correction method of claim 1, wherein the step of calculating the scaling factor of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel point in each calibration image comprises:
respectively calculating the difference value of the gray value of each pixel point in each calibration image minus the gray value of each corresponding pixel point in the black image to obtain a plurality of difference values;
and calculating a quotient of dividing each difference value by the first average gray value of the pixel points in each calibration image, and taking each quotient as a scaling coefficient of the gray value of each corresponding pixel point in each calibration image.
3. The image correction method according to claim 1, wherein the step of determining the bright area of the image to be detected includes:
counting the gray value of each pixel point in the image to be detected to obtain a gray histogram;
determining the maximum gray value with the number larger than a threshold value corresponding to the gray value from the gray histogram as a target gray value;
and determining the area where the pixel points with the gray values larger than the target gray value in the image to be detected are located as a bright area.
4. The image correction method according to claim 1, wherein the step of obtaining a calculation result based on the second average gradation value and the variance calculation includes:
and calculating the sum of the quotient of dividing the variance by 3 times of the second average gray value and the second average gray value to obtain a calculation result.
5. The image correction method according to claim 1, wherein the step of correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image, and the gray value of each pixel point in the image to be detected to obtain the corrected image to be detected comprises:
calculating the product of the gray value of each pixel point of the image to be detected and the scaling coefficient of the gray value of each corresponding pixel point in the standard calibration image;
and obtaining the gray value of each pixel point in the corrected image to be detected by using the product and the gray value of each corresponding pixel point in the black image.
6. The image correction method according to claim 1, wherein after the step of acquiring the black image and the plurality of calibration images, the method comprises:
and determining abnormal pixel points in each calibration image, and recording coordinates of the abnormal pixel points, wherein the pixel points with the gray values outside the preset gray value range are the abnormal pixel points.
7. The image correction method according to claim 6, wherein after the step of correcting the image to be detected based on the scaling factor of the gray value of each pixel in the standard calibration image, the gray value of each pixel in the black image, and the gray value of each pixel in the image to be detected by using the calibration image corresponding to the target first average gray value as the standard calibration image to obtain the corrected image to be detected, the method comprises:
determining abnormal pixel points in the corrected image to be detected based on coordinates of the abnormal pixel points in the standard calibration image, wherein the coordinates of the abnormal pixel points in the corrected image to be detected are the same as the coordinates of the abnormal pixel points in the standard calibration image;
respectively filtering the gray values of the abnormal pixel points in the corrected image to be detected based on N filters to obtain N new gray values corresponding to each abnormal pixel point in the corrected image to be detected, wherein N is a positive integer, and the window size of each filter is different;
and replacing the gray values of the abnormal pixel points in the corrected image to be detected with the mean value of the N new gray values corresponding to each abnormal pixel point in the corrected image to be detected.
8. An image correction apparatus characterized by comprising:
the camera comprises an acquisition module, a display module and a control module, wherein the acquisition module is used for acquiring a black image and a plurality of calibration images, the black image is an image acquired when a camera lens is completely shielded, the calibration images are images of calibration objects with uniform gray levels acquired when the camera lens is not shielded under different preset illuminations, and the preset illuminations correspond to the calibration images one to one;
the first calculation module is used for calculating and obtaining a scaling coefficient of the gray value of each pixel point in each calibration image based on the gray value of each pixel point in the black image, the gray value of each pixel point in each calibration image and the first average gray value of the pixel point in each calibration image;
the determining module is used for determining a bright area of the image to be detected and calculating a second average gray value of the pixels in the bright area and the variance of the gray values of the pixels in the bright area;
the second calculation module is used for calculating to obtain a calculation result based on the second average gray value and the variance;
the selecting module is used for selecting a target first average gray value which is closest to the calculation result from a plurality of first average gray values corresponding to the plurality of calibration images, wherein the calibration images correspond to the first average gray values one by one;
and the correcting module is used for correcting the image to be detected based on the scaling coefficient of the gray value of each pixel point in the standard calibration image, the gray value of each pixel point in the black image and the gray value of each pixel point in the image to be detected by taking the calibration image corresponding to the target first average gray value as the standard calibration image to obtain the corrected image to be detected.
9. An image correction apparatus, characterized in that the image correction apparatus comprises a processor, a memory, and an image correction program stored on the memory and executable by the processor, wherein the image correction program, when executed by the processor, implements the steps of the image correction method according to any one of claims 1 to 7.
10. A readable storage medium having an image correction program stored thereon, wherein the image correction program, when executed by a processor, implements the steps of the image correction method of any one of claims 1 to 7.
CN202310028630.9A 2023-01-09 2023-01-09 Image correction method, device, equipment and readable storage medium Active CN115760653B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310028630.9A CN115760653B (en) 2023-01-09 2023-01-09 Image correction method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310028630.9A CN115760653B (en) 2023-01-09 2023-01-09 Image correction method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN115760653A true CN115760653A (en) 2023-03-07
CN115760653B CN115760653B (en) 2023-05-09

Family

ID=85348735

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310028630.9A Active CN115760653B (en) 2023-01-09 2023-01-09 Image correction method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115760653B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116630433A (en) * 2023-04-24 2023-08-22 理工特智科技(重庆)有限公司 Full-scale blackness film image digitizing method, system, equipment and medium

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002077616A (en) * 2000-08-31 2002-03-15 Canon Inc Image processing method and apparatus, and recording medium
US20090322892A1 (en) * 2008-06-25 2009-12-31 Micron Technology, Inc. Method and apparatus for calibrating and correcting shading non-uniformity of camera systems
JP2010166143A (en) * 2009-01-13 2010-07-29 Ricoh Co Ltd Image processing apparatus, image processing method, program, and recording medium
CN104680489A (en) * 2015-02-11 2015-06-03 深圳怡化电脑股份有限公司 Image correcting method and system
CN105631819A (en) * 2015-12-25 2016-06-01 深圳市安健科技股份有限公司 Flat-field correction method and system of CCD DR detector
CN106840387A (en) * 2016-12-09 2017-06-13 中国科学院国家天文台 The Objective extraction and flat field correction method of a kind of larger imaging system of gain difference
CN107197122A (en) * 2017-06-12 2017-09-22 武汉中导光电设备有限公司 A kind of method for correcting flat field being imaged for area array cameras
CN107255521A (en) * 2017-06-28 2017-10-17 华中科技大学鄂州工业技术研究院 A kind of Infrared Image Non-uniformity Correction method and system
CN108088845A (en) * 2017-12-07 2018-05-29 武汉精测电子集团股份有限公司 A kind of image-forming correction method and device retained based on Weak Information
CN109934875A (en) * 2017-12-18 2019-06-25 长光华大基因测序设备(长春)有限公司 Camera calibration peace field correction apparatus, camera calibration method and method for correcting flat field
CN111383280A (en) * 2018-12-29 2020-07-07 中国科学院长春光学精密机械与物理研究所 Spatial remote sensing TDICCD camera non-uniformity correction method and device
CN113808046A (en) * 2021-09-18 2021-12-17 凌云光技术股份有限公司 Method and device for acquiring flat field correction parameters
CN114757853A (en) * 2022-06-13 2022-07-15 武汉精立电子技术有限公司 Flat field correction function acquisition method and system and flat field correction method and system
CN115170676A (en) * 2022-07-25 2022-10-11 Oppo广东移动通信有限公司 Sensor calibration and image correction method and device, electronic equipment and storage medium

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002077616A (en) * 2000-08-31 2002-03-15 Canon Inc Image processing method and apparatus, and recording medium
US20090322892A1 (en) * 2008-06-25 2009-12-31 Micron Technology, Inc. Method and apparatus for calibrating and correcting shading non-uniformity of camera systems
JP2010166143A (en) * 2009-01-13 2010-07-29 Ricoh Co Ltd Image processing apparatus, image processing method, program, and recording medium
CN104680489A (en) * 2015-02-11 2015-06-03 深圳怡化电脑股份有限公司 Image correcting method and system
CN105631819A (en) * 2015-12-25 2016-06-01 深圳市安健科技股份有限公司 Flat-field correction method and system of CCD DR detector
CN106840387A (en) * 2016-12-09 2017-06-13 中国科学院国家天文台 The Objective extraction and flat field correction method of a kind of larger imaging system of gain difference
CN107197122A (en) * 2017-06-12 2017-09-22 武汉中导光电设备有限公司 A kind of method for correcting flat field being imaged for area array cameras
CN107255521A (en) * 2017-06-28 2017-10-17 华中科技大学鄂州工业技术研究院 A kind of Infrared Image Non-uniformity Correction method and system
CN108088845A (en) * 2017-12-07 2018-05-29 武汉精测电子集团股份有限公司 A kind of image-forming correction method and device retained based on Weak Information
CN109934875A (en) * 2017-12-18 2019-06-25 长光华大基因测序设备(长春)有限公司 Camera calibration peace field correction apparatus, camera calibration method and method for correcting flat field
CN111383280A (en) * 2018-12-29 2020-07-07 中国科学院长春光学精密机械与物理研究所 Spatial remote sensing TDICCD camera non-uniformity correction method and device
CN113808046A (en) * 2021-09-18 2021-12-17 凌云光技术股份有限公司 Method and device for acquiring flat field correction parameters
CN114757853A (en) * 2022-06-13 2022-07-15 武汉精立电子技术有限公司 Flat field correction function acquisition method and system and flat field correction method and system
CN115170676A (en) * 2022-07-25 2022-10-11 Oppo广东移动通信有限公司 Sensor calibration and image correction method and device, electronic equipment and storage medium

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
YUKUN WANG ET AL.: "《a novel low rank smooth flat-field correction algorithm for hyperspectral microscopy imaging》" *
丁毅 等: "《一种新型的空间外差光谱仪平场校正方法》" *
孟然 等: "《黑白CCD相机平场影响因素分析及校正方法研究》" *
李静 等: "《一种高精度CCD 测试系统的非均匀性校正方法》" *
毛小群: "《基于定标法的红外图像非均匀性校正》" *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116630433A (en) * 2023-04-24 2023-08-22 理工特智科技(重庆)有限公司 Full-scale blackness film image digitizing method, system, equipment and medium
CN116630433B (en) * 2023-04-24 2024-01-26 理工特智科技(重庆)有限公司 Full-scale blackness film image digitizing method, system, equipment and medium

Also Published As

Publication number Publication date
CN115760653B (en) 2023-05-09

Similar Documents

Publication Publication Date Title
CN109257582B (en) Correction method and device for projection equipment
JP4816725B2 (en) Image processing apparatus, image processing program, electronic camera, and image processing method for image analysis of lateral chromatic aberration
CN107403421B (en) Image defogging method, storage medium and terminal equipment
JP5389903B2 (en) Optimal video selection
US9692958B2 (en) Focus assist system and method
US8503734B2 (en) Detecting image detail level
JP6115214B2 (en) Pattern processing apparatus, pattern processing method, and pattern processing program
KR20040089122A (en) Image processing to remove red-eye features without user interaction
CN110736610B (en) Method and device for measuring optical center deviation, storage medium and depth camera
CN111368587B (en) Scene detection method, device, terminal equipment and computer readable storage medium
CN110443783B (en) Image quality evaluation method and device
CN111340735B (en) LED screen body correction method, device and terminal
CN114066857A (en) Infrared image quality evaluation method and device, electronic equipment and readable storage medium
WO2019210707A1 (en) Image sharpness evaluation method, device and electronic device
CN115760653A (en) Image correction method, device, equipment and readable storage medium
CN111179184B (en) Fish-eye image effective region extraction method based on random sampling consistency
US20130169791A1 (en) Computing device and method for measuring widths of measured parts
CN107094219A (en) Image processing apparatus and image processing method
CN111340722B (en) Image processing method, processing device, terminal equipment and readable storage medium
RU2690716C1 (en) Self-adaptive identification method and device for identifying security document
CN109559707B (en) Gamma value processing method and device of display panel and display equipment
CN107085843A (en) System and method for estimating the modulation transfer function in optical system
CN114007013A (en) Fuzzy region determination and anti-shake performance detection method and system, and anti-shake performance detection equipment
CN111435080B (en) Water level measuring method, device and system
CN114663681A (en) Method for reading pointer type meter and related product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant