CN113066029A - Image correction method and device - Google Patents

Image correction method and device Download PDF

Info

Publication number
CN113066029A
CN113066029A CN202110348200.6A CN202110348200A CN113066029A CN 113066029 A CN113066029 A CN 113066029A CN 202110348200 A CN202110348200 A CN 202110348200A CN 113066029 A CN113066029 A CN 113066029A
Authority
CN
China
Prior art keywords
calibration
balls
image
distortion
points
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110348200.6A
Other languages
Chinese (zh)
Other versions
CN113066029B (en
Inventor
何滨
孟险峰
徐鸿嘉
顾静军
陈汉清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Santan Medical Technology Co Ltd
Original Assignee
Hangzhou Santan Medical Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Santan Medical Technology Co Ltd filed Critical Hangzhou Santan Medical Technology Co Ltd
Priority to CN202110348200.6A priority Critical patent/CN113066029B/en
Publication of CN113066029A publication Critical patent/CN113066029A/en
Application granted granted Critical
Publication of CN113066029B publication Critical patent/CN113066029B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • G06T5/80
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/30Determination of transform parameters for the alignment of images, i.e. image registration
    • G06T7/33Determination of transform parameters for the alignment of images, i.e. image registration using feature-based methods
    • G06T7/337Determination of transform parameters for the alignment of images, i.e. image registration using feature-based methods involving reference images or patches

Abstract

The embodiment of the application provides an image correction method and device. The scheme is as follows: sampling pixel points in a calibration image collected by a C-arm machine to obtain a plurality of sampling points; determining distortion displacement of a plurality of sampling points; determining an initial displacement matrix based on the distortion displacement of a plurality of sampling points, wherein the value of an element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point; predicting values of elements except for the elements corresponding to the sampling points in the initial displacement matrix based on matrix decomposition to obtain a distortion displacement matrix; and correcting the image to be corrected acquired by the C-arm machine by using the distortion displacement matrix to obtain a corrected image. According to the technical scheme provided by the embodiment of the application, the distortion displacement of each pixel point in the image collected by the C-arm machine is obtained based on the distortion displacement matrix. By utilizing the distortion displacement matrix, the C-arm machine acquired image with complex distortion can be efficiently and accurately subjected to distortion correction.

Description

Image correction method and device
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image correction method and apparatus.
Background
Image distortion refers to the distortion or deformation of an object in an image relative to the object itself. Image distortion is generally divided into radial distortion and tangential distortion. For images with radial distortion and tangential distortion, corresponding correction methods exist at present.
However, the C-arm machine generates an image based on the X-ray image enhancement device, and the distortion existing in the image is complicated. Based on the above correction method for radial distortion and tangential distortion, an image with complex distortion cannot be corrected well.
Disclosure of Invention
An object of the embodiments of the present application is to provide an image correction method and apparatus for efficiently and accurately correcting an image with complex distortion. The specific technical scheme is as follows:
the embodiment of the application provides an image rectification method, which comprises the following steps:
sampling pixel points in a calibration image collected by a C-arm machine to obtain a plurality of sampling points;
determining distortion displacement of the plurality of sampling points;
determining an initial displacement matrix based on the distortion displacements of the plurality of sampling points, wherein the ith row and jth column elements in the initial displacement matrix correspond to the ith row and jth column pixel points in the calibration image, the value of the element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and the values of the elements except the elements corresponding to the plurality of sampling points in the initial displacement matrix are zero;
predicting values of elements in the initial displacement matrix except for elements corresponding to the plurality of sampling points based on matrix decomposition to obtain a distortion displacement matrix;
and correcting the image to be corrected collected by the C-arm machine by using the distortion displacement matrix to obtain a corrected image.
Optionally, the calibration image includes a plurality of calibration balls;
the step of sampling the pixel points in the calibration image to obtain a plurality of sampling points comprises the following steps:
and identifying a plurality of calibration balls in the calibration image to obtain central points of the calibration balls, and taking the central points of the calibration balls as sampling points.
Optionally, a distance between two adjacent calibration balls in a first direction is a first preset value, a distance between two adjacent calibration balls in a second direction is a second preset value, and the first direction and the second direction are orthogonal; the plurality of calibration balls comprises a plurality of positioning calibration balls;
the step of determining distortion displacement of the plurality of sampling points comprises:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to the first preset value, and performing one-dimensional expansion in the second direction according to the second preset value to obtain correction coordinates of the central points of the plurality of calibration balls;
and acquiring distortion displacement of the plurality of sampling points based on the original coordinates of the central points of the plurality of calibration balls in the calibration image and the obtained corrected coordinates of the central points of the plurality of calibration balls.
Optionally, the step of performing one-dimensional expansion in the first direction according to the first preset value and performing one-dimensional expansion in the second direction according to the second preset value with a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point to obtain the corrected coordinates of the central points of the plurality of calibration balls includes:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to the first preset value, and performing one-dimensional expansion in the second direction according to the second preset value to obtain expanded coordinates of the central points of the plurality of expanded calibration balls;
and for each calibration ball, determining the expanded coordinate of the central point of the expanded calibration ball closest to the calibration ball according to the expanded coordinates of the central points of the expanded calibration balls and the original coordinate of the central point of the calibration ball in the calibration image, and taking the determined expanded coordinate of the central point of the expanded calibration ball as the correction coordinate of the central point of the calibration ball.
Optionally, the plurality of calibration balls include three positioning calibration balls, and the three positioning calibration balls are distributed in an L shape; the reference positioning calibration ball is one of the two positioning calibration balls with the minimum distance.
Optionally, a distance between two positioning calibration balls with a smallest distance in the first direction is less than or equal to a preset multiple of the first preset value, and a distance between two positioning calibration balls with a smallest distance in the second direction is less than or equal to the preset multiple of the second preset value.
Optionally, the predicting values of elements in the initial displacement matrix, excluding the elements corresponding to the plurality of sampling points, based on matrix decomposition to obtain a distorted displacement matrix includes:
and predicting values of elements except for the elements corresponding to the plurality of sampling points in the initial displacement matrix by utilizing a deep learning frame or a gradient descent algorithm based on matrix decomposition to obtain a distortion displacement matrix.
An embodiment of the present application further provides an image rectification apparatus, including:
the sampling module is used for sampling pixel points in a calibration image collected by the C-arm machine to obtain a plurality of sampling points;
a first determining module for determining distortion displacement of the plurality of sampling points;
a second determining module, configured to determine an initial displacement matrix based on distortion displacements of the multiple sampling points, where an element in an ith row and a jth column in the initial displacement matrix corresponds to a pixel in an ith row and a jth column in the calibration image, a value of an element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and values of elements in the initial displacement matrix except the elements corresponding to the multiple sampling points are zero;
the prediction module is used for carrying out matrix decomposition on the initial displacement matrix to obtain a distortion displacement matrix;
and the correction module is used for correcting the image to be corrected acquired by the C-arm machine by utilizing the distortion displacement matrix to obtain a corrected image.
Optionally, the calibration image includes a plurality of calibration balls;
the sampling module is specifically configured to identify a plurality of calibration balls in the calibration image to obtain center points of the plurality of calibration balls, and use the center points of the plurality of calibration balls as sampling points.
Optionally, a distance between two adjacent calibration balls in a first direction is a first preset value, a distance between two adjacent calibration balls in a second direction is a second preset value, and the first direction and the second direction are orthogonal; the plurality of calibration balls comprises a plurality of positioning calibration balls;
the first determining module includes:
the expansion submodule is used for carrying out one-dimensional expansion on the center point of the reference positioning calibration ball in the plurality of positioning calibration balls as a starting point in the first direction according to the first preset value and carrying out one-dimensional expansion on the center point of the plurality of positioning calibration balls in the second direction according to the second preset value to obtain the correction coordinates of the center points of the plurality of calibration balls;
and the obtaining sub-module is used for obtaining the distortion displacement of the plurality of sampling points based on the original coordinates of the central points of the plurality of calibration balls in the calibration image and the obtained corrected coordinates of the central points of the plurality of calibration balls.
Optionally, the expansion submodule is specifically configured to:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to the first preset value, and performing one-dimensional expansion in the second direction according to the second preset value to obtain expanded coordinates of the central points of the plurality of expanded calibration balls;
and for each calibration ball, determining the expanded coordinate of the central point of the expanded calibration ball closest to the calibration ball according to the expanded coordinates of the central points of the expanded calibration balls and the original coordinate of the central point of the calibration ball in the calibration image, and taking the determined expanded coordinate of the central point of the expanded calibration ball as the correction coordinate of the central point of the calibration ball.
Optionally, the plurality of calibration balls include three positioning calibration balls, and the three positioning calibration balls are distributed in an L shape; the reference positioning calibration ball is one of the two positioning calibration balls with the minimum distance.
Optionally, a distance between two positioning calibration balls with a smallest distance in the first direction is less than or equal to a preset multiple of the first preset value, and a distance between two positioning calibration balls with a smallest distance in the second direction is less than or equal to the preset multiple of the second preset value.
Optionally, the prediction module is specifically configured to predict values of elements in the initial displacement matrix, except for elements corresponding to the multiple sampling points, by using a deep learning frame or a gradient descent algorithm based on matrix decomposition, so as to obtain a distortion displacement matrix.
The embodiment of the application also provides electronic equipment which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
and a processor for implementing any of the image rectification method steps described above when executing the program stored in the memory.
An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the image rectification method steps described above.
Embodiments of the present application also provide a computer program, which when run on a computer, causes the computer to perform any of the image rectification methods described above.
The embodiment of the application has the following beneficial effects:
according to the technical scheme, the pixel points in the calibration image collected by the C-arm machine are sampled to obtain a plurality of sampling points, the initial displacement matrix is constructed by utilizing the distortion displacement of the sampling points, the values of elements except the elements corresponding to the sampling points in the initial displacement matrix are predicted based on matrix decomposition, and the values of each element are the distortion displacement of the corresponding pixel points respectively in the distortion displacement matrix obtained in the way. Therefore, in the embodiment of the application, the distortion displacement of each pixel point in the image acquired by the C-arm machine is obtained based on the distortion displacement matrix. By utilizing the distortion displacement matrix, the C-arm machine acquired image with complex distortion can be efficiently and accurately subjected to distortion correction.
Of course, not all advantages described above need to be achieved at the same time in the practice of any one product or method of the present application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
FIG. 1-a is a first schematic view of radial distortion;
FIG. 1-b is a second schematic illustration of radial distortion;
FIG. 1-c is a first schematic diagram of tangential distortion;
FIG. 1-d is a second schematic illustration of tangential distortion;
FIG. 2-a is a schematic view showing no distortion;
FIG. 2-b is a schematic view showing S-shaped distortion;
FIG. 2-c is a schematic illustration of the occurrence of local distortion;
fig. 3 is a first flowchart of an image rectification method according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a calibration image provided in an embodiment of the present application;
fig. 5 is a second flowchart of an image rectification method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of a correction coordinate determination method according to an embodiment of the present application;
fig. 7 is a schematic diagram of a calibrated image after dimension expansion according to an embodiment of the present application;
FIG. 8 is a schematic structural diagram of an image rectification device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the description herein are intended to be within the scope of the present disclosure.
The image distortion of the image collected by the imaging device (such as an optical camera) mainly comprises radial distortion and tangential distortion. For ease of understanding, image distortion will be described with reference to fig. 1-a to 1-d as examples. Fig. 1-a is a first schematic view of radial distortion. Fig. 1-b is a second schematic illustration of radial distortion. Fig. 1-c is a first schematic of tangential distortion. Fig. 1-d is a second schematic of tangential distortion.
The above-mentioned radial distortion is related to the optics on the imaging device. For example, when image capturing is performed using an imaging apparatus including a wide-angle lens, the captured image may have barrel distortion as shown in fig. 1-a. For another example, when image capturing is performed using an imaging apparatus including a telephoto lens, the captured image may suffer from pincushion distortion as shown in fig. 1-b. Wherein, the barrel distortion and the pincushion distortion belong to radial distortion.
The tangential distortion is related to the fact that the surface of the shot object is not perpendicular to the optical axis of the lens on the imaging device.
For example, in 20 collected images shown in fig. 1-c, the 20 collected images exhibit different tangential distortions as the angle between the surface of the object to be photographed, i.e., the mosaic plate formed by the black and white grids in fig. 1-c, and the optical axis of the lens on the imaging device changes.
As another example, in fig. 1-d, for each black or white lattice in the captured image, the black or white lattice is the same size and shape on the subject being photographed. However, in the captured image, each black or white cell is distorted tangentially to a different degree in the captured image as shown in fig. 1-d due to the difference in the angle between each black or white cell and the optical axis of the lens on the imaging device.
For the above radial distortion and tangential distortion, a commonly used distortion correction method at present is fitting based on a polynomial. However, when the C-arm machine is used to acquire the captured image, the imaging principle is complex, so that the image distortion existing in the captured image is also complex. For example, an S-shaped distortion or a local distortion may occur in a captured image captured by the C-arm machine. For ease of understanding, fig. 2-a to 2-c are illustrated as examples. Fig. 2-a is a schematic view showing no distortion. Fig. 2-b is a schematic diagram showing the occurrence of sigmoid distortion. Fig. 2-c is a schematic diagram of the occurrence of local distortion.
The positions of the various points in the captured image shown in fig. 2-b are significantly shifted compared to fig. 2-a, and the positions of the partial points in the elliptical region in the captured image shown in fig. 2-c are significantly shifted. This will affect the accuracy of the acquired images obtained by the image acquisition of the C-arm machine.
For the image distortion shown in fig. 2-b and 2-C, since the image distortion of the image collected by the C-arm machine is complicated, the above-mentioned method based on polynomial fitting cannot accurately correct the image distortion, such as the image correction of the above-mentioned S-shaped distortion or local distortion.
In order to solve the problem that an image with complex distortion cannot be corrected in the related art, an embodiment of the present application provides an image correction method. As shown in fig. 3, fig. 3 is a first flowchart of an image rectification method according to an embodiment of the present application. The method comprises the following steps.
Step S301, sampling pixel points in a calibration image collected by the C-arm machine to obtain a plurality of sampling points.
In step S302, distortion displacements of a plurality of sampling points are determined.
Step S303, determining an initial displacement matrix based on the distortion displacement of the plurality of sampling points, wherein the ith row and jth column elements in the initial displacement matrix correspond to the ith row and jth column pixel points in the calibration image, the value of the element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and the values of the elements except the elements corresponding to the plurality of sampling points in the initial displacement matrix are zero.
And step S304, predicting values of elements except the elements corresponding to the plurality of sampling points in the initial displacement matrix based on matrix decomposition to obtain a distortion displacement matrix.
And S305, correcting the image to be corrected acquired by the C-arm machine by using the distortion displacement matrix to obtain a corrected image.
According to the method provided by the embodiment of the application, the pixel points in the calibration image collected by the C-arm machine are sampled to obtain a plurality of sampling points, the distortion displacement of the plurality of sampling points is utilized to construct the initial displacement matrix, the values of elements except the elements corresponding to the plurality of sampling points in the initial displacement matrix are predicted based on matrix decomposition, and the value of each element in the distortion displacement matrix obtained in the way is the distortion displacement of the corresponding pixel point. Therefore, in the embodiment of the application, the distortion displacement of each pixel point in the image acquired by the C-arm machine is obtained based on the distortion displacement matrix. By utilizing the distortion displacement matrix, the C-arm machine acquired image with complex distortion can be efficiently and accurately subjected to distortion correction.
The following examples are given to illustrate the examples of the present application. For convenience of description, an electronic device, which may be a C-arm machine or a device having an image processing function connected to the C-arm machine, will be described as an execution main body. Here, the electronic device is not particularly limited.
In step S301, a pixel point in the calibration image collected by the C-arm machine is sampled to obtain a plurality of sampling points.
In this step, the electronic device may obtain a calibration image collected by the C-arm machine, so as to sample a pixel point in the calibration image to obtain a plurality of sampling points. Here, the sampling mode of the pixel points in the calibration image and the number of sampling points obtained by sampling are not specifically limited.
In an optional embodiment, in order to facilitate the sampling processing of the calibration image collected by the C-arm machine, a calibration plate may be disposed on the C-arm machine, and a plurality of metal balls are uniformly distributed on the calibration plate. The C-arm machine can acquire images of the calibration plate by using X-rays and take the acquired images as calibration images.
In the embodiment of the application, because the metal can show better presentation effect on the image collection under the X-ray irradiation, therefore, including a plurality of prills on the above-mentioned calibration plate can make the calibration image of gathering clearer, the processing of the later stage to the calibration image of being convenient for. Here, the metal included in the metal pellet is not particularly limited.
In an alternative embodiment, the calibration image includes a plurality of calibration balls. The calibration ball is the image of the small metal balls in the calibration plate in the calibration image. The distribution characteristics of the metal balls on the calibration plate can be referred to the distribution characteristics of the calibration balls in the following, and are not specifically described here.
Based on the calibration image including a plurality of calibration balls, in step S301, a pixel point in the calibration image is sampled to obtain a plurality of sampling points, which may specifically be:
the electronic equipment identifies the calibration balls in the calibration image to obtain the central points of the calibration balls, and the central points of the calibration balls are used as sampling points.
For ease of understanding, the acquisition of the above-described sampling points is described in conjunction with fig. 4. Fig. 4 is a schematic diagram of a calibration image provided in an embodiment of the present application.
In the calibration image shown in fig. 4, a plurality of calibration balls are included, i.e., a plurality of black circles included in the area 405 in fig. 4. When the electronic device samples the pixel points in the calibration image, the calibration balls included in the region 405 can be identified, and the pixel point where the center point of each calibration ball is located is used as a sampling point.
In the calibration image shown in fig. 4, two types of calibration balls, that is, a calibration ball 404 shown in fig. 4, and a calibration ball 401, a calibration ball 402, or a calibration ball 403 shown in fig. 4 are included. The calibration ball 404 has a small area and may be referred to as a common calibration ball, and the calibration ball 401, the calibration ball 402 or the calibration ball 403 has a large area and may be referred to as a positioning calibration ball. For the description of positioning the calibration ball, reference is made to the following description, which is not specifically described here.
In the embodiment of the present application, in order to distinguish the normal calibration ball from the positioning calibration ball in the calibration image, the radius of the normal calibration ball may be smaller than the radius of the positioning calibration ball. The radii of the above-mentioned ordinary calibration ball and the positioning calibration ball are not specifically described here.
In another optional embodiment, when the calibration image is sampled to obtain a plurality of sampling points, the electronic device may further uniformly use a pixel point corresponding to a certain point in each calibration ball in the calibration image as the sampling point after identifying the plurality of calibration balls in the calibration image. A point in the calibration sphere includes, but is not limited to, the highest vertex, the lowest vertex, the left vertex, or the right vertex.
In the embodiment of the present application, the acquisition of the sampling points in the calibration image is not particularly limited. For convenience of description, the following description will be given by taking the center point as an example, and not by any limitation.
Through the calibration ball, the electronic equipment can accurately acquire a plurality of sampling points, and the distortion displacement of each sampling point is determined at the later stage conveniently, so that the distortion displacement matrix is obtained, and the accuracy of the determined distortion displacement of each sampling point and the accuracy of the distortion displacement matrix are improved.
For the above step S302, distortion displacements of a plurality of sampling points are determined.
In this step, for each sampling point determined in step S301, the user may input the distortion displacement of the sampling point to the electronic device.
For each sampling point determined in step S301, the electronic device may also determine a distortion displacement of the sampling point based on the positioning calibration ball. For the determination of the distortion displacement at each sampling point, reference is made to the following description, which is not specifically described herein.
In the embodiment of the present application, distortion displacements of multiple sampling points may also be determined in other manners, which is not limited herein.
In the embodiment of the present application, for each sampling point, the distortion displacement of the sampling point includes the distortion displacement of the sampling point in the X direction (i.e., horizontal direction) and the distortion displacement of the sampling point in the Y direction (i.e., vertical direction). The X direction and the Y direction are directions of two coordinate axes in the image coordinate system.
In step S303, an initial displacement matrix is determined based on the distortion displacements of the multiple sampling points, where an element in the ith row and the jth column in the initial displacement matrix corresponds to a pixel in the ith row and the jth column in the calibration image, a value of an element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and values of elements in the initial displacement matrix except the elements corresponding to the multiple sampling points are zero.
In this step, since a plurality of sampling points can be obtained after the sampling in step S301, for convenience of later data processing, the electronic device may determine an initial displacement matrix according to the position of each sampling point in the calibration image based on the distortion displacement of each sampling point.
In this embodiment of the application, when determining the initial displacement matrix, since the distortion displacement of each sampling point includes the distortion displacement in the X direction and the distortion displacement in the Y direction, the electronic device may construct a displacement matrix in the X direction according to the distortion displacement of each sampling point in the X direction, and construct a displacement matrix in the Y direction according to the distortion displacement of each sampling point in the Y direction. The initial displacement matrix includes an initial displacement matrix in the X direction and an initial displacement matrix in the Y direction.
For convenience of understanding, the construction of the displacement matrix in the X direction is described by taking an example in which the size of the calibration image is 1024 pixels by 1024 pixels.
Through the step S302, the electronic device determines the distortion displacement of each sampling point in the calibration image in the X direction, and does not determine the distortion displacement of the pixel points other than the sampling point in the X direction, that is, the distortion displacement of each pixel point other than the sampling point in the X direction is 0. The electronic device can construct a displacement matrix with the size of 1024 × 1024 according to the distortion displacement of each pixel point in the calibration image in the X direction and the position of each pixel point, namely, an initial displacement matrix in the X direction. In the initial displacement matrix, the element value at the corresponding position of each sampling point is the distortion displacement of the sampling point in the X direction, and the element value at the corresponding position of each pixel point except the sampling point is the distortion displacement of the pixel point in the X direction, that is, 0.
For example, if the position of a certain sampling point in the calibration image is row 3, column 3, the distortion displacement of the sampling point in the X direction is Δ X, the position of a certain pixel (non-sampling point) is row 5, column 1, and the distortion displacement of the pixel in the X direction is 0, then in the initial displacement matrix in the X direction with the size of 1024 × 1024, the element value of row 3, column 3 in row 3 is Δ X, and the element value of row 5, column 1 in column 1 is 0.
The construction of the displacement matrix in the Y direction may refer to the construction of the initial displacement matrix in the X direction, and will not be described in detail here.
In the embodiment of the present application, i and j in the ith row and the jth column in step S303 are both positive integers. I is more than or equal to 1 and less than or equal to M, j is more than or equal to 1 and less than or equal to N, M is the total number of pixel points in each row of the calibration image, and N is the total number of pixel points in each column of the calibration image.
In step S304, based on matrix decomposition, values of elements other than the elements corresponding to the plurality of sampling points in the initial displacement matrix are predicted to obtain a distortion displacement matrix.
In this step, in the initial displacement matrix determined in step S303, that is, in the initial displacement matrix in the X direction and the initial displacement matrix in the Y direction, the distortion displacement of each pixel point other than the sampling point is supplemented with 0. In order to effectively complement the initial displacement matrix, that is, to determine the distortion displacement corresponding to each pixel point in the calibration image, the electronic device may predict values of elements other than the elements corresponding to the plurality of sampling points in the initial displacement matrix based on matrix decomposition according to a characteristic that the distortion displacement of a certain pixel point is close to the distortion displacement of surrounding pixel points, so as to obtain the distortion displacement matrix. Namely, the distortion displacement corresponding to each pixel point in the calibration image is accurately predicted, and a distortion displacement matrix is obtained.
In an optional embodiment, in step S304, based on matrix decomposition, values of elements other than the elements corresponding to the multiple sampling points in the initial displacement matrix are predicted to obtain a distortion displacement matrix, which may be specifically represented as:
and the electronic equipment predicts the values of elements except the elements corresponding to the plurality of sampling points in the initial displacement matrix by utilizing a deep learning framework or a gradient descent algorithm based on matrix decomposition to obtain a distortion displacement matrix.
For the sake of understanding, the process of solving the distortion displacement matrix will be described below by taking the above gradient descent method as an example.
Now suppose matrix R[m*n]Is the initial displacement matrix, i.e. the initial displacement matrix in the X direction or the initial displacement matrix in the Y direction, Ri,jIs a matrix R[m*n]Row i and column j. R[m*n]Can be expressed as:
Figure BDA0003001555710000121
suppose in R[m*n]=P[m*k]*Q[k*n]On the basis of (i.e. initially)The start shift matrix can be matrix decomposed into P[m*k]And Q[k*n]The electronic device may construct an Objective function Objective:
Objective=min[N(P[m*k]*Q[k*n])+f(P[m*k]*Q[k*n],R[m*n])]
where min is the minimum value operation, N (P)[m*k]*Q[k*n]) F (P) can be calculated by the following equation 1[m*k]*Q[k*n],R[m*n]) Can be calculated by the following formula 2.
Equation 1:
Figure BDA0003001555710000122
equation 2:
Figure BDA0003001555710000123
wherein, N (A)[a*b]) Is represented by A[a*b]Element value of each element in f (A) is the difference of element values of neighboring elements[a*b],B[a*b]) Is B[a*b]Calculating A based on whether the element is 0 or not[a*b]The sum of the squares of the differences between the elements corresponding to values other than 0 in (1) can be understood as: a. the[a*b]And B[a*b]The difference in the corresponding values of the elements at a particular position, i.e. the distance, matrix A[a*b]And B[a*b]Being a formal parameter, matrix A[a*b]The incoming actual parameter of (A) is a matrix P[m*k]And matrix Q[k*n]The matrix obtained after multiplication, matrix B[a*b]The afferent parameters of (A) are R[m*n]
neighbor (i, j) is the element that is the neighbor of the ith row and jth column element, N is the number of the neighbor elements, AkmIs a matrix A[a*b]Element of the kth row and mth column, AijIs a matrix A[a*b]The ith row and the jth column in the matrix A[a*b]B is the matrix A[a*b]Column number of (1), matrix B[a*b]Is a matrix R[m*n],BijIs a matrix B[a*b]Row i and column j.
The elements adjacent to the jth element in the ith row and the jth column are corresponding to the jth element in the ith row and the jth column in at least two directions of up, down, left, right, left-up, left-down, right-up and right-down. The specific selection range of the element in the ith row and the jth column neighbor can be determined according to the set maximum number of neighbor elements. The number of the neighbor elements of the ith row and the jth column is different according to the position of the element. For example, the neighboring elements of row 1, column 1 elements may include row 1, column 2 elements and row 2, column 1 elements. For another example, in a 1024 x 1024 matrix, the neighboring elements of the 5 th row and the 5 th column may include the elements corresponding to the above 8 directions. Here, the number of the neighbor elements of the ith row and the jth column is not particularly limited.
After the Objective function Objective is constructed, the electronic device can respectively aim at pijAnd q isijObtaining P by partial derivation[m*k]And Q[k*n]The gradient corresponding to each element in the target vector is optimized by using a gradient descent algorithm to obtain P[m*k]And Q[k*n]I.e. the distortion displacement matrix described above. p is a radical ofijRepresents P[m*k]Element of the ith row and the jth column in (q)ijRepresents Q[k*n]Row i and column j.
By the above formula 1, P can be used[m*k]And Q[k*n]The matrix obtained by multiplication restores R containing the missing value (namely the distortion displacement corresponding to the pixel points except the sampling point)[m*n]When the matrix A is[a*b]The incoming actual parameter of (A) is a matrix P[m*k]And matrix Q[k*n]When the resulting matrix is multiplied, N (A)[a*b]) The distortion difference between the distortion displacement of any pixel point and the distortion displacement of the neighbor pixel point can be understood. The smaller the distortion difference is, the higher the accuracy of the distortion displacement matrix determined based on the distortion difference is, so that the accuracy of a corrected image obtained by correcting the image based on the distortion displacement matrix is improved.
By the above formula 2, P can be made[m*k]And Q[k*n]Matrix obtained by multiplication with R[m*n]Is not missing (i.e., each of the aboveDistortion displacement to which the sample points correspond) between the element values at the corresponding positions as small as possible. I.e. so that the matrix a[a*b]And matrix B[a*b]The distance between the values of the elements at the corresponding positions in (b) is as small as possible. When f (A)[a*b],B[a*b]) The smaller, i.e. the smaller the distance, the matrix A[a*b]And matrix B[a*b]The higher the similarity, the higher the accuracy of the distortion displacement matrix obtained based on matrix decomposition.
In an alternative embodiment, the deep learning framework may be a Torch framework or a Tensorflow integrated optimizer, such as Adam. Among them, the Torch framework is a scientific computing framework widely supporting machine learning algorithms, and the tensoflow is a symbolic mathematical system based on dataflow programming. Here, the deep learning framework is not particularly limited, and a process of solving the distortion displacement matrix by using the deep learning framework is not particularly described.
In step S305, the image to be corrected collected by the C-arm machine is corrected by using the distortion displacement matrix, so as to obtain a corrected image.
In this step, after obtaining the distortion displacement matrix in step S304, the electronic device may obtain an image to be corrected, which is collected by the C-arm machine, and correct the image to be corrected by using the distortion displacement matrix, so as to obtain a corrected image.
The image to be corrected may be any image acquired by the C-arm machine, and the image to be corrected is not particularly limited.
In the embodiment of the application, since the image distortion of the image to be corrected acquired by each C-arm machine is the same as the image distortion of the calibration image acquired by the C-arm machine, when the electronic device corrects the image to be corrected acquired by the C-arm machine by using the distortion displacement matrix determined by the calibration image acquired by a certain C-arm machine, the correction of the image distortion can be accurately completed, so that the image distortion in the image to be corrected is eliminated.
In an optional embodiment, for the calibration image, a distance between two adjacent calibration balls in a first direction is a first preset value, a distance between two adjacent calibration balls in a second direction is a second preset value, and the first direction and the second direction are orthogonal; the plurality of calibration balls includes a plurality of positioning calibration balls.
In the embodiment of the present application, the area of the calibration ball in the above calibration image is smaller than the area of the positioning calibration ball, as shown in fig. 4.
The first direction and the second direction may be determined according to distribution characteristics of the calibration balls in the calibration image, and the first direction and the second direction are different from the X direction and the Y direction. Here, the first direction and the second direction are not particularly limited.
For ease of understanding, the above-mentioned example of fig. 4 is still used for illustration. Now, it is assumed that the first direction is an upward direction or a downward direction along a straight line where the center point of the calibration ball 403 and the center point of the calibration ball 402 are located, and the second direction is an upward direction or a downward direction along a straight line where the center point of the calibration ball 401 and the center point of the calibration ball 402 are located. The first direction and the second direction are orthogonal. In fig. 4, the calibration ball 404 is a common calibration ball, and the calibration ball 401, the calibration ball 402 or the calibration ball 403 is a positioning calibration ball.
In an alternative embodiment, the plurality of calibration balls may include three positioning calibration balls, and the three positioning calibration balls may be distributed in an L-shape. Besides, the number of the positioning calibration balls in the calibration image can be other values, such as 4, 5, 6, etc. Here, the number of the positioning calibration balls included in the calibration image is not particularly limited.
In an alternative embodiment, the distance between every two adjacent calibration balls in the first direction or the second direction may be represented as the distance between the center points of every two adjacent calibration balls. In the first direction, the distance between every two adjacent calibration balls is a first preset value. In the second direction, the distance between every two adjacent calibration balls is a second preset value.
In an alternative embodiment, the distance between the two positioning calibration balls with the smallest distance in the first direction is less than or equal to a preset multiple of the first preset value, and the distance between the two positioning calibration balls with the smallest distance in the second direction is less than or equal to a preset multiple of the second preset value.
For ease of understanding, the above-mentioned example of fig. 4 is still used for illustration. In fig. 4, the calibration ball 403 is separated from the calibration ball 402 by a common calibration ball in the first direction, and the distance between the calibration ball 403 and the calibration ball 402 may be 2 times the first preset value. In fig. 4, the calibration balls 401 and 402 are separated by three common calibration balls in the second direction, and the distance between the calibration balls 401 and 402 can be 4 times the second preset value.
The first preset value may be the same as the second preset value, and the first preset value may also be different from the second preset value. Here, the sizes of the first preset value and the second preset value are not particularly limited. For convenience of description, the first preset value and the second preset value are the same as an example and are not limited in any way.
Based on the distribution of the calibration spheres, the embodiment of the application also provides an image correction method according to the method shown in fig. 3. As shown in fig. 5, fig. 5 is a second flowchart of an image rectification method according to an embodiment of the present application. In this method, the above step S302 is subdivided into steps S3021 to S3022.
Step S3021, taking the central point of the reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to a first preset value, and performing one-dimensional expansion in the second direction according to a second preset value to obtain the correction coordinates of the central points of the plurality of calibration balls.
In this step, the electronic device may determine a reference positioning calibration ball from the plurality of positioning calibration balls included in the calibration image, so as to perform one-dimensional expansion in the first direction according to the first preset value and perform one-dimensional expansion in the second direction according to the second preset value with a central point of the reference positioning calibration ball as a starting point, thereby obtaining corrected coordinates of the central points of the plurality of calibration balls.
In an alternative embodiment, the reference positioning calibration ball may be any positioning calibration ball in the calibration image.
In another alternative embodiment, considering the uncertainty and complexity of the occurrence of image distortion, when determining the reference positioning calibration ball, one of the two positioning calibration balls with the smallest distance may be determined as the reference positioning calibration ball. Because the distance between the two positioning calibration balls is minimum, the distortion displacement of the two positioning calibration balls relative to other positioning calibration balls is relatively small, so that the error introduced in the expansion process can be effectively reduced, and the accuracy of the later-determined correction coordinate is improved.
In an alternative embodiment, as shown in fig. 6, the above step S3021 may be subdivided into steps S601 to S602. Fig. 6 is a schematic flowchart of a correction coordinate determination method according to an embodiment of the present application.
Step S601, taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in a first direction according to a first preset value, and performing one-dimensional expansion in a second direction according to a second preset value to obtain expansion coordinates of the central points of the plurality of expansion calibration balls.
For ease of understanding, the determination of the extended coordinates described above is described in conjunction with FIG. 7. Fig. 7 is a schematic diagram of a calibrated image after dimension expansion according to an embodiment of the present application. It is assumed that the upward direction of the straight lines of the positioning calibration ball 701 and the positioning calibration ball 702 is the first direction, and the upward direction of the straight lines of the positioning calibration ball 703 and the positioning calibration ball 701 is the second direction.
The electronic device may use the positioning calibration ball 701 in fig. 7 as a reference positioning calibration ball. The electronic device performs one-dimensional expansion along a first direction according to a first preset value by taking a central point of the positioning calibration ball 701 as a starting point, performs one-dimensional expansion along a second direction according to a second preset value to obtain a plurality of expanded calibration balls, and determines a position coordinate of the central point of each expanded calibration ball as an expanded coordinate of each expanded calibration ball.
For example, the electronic device determines an expanded calibration ball every first preset value in sequence from the positioning calibration ball 701 as a starting point along a first direction, upward and downward, so as to obtain a plurality of expanded calibration balls. And aiming at each expanded calibration ball, the electronic equipment takes the expanded calibration ball as a starting point, and sequentially determines each second preset value upwards and downwards along the second direction to form an expanded calibration ball. Through one-dimensional expansion in the first direction and one-dimensional expansion in the second direction, the electronic device can obtain an expanded calibration sphere as shown in fig. 7. I.e., each of the white calibration balls in fig. 7, such as calibration ball 704 in fig. 7, etc.
For each expanded calibration ball in fig. 7, the electronic device may determine the position coordinates of the central point of the expanded positioning ball as the expanded coordinates of the expanded positioning ball.
Step S602, for each calibration ball, determining an expanded calibration ball closest to the calibration ball according to the expanded coordinates of the central points of the expanded calibration balls and the original coordinates of the central point of the calibration ball in the calibration image, and taking the determined expanded coordinates of the central point of the expanded calibration ball as the correction coordinates of the central point of the calibration ball.
For ease of understanding, the above-mentioned example of fig. 7 is still used for illustration. With respect to the calibration ball 705 in fig. 7, there are two extended calibration balls, an extended calibration ball 706 and an extended calibration ball 707, in the vicinity of the calibration ball 705 in the first direction described above. When the calibration coordinates of the center point of the calibration ball 705 are determined, the distance from the center point of the calibration ball 705 to the center point of the expanded calibration ball 706 is significantly smaller than the distance from the center point of the calibration ball 705 to the center point of the expanded calibration ball 707, that is, the calibration ball 705 is closest to the expanded calibration ball 706. At this time, the electronic device may determine the extended coordinates of the center point of the extended calibration sphere 706 as the corrected coordinates of the center point of the calibration sphere 705.
Through the steps S601 and S602, the electronic device may accurately determine the corrected coordinates of each calibration ball of the calibration image, that is, the corrected coordinates corresponding to each sampling point, according to the determined extended coordinates of the central point of the extended calibration ball.
Step S3022, based on the original coordinates of the central points of the plurality of calibration balls in the calibration image and the obtained corrected coordinates of the central points of the plurality of calibration balls, obtaining distortion displacements of the plurality of sampling points.
In this step, for each calibration ball in the calibration image, the electronic device may calculate the distortion displacement of the calibration ball according to the original coordinate of the central point of the calibration ball and the corrected coordinate of the central point of the calibration ball, that is, determine the distortion displacement of the sampling point corresponding to the calibration ball.
In an alternative embodiment, for each sample point in the calibration image, the distortion displacement of the sample point may be expressed as: and calibrating the difference between the original coordinates and the corrected coordinates of the calibration ball corresponding to the sampling point in the image. Here, the calculation of the distortion displacement of the plurality of sampling points will not be specifically described.
Through the steps S3021 and S3022, the electronic device may accurately determine the distortion coordinate corresponding to each sampling point according to the original coordinate and the corrected coordinate of each sampling point.
Based on the same inventive concept, according to the image correction method provided by the embodiment of the present application, the embodiment of the present application further provides an image correction device. Fig. 8 is a schematic structural diagram of an image rectification device according to an embodiment of the present application, as shown in fig. 8. The apparatus includes the following modules.
The sampling module 801 is used for sampling pixel points in a calibration image acquired by the C-arm machine to obtain a plurality of sampling points;
a first determining module 802 for determining distortion displacement of a plurality of sampling points;
a second determining module 803, configured to determine an initial displacement matrix based on distortion displacements of multiple sampling points, where an element in the ith row and the jth column in the initial displacement matrix corresponds to a pixel in the ith row and the jth column in the calibration image, a value of an element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and values of elements in the initial displacement matrix except the elements corresponding to the multiple sampling points are zero;
the prediction module 804 is configured to predict values of elements, except for elements corresponding to the multiple sampling points, in the initial displacement matrix based on matrix decomposition to obtain a distortion displacement matrix;
and the correcting module 805 is configured to correct the image to be corrected acquired by the C-arm machine by using the distortion displacement matrix, so as to obtain a corrected image.
Optionally, the calibration image may include a plurality of calibration balls;
the sampling module 801 may be specifically configured to identify a plurality of calibration balls in a calibration image to obtain center points of the plurality of calibration balls, and use the center points of the plurality of calibration balls as sampling points.
Optionally, the distance between two adjacent calibration balls in the first direction is a first preset value, the distance between two adjacent calibration balls in the second direction is a second preset value, and the first direction and the second direction are orthogonal; the plurality of calibration balls comprises a plurality of positioning calibration balls;
the first determining module 802 may include:
the expansion submodule is used for carrying out one-dimensional expansion on a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point in a first direction according to a first preset value and carrying out one-dimensional expansion on the central point in a second direction according to a second preset value to obtain correction coordinates of the central points of the plurality of calibration balls;
and the obtaining submodule is used for obtaining the distortion displacement of a plurality of sampling points based on the original coordinates of the central points of the plurality of calibration balls in the calibration image and the obtained corrected coordinates of the central points of the plurality of calibration balls.
Optionally, the expansion sub-module may be specifically configured to:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in a first direction according to a first preset value, and performing one-dimensional expansion in a second direction according to a second preset value to obtain expanded coordinates of the central points of the plurality of expanded calibration balls;
and aiming at each calibration ball, determining the expanded calibration ball closest to the calibration ball according to the expanded coordinates of the central points of the expanded calibration balls and the original coordinates of the central point of the calibration ball in the calibration image, and taking the expanded coordinates of the central point of the determined expanded calibration ball as the correction coordinates of the central point of the calibration ball.
Optionally, the plurality of calibration balls include three positioning calibration balls, and the three positioning calibration balls are distributed in an L shape; the reference positioning calibration ball is one of the two positioning calibration balls with the minimum distance.
Optionally, the distance between the two positioning calibration balls with the smallest distance in the first direction is less than or equal to a preset multiple of the first preset value, and the distance between the two positioning calibration balls with the smallest distance in the second direction is less than or equal to a preset multiple of the second preset value.
Optionally, the prediction module 804 may be specifically configured to predict values of elements, except for elements corresponding to the multiple sampling points, in the initial displacement matrix by using a deep learning framework or a gradient descent algorithm based on matrix decomposition, so as to obtain a distortion displacement matrix.
Through the device that this application embodiment provided, pixel in the calibration image that gathers C arm machine is sampled, obtains a plurality of sampling points, utilizes the distortion displacement of a plurality of sampling points, constructs the initial displacement matrix to based on matrix decomposition, predict the value of the element except that a plurality of sampling point correspond in the initial displacement matrix, in the distortion displacement matrix that obtains like this, the value of every element is the distortion displacement of the pixel that corresponds respectively. Therefore, in the embodiment of the application, the distortion displacement of each pixel point in the image acquired by the C-arm machine is obtained based on the distortion displacement matrix. By utilizing the distortion displacement matrix, the C-arm machine acquired image with complex distortion can be efficiently and accurately subjected to distortion correction.
Based on the same inventive concept, according to the image rectification method provided by the embodiment of the present application, the embodiment of the present application further provides an electronic device, as shown in fig. 9, including a processor 901, a communication interface 902, a memory 903 and a communication bus 904, where the processor 901, the communication interface 902 and the memory 903 complete communication with each other through the communication bus 904;
a memory 903 for storing computer programs;
the processor 901 is configured to implement the following steps when executing the program stored in the memory 903:
sampling pixel points in a calibration image collected by a C-arm machine to obtain a plurality of sampling points;
determining distortion displacement of a plurality of sampling points;
determining an initial displacement matrix based on distortion displacements of a plurality of sampling points, wherein the ith row and jth column elements in the initial displacement matrix correspond to the ith row and jth column pixel points in the calibration image, the value of the element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and the values of the elements except the elements corresponding to the sampling points in the initial displacement matrix are zero;
predicting values of elements except for elements corresponding to the plurality of sampling points in the initial displacement matrix based on matrix decomposition to obtain a distortion displacement matrix;
and correcting the image to be corrected acquired by the C-arm machine by using the distortion displacement matrix to obtain a corrected image.
Through the electronic equipment that this application embodiment provided, pixel in the calibration image that the C arm machine gathered is sampled, obtains a plurality of sampling points, utilizes the distortion displacement of a plurality of sampling points, constructs initial displacement matrix to based on matrix decomposition, predict the value of the element except that a plurality of sampling point correspond in the initial displacement matrix, in the distortion displacement matrix that obtains like this, the value of every element is the distortion displacement of the pixel that corresponds respectively. Therefore, in the embodiment of the application, the distortion displacement of each pixel point in the image acquired by the C-arm machine is obtained based on the distortion displacement matrix. By utilizing the distortion displacement matrix, the images acquired by the C-arm machine with complex distortion can be efficiently and accurately corrected in a distortion manner, and the images acquired by the C-arm machine with complex distortion can be well corrected.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor including a Central Processing Unit (CPU), a Network Processor (NP), etc.; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
Based on the same inventive concept, according to the image rectification method provided by the embodiment of the present application, the embodiment of the present application further provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and the computer program realizes the steps of any one of the image rectification methods when being executed by a processor.
Based on the same inventive concept, according to the image rectification method provided in the embodiments of the present application, the embodiments of the present application also provide a computer program, which, when running on a computer, causes the computer to execute any one of the image rectification methods in the embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. The term "comprising", without further limitation, means that the element so defined is not excluded from the group consisting of additional identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for embodiments such as the apparatus, the electronic device, the computer-readable storage medium, and the computer program, since they are substantially similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.
The above description is only for the preferred embodiment of the present application and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (16)

1. An image rectification method, characterized in that the method comprises:
sampling pixel points in a calibration image collected by a C-arm machine to obtain a plurality of sampling points;
determining distortion displacement of the plurality of sampling points;
determining an initial displacement matrix based on the distortion displacements of the plurality of sampling points, wherein the ith row and jth column elements in the initial displacement matrix correspond to the ith row and jth column pixel points in the calibration image, the value of the element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and the values of the elements except the elements corresponding to the plurality of sampling points in the initial displacement matrix are zero;
predicting values of elements in the initial displacement matrix except for elements corresponding to the plurality of sampling points based on matrix decomposition to obtain a distortion displacement matrix;
and correcting the image to be corrected collected by the C-arm machine by using the distortion displacement matrix to obtain a corrected image.
2. The method of claim 1, wherein the calibration image comprises a plurality of calibration balls;
the step of sampling the pixel points in the calibration image to obtain a plurality of sampling points comprises the following steps:
and identifying a plurality of calibration balls in the calibration image to obtain central points of the calibration balls, and taking the central points of the calibration balls as sampling points.
3. The method according to claim 2, wherein the distance between two adjacent calibration balls in the first direction is a first preset value, the distance between two adjacent calibration balls in the second direction is a second preset value, and the first direction and the second direction are orthogonal; the plurality of calibration balls comprises a plurality of positioning calibration balls;
the step of determining distortion displacement of the plurality of sampling points comprises:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to the first preset value, and performing one-dimensional expansion in the second direction according to the second preset value to obtain correction coordinates of the central points of the plurality of calibration balls;
and acquiring distortion displacement of the plurality of sampling points based on the original coordinates of the central points of the plurality of calibration balls in the calibration image and the obtained corrected coordinates of the central points of the plurality of calibration balls.
4. The method according to claim 3, wherein the step of performing one-dimensional expansion in the first direction according to the first preset value and performing one-dimensional expansion in the second direction according to the second preset value to obtain corrected coordinates of the center points of the plurality of calibration balls, with the center point of the reference calibration ball of the plurality of calibration balls as a starting point, comprises:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to the first preset value, and performing one-dimensional expansion in the second direction according to the second preset value to obtain expanded coordinates of the central points of the plurality of expanded calibration balls;
and for each calibration ball, determining the expanded coordinate of the central point of the expanded calibration ball closest to the calibration ball according to the expanded coordinates of the central points of the expanded calibration balls and the original coordinate of the central point of the calibration ball in the calibration image, and taking the determined expanded coordinate of the central point of the expanded calibration ball as the correction coordinate of the central point of the calibration ball.
5. The method of claim 3, wherein the plurality of calibration balls comprises three positioning calibration balls, the three positioning calibration balls being distributed in an L-shape; the reference positioning calibration ball is one of the two positioning calibration balls with the minimum distance.
6. The method according to claim 5, wherein the distance between two positioning calibration balls having the smallest distance in the first direction is less than or equal to a preset multiple of the first preset value, and the distance between two positioning calibration balls having the smallest distance in the second direction is less than or equal to the preset multiple of the second preset value.
7. The method according to any one of claims 1 to 6, wherein the step of predicting values of elements of the initial displacement matrix except for elements corresponding to the plurality of sampling points based on matrix decomposition to obtain a distortion displacement matrix comprises:
and predicting values of elements except for the elements corresponding to the plurality of sampling points in the initial displacement matrix by utilizing a deep learning frame or a gradient descent algorithm based on matrix decomposition to obtain a distortion displacement matrix.
8. An image rectification apparatus, characterized in that the apparatus comprises:
the sampling module is used for sampling pixel points in a calibration image collected by the C-arm machine to obtain a plurality of sampling points;
a first determining module for determining distortion displacement of the plurality of sampling points;
a second determining module, configured to determine an initial displacement matrix based on distortion displacements of the multiple sampling points, where an element in an ith row and a jth column in the initial displacement matrix corresponds to a pixel in an ith row and a jth column in the calibration image, a value of an element corresponding to each sampling point in the initial displacement matrix is the distortion displacement of the sampling point, and values of elements in the initial displacement matrix except the elements corresponding to the multiple sampling points are zero;
the prediction module is used for carrying out matrix decomposition on the initial displacement matrix to obtain a distortion displacement matrix;
and the correction module is used for correcting the image to be corrected acquired by the C-arm machine by utilizing the distortion displacement matrix to obtain a corrected image.
9. The apparatus of claim 8, wherein the calibration image comprises a plurality of calibration balls;
the sampling module is specifically configured to identify a plurality of calibration balls in the calibration image to obtain center points of the plurality of calibration balls, and use the center points of the plurality of calibration balls as sampling points.
10. The apparatus according to claim 9, wherein the distance between two adjacent calibration balls in the first direction is a first preset value, the distance between two adjacent calibration balls in the second direction is a second preset value, and the first direction and the second direction are orthogonal; the plurality of calibration balls comprises a plurality of positioning calibration balls;
the first determining module includes:
the expansion submodule is used for carrying out one-dimensional expansion on the center point of the reference positioning calibration ball in the plurality of positioning calibration balls as a starting point in the first direction according to the first preset value and carrying out one-dimensional expansion on the center point of the plurality of positioning calibration balls in the second direction according to the second preset value to obtain the correction coordinates of the center points of the plurality of calibration balls;
and the obtaining sub-module is used for obtaining the distortion displacement of the plurality of sampling points based on the original coordinates of the central points of the plurality of calibration balls in the calibration image and the obtained corrected coordinates of the central points of the plurality of calibration balls.
11. The apparatus of claim 10, wherein the expansion submodule is specifically configured to:
taking a central point of a reference positioning calibration ball in the plurality of positioning calibration balls as a starting point, performing one-dimensional expansion in the first direction according to the first preset value, and performing one-dimensional expansion in the second direction according to the second preset value to obtain expanded coordinates of the central points of the plurality of expanded calibration balls;
and for each calibration ball, determining the expanded coordinate of the central point of the expanded calibration ball closest to the calibration ball according to the expanded coordinates of the central points of the expanded calibration balls and the original coordinate of the central point of the calibration ball in the calibration image, and taking the determined expanded coordinate of the central point of the expanded calibration ball as the correction coordinate of the central point of the calibration ball.
12. The apparatus of claim 10, wherein the plurality of calibration balls comprises three positioning calibration balls, the three positioning calibration balls being distributed in an L-shape; the reference positioning calibration ball is one of the two positioning calibration balls with the minimum distance.
13. The apparatus according to claim 12, wherein the distance between the two positioning calibration balls with the smallest distance in the first direction is less than or equal to a preset multiple of the first preset value, and the distance between the two positioning calibration balls with the smallest distance in the second direction is less than or equal to the preset multiple of the second preset value.
14. The apparatus according to any one of claims 8 to 13, wherein the prediction module is specifically configured to predict values of elements in the initial displacement matrix, except for elements corresponding to the plurality of sampling points, by using a deep learning framework or a gradient descent algorithm based on matrix decomposition to obtain a distortion displacement matrix.
15. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 7 when executing a program stored in the memory.
16. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 7.
CN202110348200.6A 2021-03-31 2021-03-31 Image correction method and device Active CN113066029B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110348200.6A CN113066029B (en) 2021-03-31 2021-03-31 Image correction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110348200.6A CN113066029B (en) 2021-03-31 2021-03-31 Image correction method and device

Publications (2)

Publication Number Publication Date
CN113066029A true CN113066029A (en) 2021-07-02
CN113066029B CN113066029B (en) 2023-03-17

Family

ID=76564810

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110348200.6A Active CN113066029B (en) 2021-03-31 2021-03-31 Image correction method and device

Country Status (1)

Country Link
CN (1) CN113066029B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108876749A (en) * 2018-07-02 2018-11-23 南京汇川工业视觉技术开发有限公司 A kind of lens distortion calibration method of robust
CN109461126A (en) * 2018-10-16 2019-03-12 重庆金山医疗器械有限公司 A kind of image distortion correction method and system
CN111047651A (en) * 2019-12-12 2020-04-21 中航华东光电有限公司 Method for correcting distorted image
CN112381739A (en) * 2020-11-23 2021-02-19 天津经纬恒润科技有限公司 Imaging distortion correction method and device of AR-HUD system
US20210084270A1 (en) * 2019-08-23 2021-03-18 Dualitas Ltd Holographic Projection

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108876749A (en) * 2018-07-02 2018-11-23 南京汇川工业视觉技术开发有限公司 A kind of lens distortion calibration method of robust
CN109461126A (en) * 2018-10-16 2019-03-12 重庆金山医疗器械有限公司 A kind of image distortion correction method and system
US20210084270A1 (en) * 2019-08-23 2021-03-18 Dualitas Ltd Holographic Projection
CN111047651A (en) * 2019-12-12 2020-04-21 中航华东光电有限公司 Method for correcting distorted image
CN112381739A (en) * 2020-11-23 2021-02-19 天津经纬恒润科技有限公司 Imaging distortion correction method and device of AR-HUD system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JIAWEN WENG.ET.: "Model-Free Lens Distortion Correction Based on Phase Analysis of Fringe-Patterns", 《SENSORS》 *
魏利胜等: "基于双经度模型的鱼眼图像畸变矫正方法", 《仪器仪表学报》 *

Also Published As

Publication number Publication date
CN113066029B (en) 2023-03-17

Similar Documents

Publication Publication Date Title
CN109345467B (en) Imaging distortion correction method, imaging distortion correction device, computer equipment and storage medium
US10417750B2 (en) Image processing method, device and photographic apparatus
JP2019079553A (en) System and method for detecting line in vision system
CN109840884B (en) Image stitching method and device and electronic equipment
US11435289B2 (en) Optical distortion measuring apparatus and optical distortion measuring method, image processing system, electronic apparatus and display apparatus
TWI435250B (en) Method for calibrating accuracy of optical touch monitor
CN110909663B (en) Human body key point identification method and device and electronic equipment
CN112070845A (en) Calibration method and device of binocular camera and terminal equipment
CN112241976A (en) Method and device for training model
CN111445537B (en) Calibration method and system of camera
CN112686824A (en) Image correction method, image correction device, electronic equipment and computer readable medium
KR20220073824A (en) Image processing method, image processing apparatus, and electronic device applying the same
CN108444452B (en) Method and device for detecting longitude and latitude of target and three-dimensional space attitude of shooting device
CN110542480B (en) Blind pixel detection method and device and electronic equipment
CN113066029B (en) Image correction method and device
CN107085843B (en) System and method for estimating modulation transfer function in optical system
CN113379845A (en) Camera calibration method and device, electronic equipment and storage medium
CN110852958B (en) Self-adaptive correction method and device based on object inclination angle
CN111353945B (en) Fisheye image correction method, device and storage medium
US20220237824A1 (en) Distortion calibration method for ultra-wide angle imaging apparatus, system and photographing device including same
CN112637587B (en) Dead pixel detection method and device
WO2023070409A1 (en) Image splicing method and apparatus
CN113205591A (en) Method and device for acquiring three-dimensional reconstruction training data and electronic equipment
CN113014928A (en) Compensation frame generation method and device
CN110728714B (en) Image processing method and device, storage medium and electronic equipment

Legal Events

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