Image correction method, device, computer equipment and storage medium

By acquiring the image set of the target focal length set, determining the matching calibration points of the pixel points to be corrected and performing error correction processing, the problem of discontinuity of the contour points at the image stitching is solved, and the clarity and imaging quality of the corrected image are improved.

CN115761002BActive Publication Date: 2025-08-08NINGBO INVIEW INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211391047.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-07
Publication Date
2025-08-08
Estimated Expiration
2042-11-07

AI Technical Summary

Technical Problem

When existing image correction techniques splice sub-regions of different target focal lengths, they lead to discontinuous contour points in the corrected image and poor imaging quality.

Method used

By acquiring the target image set corresponding to the target focal length set, the matching calibration points of the pixel points to be corrected are determined, and the correction process is performed according to the error correction relationship and the target focal length, and the sub-regions with low clarity are replaced to improve imaging quality.

Benefits of technology

The clarity and imaging quality of the corrected image are improved, so that the contour points of the target sample at the stitching in the corrected image are continuous, and the overall quality of the image is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115761002B_ABST
    Figure CN115761002B_ABST
Patent Text Reader

Abstract

The present application relates to an image correction method, apparatus, computer equipment, storage medium and computer program product. The method includes: obtaining a target image set corresponding to a target focal length set; for a sub-region to be corrected in a target reference image, determining matching calibration points corresponding to the pixel points to be corrected based on the position data of the pixel points to be corrected in the sub-region to be corrected and the position data of each calibration point in the target reference image; performing correction processing on the pixel points to be corrected based on the error correction relationship corresponding to the matching calibration points and the target focal length of the target reference image to which the pixel points to be corrected belong, thereby obtaining a corrected sub-region; determining a sub-region to be replaced corresponding to the relative position of the corrected sub-region in the target reference image, and performing replacement processing on the sub-region to be replaced based on the corrected sub-region, thereby obtaining a corrected image of the target sample. This solution improves the imaging quality of the corrected image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image correction method, apparatus, computer equipment, and storage medium. Background Art

[0002] With the development of image processing technology, image correction technology has emerged. This technology can correct the target image of the target sample to obtain a corrected target image, thereby improving the imaging quality of the image.

[0003] Traditional image correction technology, in the calibration stage, collects calibration images of calibration samples corresponding to different focal lengths, and determines the focal length (for the convenience of distinction, called target focal length) of the calibration image corresponding to each sub-region with the highest clarity (for the convenience of distinction, called target sub-region) based on the preset partitioning strategy and the calibration image, and obtains the correspondence between the target focal length and the target sub-region; in the actual application stage, obtains the target image of the target sample corresponding to the target focal length, and performs splicing processing based on the target sub-regions corresponding to each target image to obtain the corrected image of the target sample.

[0004] Current image correction technology obtains a stitched corrected image by stitching target sub-regions corresponding to different target focal lengths. However, different target focal lengths will cause different distortions of the target sample in the target image. Therefore, the contour points of the target sample will be discontinuous at the stitching points in the corrected image (i.e., the stitching points between target sub-regions), resulting in poor imaging quality of the corrected image. Summary of the Invention

[0005] Based on this, it is necessary to provide an image correction method, device, computer equipment, computer-readable storage medium and computer program product that can improve the imaging quality of the corrected image in order to address the above technical problems.

[0006] In a first aspect, the present application provides a method for correcting an image. The method comprises:

[0007] Acquire a target image set of a target sample corresponding to a target focal length set; the target image set includes a frame of target benchmark image and multiple frames of target reference images;

[0008] For each frame of the target reference image, the matching calibration points corresponding to the pixel points to be corrected are determined based on the position data of the pixel points to be corrected in the target reference image and the position data of each calibration point in the target reference image.

[0009] For each pixel to be corrected in the sub-region to be corrected, performing correction processing on the pixel to be corrected according to the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, to obtain a corrected sub-region;

[0010] According to the relative position of the corrected sub-region in the target reference image, the sub-region to be replaced corresponding to the relative position is determined in the target reference image, and the sub-region to be replaced is replaced based on the corrected sub-region to obtain the corrected image of the target sample.

[0011] In one embodiment, the pixel to be corrected is corrected according to the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, to obtain the corrected sub-region, including:

[0012] Determining an error correction relationship corresponding to the matching calibration points according to the matching calibration points corresponding to the pixel points to be corrected; the error correction relationship is used to characterize the correspondence between the target focal length and the position error value;

[0013] For each pixel to be corrected in the sub-area to be corrected, determining a position error value of the pixel to be corrected according to the error correction relationship of the matched calibration points and a target focal length of the target reference image to which the pixel to be corrected belongs;

[0014] According to the position error value of the pixel to be corrected and the position data of the pixel to be corrected, the corrected position data of the pixel to be corrected is determined to obtain a corrected sub-region.

[0015] In one embodiment, before acquiring the target image set of the target sample corresponding to the target focal length set, the method further includes:

[0016] According to a preset division strategy, the calibration image set of the calibration sample corresponding to the calibration focal length set is divided to obtain a frame of the calibration benchmark image and multiple frames of calibration reference images;

[0017] Determining, in the calibration image set, a matching image corresponding to the calibration reference image according to a preset matching strategy, and determining, based on the calibration reference image and the matching image, a first matching point in the matching image corresponding to each calibration point in the calibration reference image;

[0018] For each calibration point in each frame of the calibration reference image, determine the second matching point corresponding to the calibration point in the calibration reference image based on the first matching point corresponding to the calibration point, and obtain a position error value between the calibration point and the second matching point; wherein the position error value corresponding to the same second matching point constitutes a position error value set; and the calibration focal lengths of the calibration reference image to which the calibration points corresponding to the same second matching point belong constitute a calibration focal length set;

[0019] An error correction relationship of the calibration points corresponding to the second matching points is established according to the position error value set corresponding to each second matching point and the calibration focal length set corresponding to the second matching point.

[0020] In one embodiment, establishing an error correction relationship for a calibration point corresponding to each second matching point based on a position error value set corresponding to each second matching point and a calibration focal length set corresponding to the second matching point includes:

[0021] For a calibration point corresponding to the same second matching point, constructing an error correction group corresponding to the calibration point based on a position error value between the calibration point and the second matching point, and a calibration focal length of a calibration reference image to which the calibration point belongs;

[0022] According to the error correction group corresponding to each calibration point, the error correction relationship of the calibration point is determined; the error correction relationship is used to characterize the corresponding relationship between the calibration focal length and the position error value.

[0023] In one embodiment, before dividing the calibration image set of the calibration sample corresponding to the calibration focal length set according to a preset division strategy to obtain a frame of the calibration benchmark image and multiple frames of calibration reference images, the method further includes:

[0024] Partitioning the initial calibration image of the calibration sample according to a preset first partitioning strategy to obtain a central area and an edge area of the initial calibration image;

[0025] For the central area of each of the initial calibration images, determining a first variation curve of the clarity of the central area and the initial focal length according to the clarity of the central area and the initial focal length corresponding to the initial calibration image;

[0026] For an edge area of each of the initial calibration images, determining a second variation curve of the clarity of the edge area and the initial focal length according to the clarity of the edge area and the initial focal length corresponding to the initial calibration image;

[0027] If no clarity peak is identified in the first change curve or the second change curve, the initial calibration image is reacquired, and the step of performing the step according to the preset first partitioning strategy is returned to until the clarity peak is identified in both the first change curve and the second change curve, and the initial focal length corresponding to the clarity peak of the first change curve is used as the first calibration focal length, and the initial focal length corresponding to the clarity peak of the second change curve is used as the second calibration focal length;

[0028] The calibrated focal length set is determined based on the first calibrated focal length and the second calibrated focal length.

[0029] In one embodiment, dividing the calibration image set of the calibration sample corresponding to the calibration focal length set according to a preset division strategy to obtain a frame of the calibration reference image and multiple frames of calibration reference images includes:

[0030] According to the first calibration focal length, a calibration image corresponding to the first calibration focal length is determined in a calibration image set of calibration samples corresponding to the calibration focal length set to obtain the calibration reference image, and calibration images other than the calibration reference image are identified as calibration reference images.

[0031] In a second aspect, the present application further provides an image correction device. The device comprises:

[0032] An acquisition module is used to acquire a target image set of a target sample corresponding to a target focal length set; the target image set includes a frame of target baseline image and multiple frames of target reference images;

[0033] a first matching module, configured to determine, for each frame of the target reference image, a sub-region to be corrected, and based on the position data of the pixel points to be corrected in the sub-region to be corrected and the position data of each calibration point in the target reference image, a matching calibration point corresponding to the pixel points to be corrected;

[0034] a correction module, configured to perform correction processing on each pixel to be corrected in the sub-region to be corrected, based on an error correction relationship corresponding to a matching calibration point of the pixel to be corrected and a target focal length of a target reference image to which the pixel to be corrected belongs, to obtain a corrected sub-region;

[0035] A replacement module is used to determine the sub-region to be replaced corresponding to the relative position of the corrected sub-region in the target reference image in the target reference image, and replace the sub-region to be replaced based on the corrected sub-region to obtain the corrected image of the target sample.

[0036] In one embodiment, the correction module is specifically configured to:

[0037] Determining an error correction relationship corresponding to the matching calibration points according to the matching calibration points corresponding to the pixel points to be corrected; the error correction relationship is used to characterize the correspondence between the target focal length and the position error value;

[0038] For each pixel to be corrected in the sub-area to be corrected, determining a position error value of the pixel to be corrected according to the error correction relationship of the matched calibration points and a target focal length of the target reference image to which the pixel to be corrected belongs;

[0039] According to the position error value of the pixel to be corrected and the position data of the pixel to be corrected, the corrected position data of the pixel to be corrected is determined to obtain a corrected sub-region.

[0040] In one embodiment, the image correction device further comprises:

[0041] A division module is used to divide the calibration image set of the calibration sample corresponding to the calibration focal length set according to a preset division strategy to obtain a frame of the calibration benchmark image and multiple frames of calibration reference images;

[0042] a second matching module, configured to determine, in the calibration image set, a matching image corresponding to the calibration reference image according to a preset matching strategy, and determine, based on the calibration reference image and the matching image, a first matching point in the matching image corresponding to each calibration point in the calibration reference image;

[0043] a first determination module configured to determine, for each calibration point in each frame of the calibration reference image, a second matching point corresponding to the calibration point in the calibration reference image based on a first matching point corresponding to the calibration point, and obtain a position error value between the calibration point and the second matching point; wherein the position error values corresponding to the same second matching point constitute a position error value set; and the calibration focal lengths of the calibration reference image to which the calibration points corresponding to the same second matching point belong constitute a calibration focal length set;

[0044] An establishing module is used to establish an error correction relationship between the calibration points corresponding to the second matching points based on the position error value set corresponding to each second matching point and the calibration focal length set corresponding to the second matching point.

[0045] In one embodiment, the establishment module is specifically configured to:

[0046] For a calibration point corresponding to the same second matching point, constructing an error correction group corresponding to the calibration point based on a position error value between the calibration point and the second matching point, and a calibration focal length of a calibration reference image to which the calibration point belongs;

[0047] According to the error correction group corresponding to each calibration point, the error correction relationship of the calibration point is determined; the error correction relationship is used to characterize the corresponding relationship between the calibration focal length and the position error value.

[0048] In one embodiment, the image correction device further comprises:

[0049] a partitioning module, configured to partition the initial calibration image of the calibration sample according to a preset first partitioning strategy to obtain a central area and an edge area of the initial calibration image;

[0050] a second determining module, configured to determine, for a central area of each of the initial calibration images, a first variation curve of the clarity of the central area and the initial focal length corresponding to the initial calibration image;

[0051] a third determining module, configured to determine, for an edge area of each of the initial calibration images, a second variation curve of the clarity of the edge area and the initial focal length according to the clarity of the edge area and the initial focal length corresponding to the initial calibration image;

[0052] a loop module, configured to, if no clarity peak is identified in the first change curve or the second change curve, reacquire an initial calibration image, return to executing the step according to the preset first partitioning strategy, until the clarity peak is identified in both the first change curve and the second change curve, use the initial focal length corresponding to the clarity peak of the first change curve as the first calibration focal length, and use the initial focal length corresponding to the clarity peak of the second change curve as the second calibration focal length;

[0053] A fourth determining module is configured to determine the calibrated focal length set based on the first calibrated focal length and the second calibrated focal length.

[0054] In one embodiment, the partitioning module is specifically configured to:

[0055] According to the first calibration focal length, a calibration image corresponding to the first calibration focal length is determined in a calibration image set of calibration samples corresponding to the calibration focal length set to obtain the calibration reference image, and calibration images other than the calibration reference image are identified as calibration reference images.

[0056] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps described in the first aspect when executing the computer program.

[0057] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps described in the first aspect.

[0058] In a fifth aspect, the present application further provides a computer program product, comprising a computer program that, when executed by a processor, performs the steps described in the first aspect.

[0059] The image correction method, apparatus, computer device, storage medium, and computer program product described above obtain a target image set of a target sample corresponding to a target focal length set; the target image set includes a frame of a target reference image and multiple frames of a target reference image; for a sub-region to be corrected in each frame of the target reference image, the matching calibration points corresponding to the pixel to be corrected are determined based on the position data of the pixel to be corrected in the sub-region to be corrected and the position data of each calibration point in the target reference image; for each pixel to be corrected in the sub-region to be corrected, the pixel to be corrected is corrected based on the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, thereby obtaining a corrected sub-region; based on the relative position of the corrected sub-region in the target reference image, a sub-region to be replaced corresponding to the relative position is determined in the target reference image, and the sub-region to be replaced is replaced based on the corrected sub-region to obtain a corrected image of the target sample. In the above scheme, the sub-region to be corrected is corrected based on the error correction relationship to obtain a corrected sub-region. In other words, the distortion caused by the target focal length and the calibrated reference focal length is corrected to obtain a corrected subregion that is undistorted relative to the target reference image. The corrected subregion is then used to replace the corresponding subregion to be replaced in the target reference image, yielding a corrected image. As can be appreciated, replacing the lower-resolution subregion to be replaced with the higher-resolution corrected subregion improves the clarity of the corrected image. Furthermore, because the distortion of the corrected subregion relative to the reference image has been corrected, the target sample's contour points remain continuous at the joints in the corrected image, further improving the image quality of the corrected image. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 1 is a flow chart of an image correction method according to an embodiment;

[0061] Figure 2 is a schematic diagram of an image including calibration points in one embodiment;

[0062] Figure 3 is a flowchart of a method for determining a corrected sub-region in one embodiment;

[0063] Figure 4 1 is a flow chart of a method for determining an error correction relationship of a calibration point in one embodiment;

[0064] Figure 5 1 is a flow chart of a method for determining a calibrated focal length set in one embodiment;

[0065] Figure 6 is a structural block diagram of an image correction device in one embodiment;

[0066] Figure 7 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0067] In one embodiment, Figure 1 As shown, a method for image correction is provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, or to a system including a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0068] Step 102: Acquire a target image set of a target sample corresponding to a target focal length set.

[0069] The target image set includes multiple target image frames, one of which is the target baseline image, and the remaining target images are target reference images. The target image is obtained by capturing the target sample at the target focal length. The target focal length set is constructed from the target focal lengths corresponding to the target images. The calibration image set includes multiple calibration image frames of the calibration sample. The calibration focal length set is constructed from the calibration focal lengths corresponding to the calibration images. The target focal length set is included in the calibration focal length set.

[0070] In an embodiment of the present application, the terminal collects images of the target sample based on each target focal length in the target focal length set to obtain a target image set corresponding to the target focal length set.

[0071] For each target focal length in the target focal length set, the terminal performs image acquisition on the target sample based on the target focal length to obtain a target image corresponding to the target focal length. The terminal constructs a target image set based on the target images corresponding to each target focal length in the target focal length set. Based on the calibration focal length corresponding to the calibration reference image, the terminal searches for a target focal length (referred to as a target reference focal length for the sake of convenience) that is equal to the calibration focal length corresponding to the calibration reference image in the target focal length set. Based on the target reference focal length, the terminal finds the target image to which the target reference focal length belongs in the target image set of the target sample corresponding to the target focal length set to obtain a target reference image. For each target image in the target image set, the terminal identifies the target images other than the target reference image as target reference images.

[0072] Step 104 : for each frame of the target reference image, for the sub-region to be corrected, the matching calibration points corresponding to the pixels to be corrected are determined according to the position data of the pixels to be corrected in the sub-region to be corrected and the position data of each calibration point in the target reference image.

[0073] The target focal length corresponding to the target reference image is the target reference focal length.

[0074] In an embodiment of the present application, for each frame of the target reference image, the terminal obtains the sub-area to be corrected of the target reference image based on the target reference focal length corresponding to the target reference image and the correspondence between the preset target reference focal length and the sub-area to be corrected. For each sub-area to be corrected, the terminal obtains the position data of each pixel to be corrected in the sub-area to be corrected, and the position data of all calibration points in the target reference image to which the sub-area to be corrected belongs, and calculates the calibration point closest to the pixel to be corrected (i.e., the matching calibration point corresponding to the pixel to be corrected). After all target reference images have undergone the above-mentioned matching processing, the terminal matches all the pixels to be corrected in the sub-area to be corrected to obtain corresponding matching calibration points. It can be understood that a frame of the target reference image can have one sub-area to be corrected or multiple sub-areas to be corrected, and the number of sub-areas to be corrected in each frame of the target reference image is related to the correspondence between the preset target reference focal length and the sub-area to be corrected. Among them, the position data of each calibration point in the target reference image is consistent with the position data of each calibration point in the calibration reference image corresponding to the target reference image; the target reference focal length corresponding to the target reference image is equal to the calibration reference focal length of the calibration reference image corresponding to the target reference image. In one embodiment, the terminal finds the calibration reference image to which the calibration reference focal length equal to the target reference focal length belongs based on the target reference focal length corresponding to the target reference image, and uses the position data of each calibration point in the calibration reference image as the position data of each calibration point in the target reference image. For example, assuming that the target reference focal length of the target reference image A1 is 8mm, the calibration reference focal length of the calibration reference image A′1 is 8mm, and the calibration reference image A′1 contains 2 calibration points a 11 、a 12 , where, in the calibration reference image A′1, the calibration point a 11 The position data is (x 11 ,y 11 ), calibration point a 12 The position data is (x 12 ,y 12 ), then the target reference image A1 also contains 2 calibration points a 11 、a 12 , and mark point a 11 The position data is (x 11 ,y 11), calibration point a 12 The position data is (x 12 ,y 12 ). Among them, the calibration point a ij With position data (x ij ,y ij ) have the same meaning, the first subscript i represents the calibration reference image A′ i (or target reference image A1), the second subscript j represents the jth calibration point of the calibration sample, so the calibration point a ij Indicates that in the calibration reference image A′ i (or target reference image A1) is the jth calibration point of the calibration sample; ij Indicates calibration point a ij The horizontal axis, y ij Calibration point a ij The vertical coordinate of ; i is a positive integer and is less than or equal to the number of frames of the target reference image, j is a positive integer and is less than or equal to the number of calibration points in the calibration sample. It can be understood that for the target reference image, the calibration point is an abstract point used for error correction; for the calibration reference image, the calibration point is a point on the calibration sample. In one embodiment, the calibration sample is an image containing calibration points, such as Figure 2 As shown in the figure, the image within the black solid line frame contains the calibration points, where Figure 2 All the black dots on the image and the center point of the image are calibration points of the calibration image, and the calibration points are arranged according to the structure of the dot matrix.

[0075] In step 106, for each pixel to be corrected in the sub-region to be corrected, correction processing is performed on the pixel to be corrected according to the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, thereby obtaining a corrected sub-region.

[0076] The error correction relationship is used to characterize the correspondence between the calibration focal length and the position error value. Since the target focal length set is included in the calibration focal length set, the error correction relationship is also used to characterize the correspondence between the target focal length and the position error value.

[0077] In the embodiment of the present application, for each pixel to be corrected in the sub-area to be corrected, the terminal uses the error correction relationship corresponding to the matching calibration point of the pixel to be corrected as the error correction relationship of the pixel to be corrected. Among them, in a frame of target image, the calibration point and the error correction relationship are one-to-one correspondence, but in the target image set, the error correction relationship and the calibration point are one-to-many relationship. For example, assuming that the target reference image set A is {target reference image A1, target reference image A2}, the target reference image A1 contains 2 calibration points a 11 、a 12, the target reference image A2 contains two calibration points a 21 、a 22 , where the calibration point a ij The first subscript i in the target reference image A i In the middle, the calibration point a ij The second subscript j in the calibration sample represents the jth calibration point, so the calibration point a ij Indicates that in the target reference image A i The jth calibration point of the calibration sample in the target reference image; i is a positive integer and is less than or equal to the number of frames of the target reference image, and j is a positive integer and is less than or equal to the number of calibration points in the calibration sample. It can be understood that the error correction relationship corresponding to the jth calibration point of the calibration sample in different target reference images is the same, that is, the calibration point a 11 With calibration point a 21 Corresponding to the same error correction relationship, calibration point a 12 With calibration point a 22 Corresponding to the same error correction relationship, each calibration point in the same frame target reference image corresponds to a different error correction relationship. For each pixel to be corrected in the sub-area to be corrected, the terminal calculates the position error value of the pixel to be corrected based on the target reference focal length of the target reference image to which the pixel to be corrected belongs and the error correction relationship of the pixel to be corrected. Based on the position error value of the pixel to be corrected and the position data of the pixel to be corrected, the terminal calculates the corrected position data of the pixel to be corrected. The above correction process is performed on all pixels to be corrected in the sub-area to be corrected to obtain a corrected sub-area.

[0078] In one embodiment, the error correction relationship is a set of quartic polynomials, specifically, as shown in the following formulas (1) and (2).

[0079] Δx jn =k0+k1·n+k2·n 2 +k3·n 3 +k4·n 4 (1)

[0080] Δy jn =k5+k6·n+k7·n 2 +k8·n 3 +k9·n 4 (2)

[0081] Where Δx jn , Δy jnThe subscripts jn have the same meaning. The first subscript j represents the jth calibration point of the calibration sample (or the pixel to be corrected corresponding to the jth calibration point), and the second subscript n represents the calibration focal length (or the target focal length). Δx represents the horizontal position error of the calibration point (or the pixel to be corrected corresponding to the calibration point), so Δx jn It represents the horizontal position error of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample on the image with focal length n. Δy represents the vertical position error of the calibration point (or the pixel to be corrected corresponding to the calibration point), then Δy jn represents the vertical position error of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample on an image with focal length n. n represents the calibration focal length (or target focal length), and k0 to k9 represent parameters, which are constants. The specific values are determined in step 408. It can be understood that each pixel to be corrected corresponds to a set of quartic polynomials.

[0082] For each pixel to be corrected in the sub-area to be corrected, the terminal inputs the target reference focal length of the target reference image to which the pixel to be corrected belongs into the error correction relationship corresponding to the pixel to be corrected, and calculates a set of position error values for the pixel to be corrected, and the set of position error values includes a position error value in the horizontal direction and a position error value in the vertical direction. In one embodiment, the position data is a position coordinate. Then, the terminal calculates the sum of the position error value of the pixel to be corrected and the position coordinate of the pixel to be corrected to obtain the corrected position coordinate of the pixel to be corrected. The above-mentioned correction process is performed on all the pixels to be corrected in the sub-area to be corrected to obtain a corrected sub-area. Specifically, the formulas for calculating the corrected position coordinates are shown in the following formulas (3) and (4).

[0083] x′ jn =x jn +Δx jn (3)

[0084] y′ jn =y jn +Δy jn (4)

[0085] Where x′ jn 、x jn , y′ jn 、y jn The subscripts jn have the same meaning. The first subscript j represents the jth calibration point of the calibration sample (or the pixel to be corrected corresponding to the jth calibration point), and the second subscript n represents the calibration focal length (or the target focal length). x′ represents the horizontal coordinate of the calibration point (or the pixel to be corrected corresponding to the calibration point) after correction. Then x′ jnrepresents the corrected horizontal coordinate of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample on the image with the calibration focal length (or target focal length) of n; x represents the horizontal coordinate of the calibration point (or the pixel to be corrected corresponding to the calibration point), then x jn represents the horizontal coordinate of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample on the image with the calibration focal length (or target focal length) of n. y′ represents the vertical coordinate of the calibration point (or the pixel to be corrected corresponding to the calibration point) after correction, so y′ jn represents the corrected ordinate of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample on the image with the calibration focal length (or target focal length) of n; y represents the ordinate of the calibration point (or the pixel to be corrected corresponding to the calibration point), then y jn Indicates the ordinate of the j-th calibration point (or the pixel to be corrected corresponding to the j-th calibration point) of the calibration sample on the image with the calibration focal length (or target focal length) of n.

[0086] In another embodiment, n in formula (1) to formula (4) is a frame number, wherein each frame number corresponds to a calibration focal length (or target focal length). For example, the calibration focal length set is {8mm, 9mm, 10mm}, wherein the frame number of the calibration image with a calibration focal length of 8mm is 1, the frame number of the calibration image with a calibration focal length of 9mm is 2, and the frame number of the calibration image with a calibration focal length of 10mm is 3. Specifically, for each pixel to be corrected in the sub-area to be corrected, the terminal queries the frame number of the target reference image to which the target reference focal length belongs based on the target reference focal length of the target reference image to which the pixel to be corrected belongs, and inputs the frame number into a set of fourth-order polynomials corresponding to the pixel to be corrected, and calculates a set of position error values of the pixel to be corrected, wherein the set of position error values includes a horizontal position error value and a vertical position error value. In one embodiment, the position data is a position coordinate. Then, the terminal calculates the sum of the position error value of the pixel to be corrected and the position coordinates of the pixel to be corrected to obtain the corrected position coordinates of the pixel to be corrected. The above correction process is performed on all the pixels to be corrected in the sub-region to be corrected to obtain the corrected sub-region.

[0087] Step 108, according to the relative position of the corrected sub-region in the target reference image, determine the sub-region to be replaced corresponding to the relative position in the target reference image, and replace the sub-region to be replaced based on the corrected sub-region to obtain a corrected image of the target sample.

[0088] In an embodiment of the present application, for each corrected sub-region, the terminal determines the relative position of the corrected sub-region in the target reference image to which the corrected sub-region belongs, and based on the relative position, matches the sub-region to be replaced corresponding to the relative position in the target reference image. The size of each frame of the target image is the same. It can be understood that the relative position of the corrected sub-region in the target reference image to which the corrected sub-region belongs is the same as the relative position of the sub-region to be replaced corresponding to the corrected sub-region in the target reference image. For each sub-region to be replaced in the target reference image, the terminal replaces the sub-region to be replaced with the corrected sub-region corresponding to the sub-region to be replaced. After the terminal performs the above-mentioned replacement processing on all sub-regions to be replaced in the target reference image, it obtains a corrected image of the target sample. In one embodiment, the corrected sub-region is a circular ring, wherein the center of the circle is the center of the image.

[0089] In the above-mentioned image correction method, the sub-region to be corrected is corrected based on the error correction relationship to obtain a corrected sub-region. In other words, the distortion caused by the target focal length and the calibrated reference focal length is corrected to obtain a corrected sub-region that is not distorted relative to the target reference image. Then, based on the corrected sub-region, the corresponding sub-region to be replaced in the target reference image is replaced to obtain a corrected image. It can be understood that replacing the sub-region to be replaced with a higher-definition corrected sub-region with a lower-definition one improves the clarity of the corrected image. In addition, since the distortion of the corrected sub-region relative to the reference image has been corrected, the contour points of the target sample will be continuous at the joints in the corrected image, thereby improving the imaging quality of the corrected image.

[0090] In one embodiment, Figure 3 As shown, according to the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, the pixel to be corrected is corrected, and the corrected sub-region includes:

[0091] Step 302: Determine the error correction relationship corresponding to the matching calibration points based on the matching calibration points corresponding to the pixel points to be corrected.

[0092] The error correction relationship is used to characterize the corresponding relationship between the target focal length and the position error value.

[0093] In an embodiment of the present application, for each pixel to be corrected in the sub-area to be corrected, the terminal obtains the matching calibration point corresponding to the pixel to be corrected, and based on the matching calibration point, queries and obtains the error correction relationship corresponding to the matching calibration point. Each matching calibration point corresponds to an error correction relationship. In one embodiment, the error correction relationship is a set of quartic polynomials. Specifically, refer to the above formula (1) and formula (2).

[0094] In another embodiment, the error correction relationship is shown in the following formula (5) and formula (6).

[0095] Δx jm =k′0+k′1·m+k′2·m 2 +k′3·m 3 +k′4·m 4 (5)

[0096] Δy jm =k′5+k′6·m+k′7·m 2 +k′8·m 3 +k′9·m 4 (6)

[0097] Where Δx jm , Δ yjm The subscripts jm have the same meaning. The first subscript j represents the jth calibration point of the calibration sample (or the pixel to be corrected corresponding to the jth calibration point), and the second subscript m represents the frame number. Δx represents the horizontal position error of the calibration point (or the pixel to be corrected corresponding to the calibration point), so Δx jm It represents the horizontal position error of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample on the image with frame number m. Δy represents the vertical position error of the calibration point (or the pixel to be corrected corresponding to the calibration point), so Δy jm Represents the vertical position error of the jth calibration point (or the pixel to be corrected corresponding to the jth calibration point) of the calibration sample in the image with frame number m. m represents the frame number, and k'0 to k'9 represent parameters, which are constants. The specific value determination method is described in step 408.

[0098] Step 304 : For each pixel to be corrected in the sub-region to be corrected, determine the position error value of the pixel to be corrected according to the error correction relationship of the matching calibration points and the target focal length of the target reference image to which the pixel to be corrected belongs.

[0099] In an embodiment of the present application, for each pixel to be corrected in the sub-area to be corrected, the terminal identifies the error correction relationship corresponding to the matching calibration point as the error correction relationship of the pixel to be corrected corresponding to the matching calibration point. The terminal obtains the target reference focal length of the target reference image to which the pixel to be corrected belongs, and calculates the position error value of the pixel to be corrected based on the target reference focal length and the error correction relationship corresponding to the pixel to be corrected. In one embodiment, for each pixel to be corrected in the sub-area to be corrected, the terminal inputs the target reference focal length of the target reference image to which the pixel to be corrected belongs into formula (1) and formula (2) respectively, and calculates the position error value of the pixel to be corrected in the horizontal direction and the position error value in the vertical direction. In another embodiment, for each pixel to be corrected in the sub-area to be corrected, the terminal identifies the target reference focal length of the target reference image to which the pixel to be corrected belongs, and based on the target reference focal length, in the corresponding relationship between the calibration focal length (or target focal length) and the frame number, queries and obtains the frame number corresponding to the target reference focal length. The terminal inputs the frame number into formula (5) and formula (6) respectively, and calculates the position error value of the pixel to be corrected in the horizontal direction and the position error value in the vertical direction. Among them, the correspondence between the calibrated focal length (or target focal length) and the frame number is a one-to-one correspondence. In one embodiment, the calibrated focal length set is an ordered set, and the calibrated focal lengths in the calibrated focal length set are sorted according to the size of the focal length value. The sorting can be from left to right, and the focal length value is from small to large. Accordingly, the frame numbers corresponding to the calibrated focal lengths in the calibrated focal length set are from left to right, and the frame numbers are from small to large. For example, if the calibrated focal length set is {8mm, 9mm, 10mm}, then the frame number of the calibrated image with a calibrated focal length of 8mm is 1, the frame number of the calibrated image with a calibrated focal length of 9mm is 2, and the frame number of the calibrated image with a calibrated focal length of 10mm is 3.

[0100] Step 306 : Determine the corrected position data of the pixel to be corrected based on the position error value of the pixel to be corrected and the position data of the pixel to be corrected, and obtain a corrected sub-region.

[0101] The position data is the position coordinates in the image (including the target image and the calibration image). It can be understood that a rectangular coordinate system can be established for all images, and the position data of each pixel can be represented by two-dimensional position coordinates.

[0102] In an embodiment of the present application, for each pixel to be corrected in the sub-region to be corrected, the terminal calculates the corrected position data of the pixel to be corrected based on the position error value of the pixel to be corrected and the position data of the pixel to be corrected. Specifically, for each pixel to be corrected in the sub-region to be corrected, the terminal calculates the sum of the position error value of the pixel to be corrected and the position data of the pixel to be corrected to obtain the corrected position data of the pixel to be corrected. In one embodiment, for each pixel to be corrected in the sub-region to be corrected, the terminal inputs the position error value of the pixel to be corrected in the horizontal direction and the horizontal coordinate of the pixel to be corrected into formula (3) to obtain the corrected horizontal coordinate; the terminal inputs the position error value of the pixel to be corrected in the vertical direction and the vertical coordinate of the pixel to be corrected into formula (4) to obtain the corrected vertical coordinate; the terminal obtains the corrected position data based on the corrected horizontal coordinate and the corrected vertical coordinate. After all the pixels to be corrected in the sub-region to be corrected are subjected to the above calculation processing, the terminal obtains the corrected sub-region. In this embodiment, for each pixel to be corrected in the sub-region to be corrected, the terminal performs correction processing on the pixel to be corrected based on the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, thereby obtaining a corrected sub-region. It will be understood that in the above scheme, the sub-region to be corrected is corrected based on the error correction relationship to obtain a corrected sub-region. In other words, the distortion caused by the target focal length and the calibration reference focal length is corrected, resulting in a corrected sub-region that is not distorted relative to the target reference image, thereby improving the imaging quality of the corrected image.

[0103] In one embodiment, Figure 4 As shown, before obtaining the target image set of the target sample corresponding to the target focal length set, the following steps are also included:

[0104] Step 402 : According to a preset division strategy, the calibration image set of the calibration sample corresponding to the calibration focal length set is divided to obtain a frame of calibration benchmark image and multiple frames of calibration reference images.

[0105] The calibration focal length set includes multiple calibration focal lengths, and the calibration image set includes multiple calibration image frames. A calibration image is an image acquired by capturing a calibration sample at the calibration focal length. There is a one-to-one correspondence between calibration focal lengths and calibration images. The calibration focal length of the calibration base image is the calibration base focal length, and the calibration focal length of the calibration reference image is the calibration reference focal length.

[0106] In an embodiment of the present application, the terminal performs image acquisition on the calibration sample according to the calibration focal length set to obtain multiple frames of calibration images. The terminal divides the calibration image set according to a preset division strategy to obtain a frame of calibration benchmark image and multiple frames of calibration reference images. Optionally, the preset division strategy can be to use the calibration image belonging to the center area with the highest clarity as the calibration benchmark image, the preset division strategy can also be a random frame of calibration image, and the preset division strategy can also be to use the calibration image belonging to the edge area with the highest clarity as the calibration benchmark image. Specifically, the terminal selects a frame of calibration image from the calibration image set as the calibration benchmark image according to the preset division strategy, and uses other calibration images except the calibration benchmark image as calibration reference images. Among them, the central area of the calibration image refers to the circular area formed with the center of the calibration image as the center and the preset radius as the radius; the edge area of the calibration image refers to the image area except the central area in the calibration image.

[0107] Step 404 : According to a preset matching strategy, a matching image corresponding to the calibration reference image is determined in the calibration image set, and a first matching point corresponding to each calibration point in the calibration reference image in the matching image is determined based on the calibration reference image and the matching image.

[0108] In an embodiment of the present application, for each frame of the calibration reference image, the terminal finds a calibration image that meets the preset matching strategy based on the shooting time of the calibration reference image and the shooting time of each calibration image in the calibration image set as the matching image of the calibration reference image. For each calibration point in the calibration reference image (for the convenience of distinction, referred to as the first calibration point), the terminal matches the second calibration point corresponding to the first calibration point based on the position data of the first calibration point in the calibration reference image and the position data of each calibration point in the matching image of the calibration reference image (for the convenience of distinction, referred to as the second calibration point), and uses the second calibration point as the first matching point of the first calibration point. Specifically, for the calibration image set, the terminal compares the shooting time difference between each calibration reference image and the calibration reference image, and uses the calibration reference image corresponding to the smallest shooting time difference as the first reference image. Similarly, the calibration reference image corresponding to the Nth smallest shooting time difference is used as the Nth reference image; wherein N is a positive integer, and N is less than or equal to the number of frames of the calibration reference image. The terminal uses the calibration reference image as the matching image corresponding to the first reference image and the (N-1)th reference image as the matching image corresponding to the Nth reference image. For the Nth reference image, the terminal calculates the second calibration point closest to the first calibration point based on the position data of the first calibration point in the Nth reference image and the position data of each second calibration point in the matching image of the Nth reference image, and uses the second calibration point closest to the first calibration point as the first matching point for the first calibration point.

[0109] Step 406 : for each calibration point in each calibration reference image frame, determine the second matching point corresponding to the calibration point in the calibration reference image based on the first matching point corresponding to the calibration point, and obtain the position error value between the calibration point and the second matching point.

[0110] The position error values corresponding to the same second matching point constitute a position error value set; and the calibration focal lengths of the calibration reference images to which the calibration points corresponding to the same second matching point belong constitute a calibration focal length set.

[0111] In an embodiment of the present application, for each calibration point (i.e., the first calibration point) in each calibration reference image frame, the terminal queries the calibration point corresponding to the first matching point in the calibration reference image (for convenience of distinction, referred to as the third calibration point) based on the first matching point corresponding to the first calibration point, and uses the third calibration point as the second matching point of the first calibration point. The terminal calculates the position error value between the first calibration point and the second matching point corresponding to the first calibration point based on the position data of the second matching point in the calibration reference image and the position data of the first calibration point in the reference image. Specifically, for each calibration point (i.e., the first calibration point) in the first reference image, the terminal calculates the position error value between the first calibration point and the first matching point corresponding to the first calibration point based on the position data of the first calibration point in the first reference image and the position data of the first matching point in the calibration reference image. It can be understood that since the matching image of the first reference image is the calibration reference image, for the calibration point in the first reference image, the first matching point and the second matching point are the same point. For each calibration point in the second reference image (i.e., the first calibration point), the terminal queries the calibration point (i.e., the third calibration point) corresponding to the first matching point in the calibration reference image based on the first matching point of the first calibration point in the first reference image, and uses the third calibration point in the calibration reference image as the second matching point of the first calibration point in the second reference image. For each calibration point in the second reference image (i.e., the first calibration point), the terminal calculates the position error value between the first calibration point and the second matching point corresponding to the first calibration point based on the position data of the second matching point in the calibration reference image and the position data of the first calibration point in the reference image. The method for calculating the position error value of the calibration point in the Nth reference image by the terminal is similar to the above-mentioned method for calculating the position error value, and will not be repeated here. For example, assuming that the calibration image set is {calibration reference image A′0, calibration reference image A′1 (i.e., the first reference image A′1), calibration reference image A′2 (i.e., the first reference image A′2)}, where the calibration reference image A′0 contains calibration point a 01 (x 01 ,y 01 ), the calibration reference image A′1 contains the calibration point a 11 (x 11 ,y 11), the calibration reference image A′2 contains the calibration point a 21 (x 21 ,y 21 ), calibration point a 11 The first matching point and the second matching point are the calibration points a 01 , calibration point a 21 The first matching point is the calibration point a 11 For the calibration point a in the first reference image A′1 11 , the terminal calculates the calibration point a 11 The first matching point a 01 (also a 11 The position data (x 01 ,y 01 ) and calibration point a 11 Position data (x 11 ,y 11 ) to obtain the calibration point a 11 With the first matching point a 01 Position error value. In one embodiment, for the position error value in the horizontal direction, the terminal calculates x 01 with x 11 The difference between 11 With the first matching point a 01 In one embodiment, for the position error value in the vertical direction, the terminal calculates y 01 with y 11 The difference between 11 With the first matching point a 01 The position error value in the vertical direction. For the calibration point a in the second reference image A′2 21 , the terminal is based on the calibration point a 21 The first matching point a 11 , query to get the first matching point a 11 The calibration point corresponding to the calibration reference image is calibration point a 01 , and mark point a 01 As the calibration point a 21 The second matching point of the first reference image A′2. 21 , the terminal calculates the calibration point a 21 The second matching point a 01 (also a 11 The position data (x 01 ,y 01 ) and calibration point a 21 Position data (x 21 ,y 21 ) to obtain the calibration point a 21 With the first matching point a01 Position error value. The calculation method of the position error value of each calibration point in other calibration reference images is similar and will not be repeated here.

[0112] Step 408 : establishing an error correction relationship between the calibration points corresponding to the second matching points based on the position error value set corresponding to each second matching point and the calibration focal length set corresponding to the second matching point.

[0113] Each second matching point corresponds to a position error value set, where the position error value in the position error value set is the position error value between the second matching point and the calibration point corresponding to the second matching point in the calibration reference image. Each second matching point corresponds to a calibration focal length set, where the calibration focal length in the calibration focal length set is the calibration focal length of the calibration reference image to which the calibration point corresponding to the second matching point belongs. A second matching point has a corresponding calibration point in each frame of the calibration reference image. If the number of calibration reference images is Z, then a position error value set contains Z position error values, and a calibration focal length set contains Z calibration focal lengths.

[0114] In an embodiment of the present application, for each second matching point, the terminal performs data fitting processing based on the position error value set corresponding to the second matching point and the calibration focal length set corresponding to the second matching point to obtain the error correction relationship of the calibration point corresponding to the second matching point. In one embodiment, the data fitting processing method is the least squares method. The terminal performs the above-mentioned data fitting processing on all second matching points to obtain the error correction relationship of multiple calibration points. Optionally, the error correction relationship can be a fourth-order polynomial, or a set of fourth-order polynomials (including the fourth-order polynomial corresponding to the position error in the horizontal direction and the position error in the vertical direction), or a multi-order polynomial. It can be understood that after the data fitting processing, k0 to k4 in formula (1), k5 to k9 in formula (2), k′0 to k′4, and k′5 to k′9 in formula (5) will be determined. The present application does not limit the form of the error correction relationship. As long as the error correction relationship is used to characterize the correspondence between the calibration focal length and the position error value, it is within the protection scope of the present application. It can be understood that the error correction relationship used to characterize the correspondence between the calibrated focal length and the position error value includes the error correction relationship directly characterizing the correspondence between the calibrated focal length and the position error value, and the error correction relationship indirectly characterizing the correspondence between the calibrated focal length and the position error value. The error correction relationship directly characterizes the correspondence between the calibrated focal length and the position error value, such as formula (1) and formula (2); the error correction relationship indirectly characterizes the correspondence between the calibrated focal length and the position error value, which means that the error correction relationship directly characterizes the correspondence between B and the position error value, and there is a correspondence between B and the calibrated focal length. In one embodiment, B is the frame number, then the error correction relationship is as shown in formula (5) and formula (6).

[0115] In another embodiment, for each second matching point, the terminal performs data fitting processing based on the position error value set corresponding to the second matching point and the frame number set corresponding to the calibration focal length set to obtain the error correction relationship of the calibration point corresponding to the second matching point. In one embodiment, the error correction relationship of the calibration point is shown in Formula (5) and Formula (6). The calibration focal length set includes multiple calibration focal lengths, and the calibration image to which each calibration focal length belongs corresponds to a frame number. The frame number set is constructed based on the frame number corresponding to the calibration image to which each calibration focal length belongs. Specifically, for each calibration point of the calibration reference image, the terminal constructs the error correction group corresponding to the calibration point (for the convenience of distinction, referred to as the first error correction group). For the calibration points corresponding to the same second matching point, the first error correction group corresponding to each calibration point is subjected to data fitting processing to obtain the error correction relationship of the calibration point.

[0116] In this embodiment, the terminal first divides the calibration image set to obtain a frame of calibration base image and multiple frames of calibration reference image; then, the terminal performs matching processing based on a preset matching strategy to obtain a matching image corresponding to each frame of calibration reference image, and then obtains a first matching point (calibration point in the matching image) corresponding to the first calibration point (calibration point in the calibration reference image); then, for each first calibration point, the terminal obtains a second matching point of the first calibration point (calibration point in the calibration base image) based on the first matching point of the first calibration point, and then obtains the position error between the first calibration point and the second matching point; finally, the terminal determines the error correction relationship of the calibration point based on the position error value set and the corresponding calibration focal length set. Therefore, the error correction relationship obtained by this scheme can be used to characterize the correspondence between the calibration focal length and the position error value. Then, in the actual application stage, the sub-area to be corrected can be corrected based on the error correction relationship, thereby improving the imaging quality of the corrected image.

[0117] In one embodiment, establishing an error correction relationship for a calibration point corresponding to each second matching point based on a position error value set corresponding to each second matching point and a calibration focal length set corresponding to the second matching point includes:

[0118] For the calibration points corresponding to the same second matching point, an error correction group corresponding to the calibration point is constructed based on the position error value between the calibration point and the second matching point, and the calibration focal length of the calibration reference image to which the calibration point belongs. According to the error correction group corresponding to each calibration point, the error correction relationship of the calibration point is determined. The error correction relationship is used to characterize the correspondence between the calibration focal length and the position error value.

[0119] In an embodiment of the present application, for the calibration points corresponding to the same second matching point, the terminal constructs an error correction group corresponding to the calibration point (referred to as the second error correction group for the sake of convenience in distinction) based on the position error value between the calibration point and the second matching point, and the calibration focal length of the calibration reference image to which the calibration point belongs. For the calibration points corresponding to the same second matching point, the terminal performs data fitting processing on the second error correction group corresponding to each calibration point to obtain the error correction relationship of the calibration point. It can be understood that since there are multiple second matching points (i.e., calibration points in the calibration reference image), there are also multiple error correction relationships. For example, assuming that the calibration image set is {calibration reference image A′0, calibration reference image A′1, calibration reference image A′2}, where the calibration reference image A′0 contains calibration point a 01 and calibration point a 02 , the calibration reference image A′1 contains the calibration point a 11 and calibration point a 12 , the calibration reference image A′2 contains the calibration point a 21 and calibration point a 22 For the calibration reference image A′1, the calibration point a 11 The second matching point is the calibration point a 01 , calibration point a 12 The second matching point is the calibration point a 02 ; For the calibration reference image A′2, calibration point a 21 The second matching point is the calibration point a 11 , calibration point a 22 The second matching point is the calibration point a 02 For the second matching point a 01 The calibration point (i.e. calibration point a 11 and calibration point a 21 ), the terminal is aligned with the fixed point a 11 The corresponding second error correction group and calibration point a 21 The corresponding second error correction group performs data fitting processing to obtain the calibration point a 11 and calibration point a 21 Error correction relationship. For the second matching point a 02 The calibration point (i.e. calibration point a 12 and calibration point a 22 ), the terminal is aligned with the fixed point a 12 The corresponding second error correction group and calibration point a 22 The corresponding second error correction group performs data fitting processing to obtain the calibration point a 12 and calibration point a 22 The error correction relationship.

[0120] In this embodiment, the terminal determines the error correction relationship for the calibration point corresponding to each second matching point based on the set of position error values corresponding to each second matching point and the set of calibrated focal lengths corresponding to the second matching point. Therefore, the error correction relationship obtained in this solution can be used to characterize the correspondence between the calibrated focal length and the position error value. In practical applications, the sub-region to be corrected can be corrected based on the error correction relationship, thereby improving the imaging quality of the corrected image.

[0121] In one embodiment, Figure 5 As shown, according to a preset division strategy, the calibration image set of the calibration sample corresponding to the calibration focal length set is divided to obtain a frame of calibration benchmark image and multiple frames of calibration reference images, and further includes:

[0122] Step 502 : Partition the initial calibration image of the calibration sample according to a preset first partitioning strategy to obtain a central area and an edge area of the initial calibration image.

[0123] In an embodiment of the present application, for each initial focal length in the initial focal length set, the terminal collects an initial calibration image corresponding to the initial focal length for the calibration sample, and obtains an initial calibration image set of the target sample corresponding to the initial focal length set. For each frame of the initial calibration image in the initial calibration image set, the terminal partitions the initial calibration image according to a preset first partitioning strategy to obtain a central area of the initial calibration image and an edge area of the initial calibration image. Specifically, for each frame of the initial calibration image in the initial calibration image set, the terminal divides the circular area with the imaging center as the center of the circle and the preset diameter as the diameter, and uses the circular area as the central area of the initial calibration image, and uses the image area outside the circular area as the edge area of the initial calibration image. In one embodiment, the preset diameter length can be the length of the shortest side of the initial calibration image.

[0124] Step 504 : For the central area of each initial calibration image, determine a first variation curve of the clarity and initial focal length of the central area according to the clarity of the central area and the initial focal length corresponding to the initial calibration image.

[0125] In an embodiment of the present application, for the central area of each initial calibration image, the terminal obtains the clarity of each central area (for the sake of convenience, referred to as central clarity) and the initial focal length of the initial calibration image, and performs curve fitting based on all central clarity and the initial focal length of the initial calibration image to obtain a first change curve of central clarity and initial focal length. The horizontal coordinate of the first change curve is the initial focal length, and the vertical coordinate is the clarity of the central area. In one embodiment, the clarity is the gradient mean of the image area (including the central area and the edge area), where the gradient mean = (the sum of the gradients of the image area) / (the number of pixels in the image area).

[0126] Step 506 : For the edge area of each initial calibration image, determine a second variation curve of the edge area clarity and the initial focal length according to the edge area clarity and the initial focal length corresponding to the initial calibration image.

[0127] In an embodiment of the present application, for the edge area of each initial calibration image, the terminal obtains the clarity of each edge area (for the convenience of distinction, referred to as edge clarity) and the initial focal length of the initial calibration image, and performs curve fitting based on all edge clarity and the initial focal length of the initial calibration image to obtain a first change curve of edge clarity and initial focal length. The horizontal coordinate of the first change curve is the initial focal length, and the vertical coordinate is the clarity of the edge area. In one embodiment, the clarity is the gradient mean of the image area (including the central area and the edge area), wherein the gradient mean = (the sum of the gradients of the image area) / (the number of pixels in the image area).

[0128] In step 508, if no clarity peak is identified in the first change curve or the second change curve, the initial calibration image is reacquired, and the steps according to the preset first partitioning strategy are returned to be executed until clarity peaks are identified in both the first change curve and the second change curve, and the initial focal length corresponding to the clarity peak of the first change curve is used as the first calibration focal length, and the initial focal length corresponding to the clarity peak of the second change curve is used as the second calibration focal length.

[0129] In an embodiment of the present application, if the terminal does not identify a clarity peak in the first change curve or the second change curve, the initial calibration image is reacquired and the process returns to step 502 until the terminal identifies a clarity peak in both the first change curve and the second change curve. The clarity corresponding to the clarity peak is the maximum clarity in the initial focal length interval of the first change curve, and there are smaller clarity ranges on both sides of the maximum clarity. The terminal uses the initial focal length corresponding to the clarity peak of the first change curve as the first calibration focal length, and uses the initial focal length corresponding to the clarity peak of the second change curve as the second calibration focal length.

[0130] Step 510: Determine a calibrated focal length set based on the first calibrated focal length and the second calibrated focal length.

[0131] In an embodiment of the present application, the terminal constructs a calibrated focal length interval based on the first calibrated focal length and the second calibrated focal length, and calculates each calibrated focal length according to the calibrated focal length interval and the preset number of frames of the calibrated image. Among them, the calibrated focal length is used to construct a calibrated focal length set. It can be understood that the calibrated focal length set is included in the initial calibrated focal length set. In one embodiment, the first calibrated focal length and the second calibrated focal length are thresholds of the calibrated focal length interval. Specifically, the terminal calculates the difference between the preset number of frames of the calibrated image and 1 to obtain the number of calibrated focal length sub-intervals. Based on the number of intervals of the calibrated focal length sub-intervals, the terminal divides the calibrated focal length interval into equal intervals to obtain multiple calibrated focal length sub-intervals, and constructs a calibrated focal length set based on the threshold of each calibrated focal length sub-interval. For example, the preset number of calibration image frames is 3, and the calibration focal length interval is [8mm, 10mm]. Based on the preset number of calibration image frames, 3, the terminal calculates the number of calibration focal length subintervals to be (3-1)=2. Based on the number of calibration focal length subintervals, 2, the terminal divides the calibration focal length interval [8mm, 10mm] into equal intervals, obtaining calibration focal length subintervals [8mm, 9mm] and calibration focal length subintervals [9mm, 10mm]. Based on the threshold values of 8mm, 9mm, and 10mm for each calibration focal length subinterval, the terminal constructs the calibration focal length set {calibrated focal length 8mm, calibrated focal length 9mm, calibrated focal length 10mm}.

[0132] In this embodiment, when both the first change curve and the second change curve identify the clarity peak, the terminal determines the calibrated focal length set based on the first calibrated focal length and the second calibrated focal length. Because the calibrated focal length set includes the first calibrated focal length and the second calibrated focal length, and the first calibrated focal length corresponds to the clearest central area, and the second calibrated focal length corresponds to the clearest edge area, the calibrated focal length interval composed of the first calibrated focal length and the second calibrated focal length includes the initial calibrated focal lengths corresponding to all the clearest sub-areas (sub-areas in the initial calibrated image). Then, each calibrated focal length in the calibrated focal length set determined based on the first calibrated focal length and the second calibrated focal length can provide support for image correction and is more reliable.

[0133] In one embodiment, according to a preset division strategy, the calibration image set of the calibration sample corresponding to the calibration focal length set is divided to obtain a frame of calibration reference image and multiple frames of calibration reference images, including:

[0134] According to the first calibration focal length, a calibration image corresponding to the first calibration focal length is determined in the calibration image set of the calibration sample corresponding to the calibration focal length set to obtain a calibration reference image, and calibration images other than the calibration reference image are identified as calibration reference images.

[0135] In the embodiment of the present application, the terminal searches for a calibration focal length equal to the first calibration focal length (i.e., a calibration reference focal length) from a calibration focal length set based on the first calibration focal length. Based on the calibration reference focal length, the terminal searches for a calibration image set of calibration samples to which the calibration reference focal length belongs (i.e., a calibration reference image), and identifies calibration images other than the calibration reference image as calibration reference images.

[0136] In this embodiment, the terminal determines a calibration reference image and a calibration reference image based on the first calibration focal length and the calibration image set. The calibration focal length of the calibration reference image is equal to the first calibration focal length, and the clarity corresponding to the first calibration focal length is the maximum center clarity. Therefore, the clarity of the central area of the calibration reference image is also the maximum center clarity of the calibration focal length set. Since the target focal length of the target reference image is equal to the calibration focal length of the calibration reference image, and the calibration focal length of the calibration reference image is equal to the first calibration focal length, it can be concluded that the clarity of the central area of the calibration reference image is the maximum center clarity of the target image set of the target sample. Therefore, when image correction processing is performed based on the calibration reference image with the maximum center clarity, the number of sub-areas to be replaced in the calibration reference image is relatively small, thereby improving the efficiency of correction.

[0137] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0138] Based on the same inventive concept, embodiments of the present application also provide an image correction device for implementing the aforementioned image correction method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of the one or more image correction device embodiments provided below can be found in the limitations of the image correction method described above and will not be further elaborated here.

[0139] In one embodiment, Figure 6 As shown, an image correction device is provided, comprising:

[0140] An acquisition module 602 is configured to acquire a target image set of a target sample corresponding to a target focal length set; the target image set includes a frame of a target baseline image and multiple frames of target reference images;

[0141] A first matching module 604 is configured to determine, for each frame of the target reference image, a sub-region to be corrected, and based on the position data of the pixels to be corrected in the sub-region to be corrected and the position data of each calibration point in the target reference image, a matching calibration point corresponding to the pixel to be corrected;

[0142] A correction module 606 is configured to perform correction processing on each pixel to be corrected in the sub-region to be corrected based on the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, thereby obtaining a corrected sub-region;

[0143] The replacement module 608 is used to determine the sub-region to be replaced corresponding to the relative position of the corrected sub-region in the target reference image in the target reference image, and replace the sub-region to be replaced based on the corrected sub-region to obtain a corrected image of the target sample.

[0144] In one embodiment, the correction module 606 is specifically configured to:

[0145] According to the matching calibration points corresponding to the pixel points to be corrected, the error correction relationship corresponding to the matching calibration points is determined; the error correction relationship is used to characterize the correspondence between the target focal length and the position error value;

[0146] For each pixel to be corrected in the sub-area to be corrected, determine the position error value of the pixel to be corrected based on the error correction relationship of the matching calibration points and the target focal length of the target reference image to which the pixel to be corrected belongs;

[0147] According to the position error value of the pixel to be corrected and the position data of the pixel to be corrected, the corrected position data of the pixel to be corrected is determined to obtain a corrected sub-region.

[0148] In one embodiment, the image correction device further comprises:

[0149] A division module is used to divide the calibration image set of the calibration sample corresponding to the calibration focal length set according to a preset division strategy to obtain a frame of calibration benchmark image and multiple frames of calibration reference images;

[0150] a second matching module, configured to determine, in the calibration image set, a matching image corresponding to the calibration reference image according to a preset matching strategy, and determine, based on the calibration reference image and the matching image, a first matching point corresponding to each calibration point in the calibration reference image in the matching image;

[0151] A first determination module is configured to determine, for each calibration point in each calibration reference image frame, a second matching point corresponding to the calibration point in the calibration reference image based on the first matching point corresponding to the calibration point, and obtain a position error value between the calibration point and the second matching point; wherein the position error values corresponding to the same second matching point constitute a position error value set; and the calibration focal lengths of the calibration reference image to which the calibration points corresponding to the same second matching point belong constitute a calibration focal length set;

[0152] The establishing module is used to establish an error correction relationship of the calibration point corresponding to the second matching point according to the position error value set corresponding to each second matching point and the calibration focal length set corresponding to the second matching point.

[0153] In one embodiment, the establishment module is specifically configured to:

[0154] For the calibration point corresponding to the same second matching point, an error correction group corresponding to the calibration point is constructed based on the position error value between the calibration point and the second matching point, and the calibration focal length of the calibration reference image to which the calibration point belongs;

[0155] According to the error correction group corresponding to each calibration point, the error correction relationship of the calibration point is determined; the error correction relationship is used to characterize the correspondence between the calibration focal length and the position error value.

[0156] In one embodiment, the image correction device further comprises:

[0157] A partitioning module is used to partition the initial calibration image of the calibration sample according to a preset first partitioning strategy to obtain a central area and an edge area of the initial calibration image;

[0158] a second determining module, configured to determine, for the central area of each initial calibration image, a first variation curve of the clarity and the initial focal length of the central area according to the clarity of the central area and the initial focal length corresponding to the initial calibration image;

[0159] a third determining module, configured to determine, for an edge area of each initial calibration image, a second variation curve of the clarity of the edge area and the initial focal length according to the clarity of the edge area and the initial focal length corresponding to the initial calibration image;

[0160] a loop module, configured to, if no clarity peak is identified in the first change curve or the second change curve, reacquire the initial calibration image, return to executing the steps according to the preset first partitioning strategy, until clarity peaks are identified in both the first change curve and the second change curve, use the initial focal length corresponding to the clarity peak of the first change curve as the first calibration focal length, and use the initial focal length corresponding to the clarity peak of the second change curve as the second calibration focal length;

[0161] The fourth determining module is configured to determine a calibrated focal length set based on the first calibrated focal length and the second calibrated focal length.

[0162] In one embodiment, the partitioning module is specifically configured to:

[0163] According to the first calibration focal length, a calibration image corresponding to the first calibration focal length is determined in the calibration image set of the calibration sample corresponding to the calibration focal length set to obtain a calibration reference image, and calibration images other than the calibration reference image are identified as calibration reference images.

[0164] Each module in the image correction device described above may be implemented in whole or in part through software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0165] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image correction method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.

[0166] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0167] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.

[0168] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0169] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0170] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0171] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.

[0172] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0173] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for correcting an image, characterized in that: The method comprises: Acquire a target image set of a target sample corresponding to a target focal length set; the target image set includes a frame of target benchmark image and multiple frames of target reference images; For each frame of the target reference image, the matching calibration points corresponding to the pixel points to be corrected are determined based on the position data of the pixel points to be corrected in the target reference image and the position data of each calibration point in the target reference image. For each pixel to be corrected in the sub-region to be corrected, performing correction processing on the pixel to be corrected according to the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, to obtain a corrected sub-region; According to the relative position of the corrected sub-region in the target reference image, the sub-region to be replaced corresponding to the relative position is determined in the target reference image, and the sub-region to be replaced is replaced based on the corrected sub-region to obtain the corrected image of the target sample.

2. The method according to claim 1, characterized in that The correcting process is performed on the pixel to be corrected according to the error correction relationship corresponding to the matching calibration point of the pixel to be corrected and the target focal length of the target reference image to which the pixel to be corrected belongs, to obtain a corrected sub-region, including: Determining an error correction relationship corresponding to the matching calibration points according to the matching calibration points corresponding to the pixel points to be corrected; the error correction relationship is used to characterize the correspondence between the target focal length and the position error value; For each pixel to be corrected in the sub-area to be corrected, determining a position error value of the pixel to be corrected according to the error correction relationship of the matched calibration points and a target focal length of the target reference image to which the pixel to be corrected belongs; According to the position error value of the pixel to be corrected and the position data of the pixel to be corrected, the corrected position data of the pixel to be corrected is determined to obtain a corrected sub-region.

3. The method according to claim 1, characterized in that Before acquiring the target image set of the target sample corresponding to the target focal length set, the method further includes: According to a preset division strategy, the calibration image set of the calibration sample corresponding to the calibration focal length set is divided to obtain a frame of the calibration benchmark image and multiple frames of calibration reference images; Determining, in the calibration image set, a matching image corresponding to the calibration reference image according to a preset matching strategy, and determining, based on the calibration reference image and the matching image, a first matching point in the matching image corresponding to each calibration point in the calibration reference image; For each calibration point in each frame of the calibration reference image, determine the second matching point corresponding to the calibration point in the calibration reference image based on the first matching point corresponding to the calibration point, and obtain a position error value between the calibration point and the second matching point; wherein the position error value corresponding to the same second matching point constitutes a position error value set; and the calibration focal lengths of the calibration reference image to which the calibration points corresponding to the same second matching point belong constitute a calibration focal length set; An error correction relationship of the calibration points corresponding to the second matching points is established according to the position error value set corresponding to each second matching point and the calibration focal length set corresponding to the second matching point.

4. The method according to claim 3, characterized in that The step of establishing an error correction relationship for calibration points corresponding to the second matching points based on a position error value set corresponding to each second matching point and a calibration focal length set corresponding to the second matching point includes: For a calibration point corresponding to the same second matching point, constructing an error correction group corresponding to the calibration point based on a position error value between the calibration point and the second matching point, and a calibration focal length of a calibration reference image to which the calibration point belongs; According to the error correction group corresponding to each calibration point, the error correction relationship of the calibration point is determined; the error correction relationship is used to characterize the corresponding relationship between the calibration focal length and the position error value.

5. The method according to claim 3, characterized in that Before dividing the calibration image set of the calibration sample corresponding to the calibration focal length set according to the preset division strategy to obtain a frame of the calibration benchmark image and multiple frames of calibration reference images, the method further includes: Partitioning the initial calibration image of the calibration sample according to a preset first partitioning strategy to obtain a central area and an edge area of the initial calibration image; For the central area of each of the initial calibration images, determining a first variation curve of the clarity of the central area and the initial focal length according to the clarity of the central area and the initial focal length corresponding to the initial calibration image; For an edge area of each of the initial calibration images, determining a second variation curve of the clarity of the edge area and the initial focal length according to the clarity of the edge area and the initial focal length corresponding to the initial calibration image; If no clarity peak is identified in the first change curve or the second change curve, the initial calibration image is reacquired, and the step of performing the step according to the preset first partitioning strategy is returned to until the clarity peak is identified in both the first change curve and the second change curve, and the initial focal length corresponding to the clarity peak of the first change curve is used as the first calibration focal length, and the initial focal length corresponding to the clarity peak of the second change curve is used as the second calibration focal length; The calibrated focal length set is determined based on the first calibrated focal length and the second calibrated focal length.

6. The method according to claim 5, characterized in that The step of dividing the calibration image set of the calibration sample corresponding to the calibration focal length set according to a preset division strategy to obtain a frame of the calibration benchmark image and multiple frames of calibration reference images includes: According to the first calibration focal length, a calibration image corresponding to the first calibration focal length is determined in a calibration image set of calibration samples corresponding to the calibration focal length set to obtain the calibration reference image, and calibration images other than the calibration reference image are identified as calibration reference images.

7. An image correction device, characterized in that: The device comprises: An acquisition module is used to acquire a target image set of a target sample corresponding to a target focal length set; the target image set includes a frame of target baseline image and multiple frames of target reference images; a first matching module, configured to determine, for each frame of the target reference image, a sub-region to be corrected, and based on the position data of the pixel points to be corrected in the sub-region to be corrected and the position data of each calibration point in the target reference image, a matching calibration point corresponding to the pixel points to be corrected; a correction module, configured to perform correction processing on each pixel to be corrected in the sub-region to be corrected, based on an error correction relationship corresponding to a matching calibration point of the pixel to be corrected and a target focal length of a target reference image to which the pixel to be corrected belongs, to obtain a corrected sub-region; A replacement module is used to determine the sub-region to be replaced corresponding to the relative position of the corrected sub-region in the target reference image in the target reference image, and replace the sub-region to be replaced based on the corrected sub-region to obtain the corrected image of the target sample.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Binocular camera calibration and image correction method and device, storage medium, terminal and intelligent equipment

    CN111932636A

  • Image correcting apparatus and image correcting method

    JP2007104649A