CN111161140B - Distortion image correction method and device - Google Patents

Distortion image correction method and device Download PDF

Info

Publication number
CN111161140B
CN111161140B CN201811327232.2A CN201811327232A CN111161140B CN 111161140 B CN111161140 B CN 111161140B CN 201811327232 A CN201811327232 A CN 201811327232A CN 111161140 B CN111161140 B CN 111161140B
Authority
CN
China
Prior art keywords
image
pixel block
reference image
correction
width
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.)
Active
Application number
CN201811327232.2A
Other languages
Chinese (zh)
Other versions
CN111161140A (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.)
Watrix Technology Beijing Co ltd
Original Assignee
Watrix Technology Beijing 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 Watrix Technology Beijing Co ltd filed Critical Watrix Technology Beijing Co ltd
Priority to CN201811327232.2A priority Critical patent/CN111161140B/en
Publication of CN111161140A publication Critical patent/CN111161140A/en
Application granted granted Critical
Publication of CN111161140B publication Critical patent/CN111161140B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/80Geometric correction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4038Image mosaicing, e.g. composing plane images from plane sub-images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • G06T5/30Erosion or dilatation, e.g. thinning

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention provides a correction method of a distorted image, which comprises the steps of obtaining a reference image and a detection image. And comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree. Dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block, and calculating the corresponding actual width of each correction pixel block in the reference image. And scaling each correction pixel block according to the corresponding actual width of the correction pixel block in the reference image, and splicing the scaled correction pixel blocks to obtain a corrected image. The invention determines the dividing size of the correction pixel blocks according to the distortion degree of the object in the detection image, and can divide the detection image into a proper number of correction pixel blocks, thereby improving the correction calculation speed of the detection image, and realizing better distortion image correction effect under the condition of quicker correction calculation of the distortion image.

Description

Distortion image correction method and device
Technical Field
The embodiment of the invention relates to the technical field of track line detection, in particular to a method and a device for correcting a distorted image.
Background
At present, along with the construction and development of cities, the demand of rail traffic construction is gradually increased. In order to ensure driving safety, real-time detection of the environment on the whole line is required, and rapid response to abnormality (foreign matters, track deformation and the like) is realized. However, since the track is mostly built underground or on a viaduct, and the length of the line is continuously increased, the difficulty and cost of using manual detection are gradually increased. Automatic detection techniques based on deep neural networks are now gradually being used-by detecting that images returned by the cameras at regular time are automatically compared to determine if an anomaly has occurred. In the prior art, a deep learning method, such as a comparison network, is generally used to detect the returned image and the historical reference image at the pixel level so as to determine whether an abnormality occurs in the track environment. The comparison network realizes automatic detection of the track environment by utilizing machine vision and image processing technology, and has the advantages of high detection speed, high precision, good robustness, low cost and the like.
However, due to factors such as mechanical vibration, temperature and humidity variation and the like, radial nonlinear distortion exists in images shot at the same place angle and different times twice. Although the actual shooting place does not have any abnormality, some nonlinear radial distortion of the object in the detected image can occur, and false alarm can be generated in the comparison network, so that the accuracy is reduced.
Disclosure of Invention
Aiming at the defects that when a linear camera shoots, due to factors such as mechanical vibration, temperature and humidity change and the like, nonlinear radial distortion occurs to an object in a detection image, so that false alarm is generated on a comparison network and the precision is reduced. The embodiment of the invention provides a method for correcting a distorted image.
In a first aspect, an embodiment of the present invention provides a method for correcting a distorted image, including:
acquiring a reference image and a detection image;
comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree;
dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block, and calculating the corresponding actual width of each correction pixel block in the reference image;
and scaling each correction pixel block according to the corresponding actual width of each correction pixel block in the reference image, and splicing the correction pixel blocks to obtain a corrected image. .
In a second aspect, an embodiment of the present invention provides an apparatus for correcting a distorted image, including:
the acquisition module is used for acquiring a reference image and a detection image;
the comparison module is used for comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree;
the calculating module is used for dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block and calculating the corresponding actual width of each correction pixel block in the reference image;
and the splicing module is used for scaling each correction pixel block according to the corresponding actual width of the correction pixel block in the reference image, and splicing the correction pixel blocks to obtain a corrected image.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
at least one processor, at least one memory, a communication interface, and a bus; wherein,,
the processor, the memory and the communication interface complete the communication with each other through the bus;
the memory stores program instructions executable by the processor to invoke the method of correcting a distorted image provided by any of the various possible implementations of the first aspect.
In a fourth aspect, embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer instructions that cause a computer to perform a method of correcting a distorted image provided by any of various possible implementations of the first aspect.
According to the distortion image correction method and device, the detection image is divided into a plurality of correction pixel blocks to respectively calculate scaling coefficients of the correction pixel blocks, the actual width of each correction pixel block corresponding to the reference image is calculated, each correction pixel block is scaled to the actual width, and the corrected image is obtained through stitching. The problem of nonlinear radial distortion of objects in the detected image is solved. The invention determines the dividing size of the correction pixel blocks according to the distortion degree of the object in the detection image, and can divide the detection image into a proper number of correction pixel blocks, thereby improving the correction calculation speed of the detection image, and realizing better distortion image correction effect under the condition of quicker correction calculation of the distortion image.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a method for correcting a distorted image according to an embodiment of the present invention;
FIG. 2 is a block diagram of a device for correcting a distorted image according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or 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. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. The specific meaning of the above terms in the present invention can be understood by those of ordinary skill in the art according to the specific circumstances.
Fig. 1 is a flowchart of a method for correcting a distorted image according to an embodiment of the present invention. Referring to fig. 1, the method includes:
101, a reference image and a detection image are acquired.
102, comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree.
And 103, dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block from the boundary to the center of the detection image, and calculating the corresponding actual width of each correction pixel block in the reference image.
And 104, scaling each correction pixel block according to the corresponding actual width of each correction pixel block in the reference image, and splicing the correction pixel blocks to obtain a corrected image.
Because the track is mostly built underground or on viaducts, and the length of the line is continuously increased, the difficulty and cost of using manual detection are gradually increased. Automatic detection technology based on a deep neural network is gradually used, namely, whether abnormality occurs or not is judged by detecting that images returned by a camera at regular time are automatically compared.
In step 101, a reference image and a detection image are acquired.
Specifically, firstly, a historical image of a track line shot by a detection camera is selected as a reference image, and the reference image is used as a reference for correcting deformity in the subsequent flow of the invention. Then, the image captured at the same position and at a different time from the reference image is used as a detection image, and the deformity correction is performed. The reference image and the detection image are compared, and the shot object and the place are not changed due to the factors of temperature, humidity, light and the like, but the object in the detection image is subjected to nonlinear radial distortion.
And 102, comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree.
Since the object in the detected image is distorted nonlinearly, i.e. the boundary of the object in the radial direction may expand or contract, the entire image cannot be scaled with uniform parameters. Embodiments of the present invention require dividing the detected image into a plurality of rectified pixel blocks to calculate their scaling coefficients, respectively.
In general, the more correction pixel blocks are divided, the better the correction effect of the image is, but the slower the correction speed is, in order to solve the defect that the correction speed is slower due to the increase of the number of the divided correction pixel blocks, the embodiment compares the reference image and the detection image, determines the division size of the correction pixel blocks according to the distortion degree of the detection image, and can divide the detection image into a proper number of correction pixel blocks, thereby improving the correction calculation speed of the detection image, and ensuring that the correction effect is still better under the condition of higher algorithm speed.
And 103, dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block, and calculating the corresponding actual width of each correction pixel block in the reference image.
After determining the division size of the correction pixel block according to the distortion degree of the detection image, the present embodiment divides the detection image into a plurality of correction pixel blocks according to the size of the correction pixel block. Further, in order to ensure the correction speed of the detected image, only the left and right boundary points of each correction pixel block are taken as the feature vectors of the correction pixel blocks, each correction pixel block is traversed from the boundary to the center of the detected image, corresponding position coordinates are searched in the coordinate system of the reference image according to the feature vectors of the correction pixel blocks, and the corresponding actual width of each correction pixel block in the reference image is calculated.
And 104, finally, scaling each correction pixel block according to the corresponding actual width of the correction pixel block in the reference image, and splicing the correction pixel blocks to obtain a corrected image.
According to the distortion image correction method provided by the embodiment of the invention, the detection image is divided into a plurality of correction pixel blocks to respectively calculate the scaling coefficients of the correction pixel blocks, the actual width corresponding to each correction pixel block in the reference image is calculated, each correction pixel block is scaled into the actual width, and the corrected image is obtained by splicing. The problem of nonlinear radial distortion of objects in the detected image is solved. The invention determines the dividing size of the correction pixel blocks according to the distortion degree of the object in the detection image, and can divide the detection image into a proper number of correction pixel blocks, thereby improving the correction calculation speed of the detection image, and realizing better distortion image correction effect under the condition of quicker correction calculation of the distortion image.
Based on the above embodiment, in step 102, comparing the reference image with the detection image, and obtaining the distortion degree of the detection image specifically includes:
step 201, taking the left upper corner of a reference image as an origin, respectively taking directions parallel to the transverse edge and the longitudinal edge of the reference image as an x axis and a y axis downwards to the right, and establishing a two-dimensional coordinate system;
step 202, line pixels of a reference image and line pixels of a detection image are acquired respectively.
The value of the middle line pixel of the reference image is acquired to represent the reference image, the value of the middle line pixel of the detection image is acquired to represent the detection image, and the line pixels of the reference image and the line pixels of the detection image are obtained.
Step 203, converting each pixel value on the line pixels of the reference image into a feature vector related to the coordinate position of the pixel value; a feature vector set F of reference image line pixels is acquired.
The obtaining the feature vector set F of the reference image line pixels specifically includes:
for any pixel coordinate x of the reference image, taking the position of the pixel coordinate x as the center, respectively acquiring pixel values of 30px on the left and right sides of the pixel coordinate x to respectively form a 61-dimensional vector serving as a characteristic vector of the pixel coordinate positionObtaining a feature vector set of reference image line pixels +.>Wherein width is the width of the reference image and the detection image, m is the pixel, +.>Refers to the feature vector of any pixel m in the reference image line pixels. In the embodiment of the present invention, the widths of the reference image and the detection image are the same, and are both represented by width.
The acquisition formula of the feature vector of the reference image line pixel is as follows:
where P (x) refers to the pixel value of the pixel coordinate, and P (x) =0 when x <0 or x is greater than or equal to width (i.e., the value exceeds the reference image boundary).
Step 204, dividing the detected image into n pixel blocks; wherein n= [ width/a ]]Width is the width of the image, a is the width of the pixel block, and the width units are pixels []Represents rounding; acquiring feature vectors of coordinates l and r on left and right boundaries of line pixels of pixel blockAnd will->Respectively as the feature vectors of the left and right boundaries of the pixel block.
The width a of the pixel block is empirically valued, and in this embodiment, the reference image is empirically divided into a plurality of pixel blocks, and in this embodiment, the width of the pixel block is empirically valued to be 20 pixels.
Step 205, calculate respectivelyAnd->Euclidean distances to all elements in the feature vector set F are obtained separately +.>Similarity set a= { a with all elements in F m |0≤m<width }, ->Similarity set b= { B with all elements in F m |0≤m<width};
Wherein, the similarity formula is:
wherein m represents a pixel,feature vector representing pixel m, A m Representation->And->Similarity between B m Representation->And->Similarity between them.
And 206, sorting the elements in A and B to obtain the minimum element of the set A and the minimum element of the set B, wherein the minimum element and the minimum element are respectively used as actual coordinate values of coordinates l and r on the left and right boundaries of line pixels of the pixel block in the reference image.
In step 207, the distortion degree of the detected image is calculated based on the actual coordinate values of the coordinates l, r in the reference image on the left and right boundaries of the line pixels of the pixel block.
Based on the above embodiments, in step 207, calculating the distortion degree of the detected image according to the actual coordinate values of the coordinates l, r in the reference image on the left and right boundaries of the line pixel of the pixel block specifically includes:
calculating the actual width real_width of the pixel block in the reference image:
real_width=|rB–lA|
wherein lA and rB are respectively l and r are actual coordinate values in a reference image;
calculating a corrected width difference delta of the pixel block:
Δ= |a-real_width|, where a is the width of the correction block;
sequentially calculating the corrected width difference value of each pixel block to obtain a difference value set D;
D={Δ n |0<n<[width/a]}
taking the average value of the difference value set D as the distortion degree of the detection image
Based on the above embodiments, in step 102, calculating the size of the correction pixel block according to the distortion degree specifically includes:
correcting the size of a block of pixels
In the embodiment of the present invention, the pixel blocks and the correction pixel blocks represent different meanings, and the reference image is divided into a plurality of pixel blocks according to experience. And determining the optimal division size of the correction pixel block according to the distortion degree of the object in the detected image, and obtaining the correction pixel block.
According to the method and the device for correcting the distorted image, the dividing size of the corrected pixel blocks is determined according to the distortion degree of the object in the detected image, and the detected image can be divided into a proper number of corrected pixel blocks, so that the correction calculation speed of the detected image is improved, and the good distortion image correction effect is achieved under the condition that the correction calculation of the distorted image is faster.
Based on the above embodiments, in step 103, dividing the detected image into a plurality of correction pixel blocks according to the size of the correction pixel block specifically includes:
after the size of the correction pixel block is obtained, dividing the width of the detection image by the size of the correction pixel block to obtain the number of correction pixel blocks after the detection image is divided.
On the basis of the above embodiments, in step 103, traversing each correction pixel block from the boundary to the center of the detected image, calculating the actual width of each correction pixel block in the reference image specifically includes:
acquiring feature vectors of coordinates l ', r' on left and right boundaries of line pixels of a correction pixel blockAnd will beRespectively as the characteristic vectors of the left and right boundaries of the correction pixel block.
Separately calculateAnd->Euclidean distance between the pixel of the reference image line and all elements in the feature vector set F, and obtaining +.>Similarity set A' with all elements in F +.>Similarity set B' to all elements in F.
And sequencing the elements in the A 'and the B', and obtaining the minimum element of the set A 'and the minimum element of the set B', wherein the minimum element and the minimum element are respectively used as actual coordinate values of coordinates l ', r' on left and right boundaries of line pixels of the correction pixel block in a reference image.
Calculating the corresponding actual width of the correction pixel block in the reference image as |rB '-lA' |; where lA 'and rB' are actual coordinate values of l 'and r' in the reference image, respectively.
In this embodiment, only the left and right boundary points of each correction pixel block are taken as the feature vectors of the correction pixel block, and the corresponding position coordinates are searched in the coordinate system of the reference image according to the feature vectors of the correction pixel block, so as to calculate the corresponding actual width of each correction pixel block in the reference image. The correction calculation speed of the detection image is further improved.
Based on the foregoing embodiments, in step 104, scaling each correction pixel block according to the actual width of each correction pixel block corresponding to the reference image, and stitching the scaled correction pixel blocks, where obtaining the corrected image specifically includes:
scaling each correction pixel block to the corresponding actual width of each correction pixel block in the reference image by using a bicubic interpolation algorithm;
according to the dividing sequence when the detected image is divided into a plurality of corrected pixel blocks in step 103, the scaled corrected pixel blocks are spliced together in turn to form a corrected image.
According to the embodiment of the invention, the detection image is divided into a plurality of correction pixel blocks to respectively calculate the scaling coefficients of the correction pixel blocks, the corresponding actual width of each correction pixel block in the reference image is calculated, each correction pixel block is scaled into the corresponding actual width of each correction pixel block in the reference image by using a bicubic interpolation algorithm, and each scaled correction pixel block is spliced together in sequence to form a corrected image. The problem of nonlinear radial distortion of objects in the detected image is solved.
Fig. 2 is a block diagram of a distorted image correction device according to an embodiment of the present invention, and referring to fig. 2, the device includes an acquisition module 201, a comparison module 202, a calculation module 203, and a stitching module 204, where:
the acquisition module 201 is used for acquiring a reference image and a detection image. The comparison module 202 is configured to compare the reference image and the detection image, obtain a distortion degree of the detection image, and calculate a size of the correction pixel block according to the distortion degree. The calculating module 203 is configured to divide the detected image into a plurality of corrected pixel blocks according to the size of the corrected pixel block, traverse each corrected pixel block, and calculate the actual width of each corrected pixel block corresponding to the reference image. The stitching module 204 is configured to scale each correction pixel block according to the actual width of each correction pixel block in the reference image, and stitch the correction pixel blocks to obtain a corrected image.
In particular, since the track is mostly built underground or on a viaduct, and the length of the line is continuously increased, the difficulty and cost of using manual detection are gradually increased. Automatic detection technology based on a deep neural network is gradually used, namely, whether abnormality occurs or not is judged by detecting that images returned by a camera at regular time are automatically compared.
First, the acquisition module 201 selects a historical image of a track line captured by a detection camera as a reference image, and uses the reference image as a reference for correcting deformity in a subsequent process of the present invention. Then, the acquisition module 201 selects an image captured at the same position and at a different time from the reference image as a detection image, and performs deformity correction. The reference image and the detection image are compared, and the shot object and the place are not changed due to the factors of temperature, humidity, light and the like, but the object in the detection image is subjected to nonlinear radial distortion.
Further, since the object in the detected image is distorted nonlinearly, i.e., the boundary of the object in the radial direction may expand or contract, the entire image cannot be scaled using uniform parameters. Embodiments of the present invention require dividing the detected image into a plurality of rectified pixel blocks to calculate their scaling coefficients, respectively.
In general, the more correction pixel blocks are divided, the better the correction effect of the image is, but the slower the correction speed is, in order to solve the defect that the correction speed is slower due to the increase of the number of the divided correction pixel blocks, the comparison module 202 compares the reference image with the detection image, determines the division size of the correction pixel blocks according to the distortion degree of the detection image, and can divide the detection image into a proper number of correction pixel blocks, thereby improving the correction calculation speed of the detection image and ensuring that the correction effect is still better under the condition of higher algorithm speed.
The comparison module 202 is specifically configured to:
taking the left upper corner of the reference image as an origin, respectively taking the directions parallel to the transverse edge and the longitudinal edge of the reference image as an x axis and a y axis downwards to the right, and establishing a two-dimensional coordinate system;
line pixels of the reference image and line pixels of the detection image are acquired, respectively.
The value of the middle line pixel of the reference image is acquired to represent the reference image, the value of the middle line pixel of the detection image is acquired to represent the detection image, and the line pixels of the reference image and the line pixels of the detection image are obtained.
Converting each pixel value on the line pixels of the reference image into a feature vector associated with its coordinate position; a feature vector set F of reference image line pixels is acquired.
The obtaining the feature vector set F of the reference image line pixels specifically includes:
for any pixel coordinate x of the reference image, taking the position of the pixel coordinate x as the center, respectively acquiring pixel values of 30px on the left and right sides of the pixel coordinate x to respectively form a 61-dimensional vector serving as a characteristic vector of the pixel coordinate positionObtaining a feature vector set of reference image line pixels +.>Wherein width is the width of the reference image and the detection image, m represents the pixel, +.>A feature vector representing any one of the pixels m of the reference image line. In the embodiment of the present invention, the widths of the reference image and the detection image are the same, and are both represented by width.
The acquisition formula of the feature vector of the reference image line pixel is as follows:
where P (x) refers to the pixel value of the pixel coordinate, and P (x) =0 when x <0 or x is greater than or equal to width (i.e., the value exceeds the reference image boundary).
Dividing a detection image into n pixel blocks; wherein n= [ width/a ]]Width is the width of the image, a is the width of the pixel block, and the width units are pixels []Represents rounding; acquiring feature vectors of coordinates l and r on left and right boundaries of line pixels of pixel blockAnd will->Respectively as the feature vectors of the left and right boundaries of the pixel block.
In this embodiment, the reference image is divided into a plurality of pixel blocks according to experience, and in this embodiment, the width of the pixel blocks may take 20 pixels according to experience.
Separately calculateAnd->Euclidean distances to all elements in the feature vector set F are obtained separately +.>Similarity set a= { a with all elements in F m |0≤m<width }, ->Similarity set b= { B with all elements in F m |0≤m<width};
Wherein, the similarity formula is:
wherein m represents a pixel,feature vector representing pixel m, A m Representation->And->Similarity between B m Representation->And->Similarity between them.
And sorting the elements in the A and the B to obtain the minimum element of the set A and the minimum element of the set B, wherein the minimum element and the minimum element are respectively used as the actual coordinate values of the coordinates l and r in the reference image on the left and right boundaries of the line pixels of the pixel block.
Calculating the actual width real_width of the pixel block in the reference image:
real_width=|rB–lA|
wherein lA and rB are respectively l and r are actual coordinate values in a reference image;
calculating a corrected width difference delta of the pixel block:
Δ= |a-real_width|, where a is the width of the correction block;
sequentially calculating the corrected width difference value of each pixel block to obtain a difference value set D;
D={Δ n |0<n<[width/a]}
taking the average value of the difference value set D as the distortion degree of the detection image
Correcting the size of a block of pixels
The calculation module 203 divides the detected image into a plurality of corrected pixel blocks according to the sizes of the corrected pixel blocks, traverses each corrected pixel block from the boundary to the center of the detected image, and calculates the actual width of each corrected pixel block in the reference image.
After the size of the correction pixel block is obtained, dividing the width of the detection image by the size of the correction pixel block to obtain the number of correction pixel blocks after the detection image is divided.
In order to further ensure the correction speed of the detection image, only the left and right boundary points of each correction pixel block are taken as the characteristic vectors of the correction pixel blocks, corresponding position coordinates are searched in the coordinate system of the reference image according to the characteristic vectors of the correction pixel blocks, and the corresponding actual width of each correction pixel block in the reference image is calculated.
Finally, the stitching module 204 zooms each correction pixel block according to the actual width of each correction pixel block corresponding to the reference image, and stitches the zoomed correction pixel blocks to obtain a corrected image.
Specifically, each correction pixel block is scaled to the corresponding actual width of each correction pixel block in the reference image using a bicubic interpolation algorithm. According to the dividing sequence when the detection image is divided into a plurality of correction pixel blocks by the calculating module 203, the scaled correction pixel blocks are spliced together in turn to form a corrected image.
According to the correcting device for the distorted image, provided by the embodiment of the invention, the detection image is divided into a plurality of corrected pixel blocks to respectively calculate the scaling coefficients of the corrected pixel blocks, the actual width corresponding to each corrected pixel block in the reference image is calculated, each corrected pixel block is scaled into the actual width, and the corrected image is obtained by splicing. The problem of nonlinear radial distortion of objects in the detected image is solved. The invention determines the dividing size of the correction pixel blocks according to the distortion degree of the object in the detection image, and can divide the detection image into a proper number of correction pixel blocks, thereby improving the correction calculation speed of the detection image, and realizing better distortion image correction effect under the condition of quicker correction calculation of the distortion image.
An embodiment of the present invention provides an electronic device, and fig. 3 is a schematic structural diagram of the electronic device provided according to the embodiment of the present invention, as shown in fig. 3, where the electronic device includes:
at least one processor (processor) 301, a communication interface (Communications Interface) 304, at least one memory (memory) 302, and a communication bus 303, wherein the at least one processor 301, the communication interface 304, and the at least one memory 302 communicate with each other via the communication bus 303. The at least one processor 301 may invoke logic instructions in the at least one memory 302 to perform the method of correcting distorted images as follows: a reference image and a detection image are acquired. And comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree. Dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block, and calculating the corresponding actual width of each correction pixel block in the reference image. And scaling each correction pixel block according to the corresponding actual width of each correction pixel block in the reference image, and splicing the scaled correction pixel blocks to obtain a corrected image.
The embodiment of the present invention also provides a non-transitory computer readable storage medium storing computer instructions that cause a computer to execute the method for correcting a distorted image provided by the corresponding embodiment, for example, including: a reference image and a detection image are acquired. And comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree. Dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block, and calculating the corresponding actual width of each correction pixel block in the reference image. And scaling each correction pixel block according to the corresponding actual width of each correction pixel block in the reference image, and splicing the scaled correction pixel blocks to obtain a corrected image.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware associated with program instructions, where the foregoing program may be stored in a computer readable storage medium, and when executed, the program performs steps including the above method embodiments; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (9)

1. A method of correcting a distorted image, comprising:
101, acquiring a reference image and a detection image;
102, comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree;
103, dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block, and calculating the corresponding actual width of each correction pixel block in the reference image;
104, scaling each correction pixel block according to the corresponding actual width of each correction pixel block in the reference image, and splicing the scaled correction pixel blocks to obtain a corrected image;
in step 102, the comparing the reference image with the detection image to obtain the distortion degree of the detection image specifically includes:
201, taking the left upper corner of a reference image as an origin, taking the directions parallel to the transverse edge and the longitudinal edge of the reference image as an x axis and a y axis downwards to the right, and establishing a two-dimensional coordinate system;
202, respectively acquiring line pixels of a reference image and line pixels of a detection image;
203 converting each pixel value on the line pixels of the reference image into a feature vector associated with its coordinate position; acquiring a feature vector set F of pixels of a reference image line;
204, dividing the detection image into n piecesA pixel block; wherein n= [ width/a ]]Width is the width of the image, a is the width of the pixel block, []Represents rounding; acquiring feature vectors of coordinates l and r on left and right boundaries of line pixels of pixel blockAnd will->Feature vectors respectively serving as left and right boundaries of the pixel block;
205, respectively calculateAnd->Euclidean distances to all elements in the feature vector set F are obtained separately +.>Similarity set A with all elements in F, and +.>Similarity set B with all elements in F;
206, sorting the elements in A and B to obtain the minimum element of the set A and the minimum element of the set B, wherein the minimum element and the minimum element are respectively used as the actual coordinate values of the coordinates l and r in the reference image on the left and right boundaries of the line pixels of the pixel block;
207, calculating the distortion degree of the detection image according to the actual coordinate value of the coordinates l and r on the left and right boundaries of the line pixels of the pixel block in the reference image.
2. The method for correcting a distorted image according to claim 1, wherein in step 207, calculating the distortion degree of the detected image based on the actual coordinate values of the coordinates l, r in the reference image on the left and right boundaries of the line pixels of the pixel block specifically includes:
calculating the actual width real_width of the pixel block in the reference image:
real_width=|rB-lA|
wherein lA and rB are respectively l and r are actual coordinate values in a reference image;
calculating a corrected width difference delta of the pixel block:
Δ= |a-real_width|, where a is the width of the correction block;
sequentially calculating the corrected width difference value of each pixel block to obtain a difference value set D;
D={Δ n |0<n<[width/a]}
taking the average value of the difference value set D as the distortion degree of the detection image
3. The method for correcting a distorted image according to claim 2, wherein in step 102, calculating the size of the corrected pixel block according to the degree of distortion specifically includes:
correcting the size of a block of pixels
4. A method of correcting a distorted image according to claim 3, wherein in step 103, dividing the detected image into a plurality of corrected pixel blocks according to the size of the corrected pixel block specifically comprises:
dividing the width of the detection image by the size of the correction pixel blocks to obtain the number of the correction pixel blocks after the detection image is divided.
5. The method according to claim 4, wherein in step 103, traversing each correction pixel block, and calculating the actual width of each correction pixel block in the reference image specifically includes:
acquiring feature vectors of coordinates l ', r' on left and right boundaries of line pixels of a correction pixel blockAnd will->Respectively serving as characteristic vectors of the left and right boundaries of the correction pixel block;
separately calculateAnd->Euclidean distances from all elements in the feature vector set F of the reference image line pixels are obtained respectively +.>Similarity set A' with all elements in F +.>A similarity set B' with all elements in F;
sorting the elements in A 'and B' to obtain the minimum element of the set A 'and the minimum element of the set B' which are respectively used as actual coordinate values of coordinates l ', r' on left and right boundaries of line pixels of the correction pixel block in a reference image;
calculating the corresponding actual width of the correction pixel block in the reference image as |rB '-lA' |; where lA 'and rB' are actual coordinate values of l 'and r' in the reference image, respectively.
6. The method for correcting a distorted image according to claim 5, wherein in step 104, scaling each corrected pixel block according to the actual width of each corrected pixel block in the reference image, and stitching the scaled corrected pixel blocks to obtain the corrected image specifically includes:
scaling each correction pixel block to the corresponding actual width of each correction pixel block in the reference image by using a bicubic interpolation algorithm;
according to the dividing sequence when the detected image is divided into a plurality of corrected pixel blocks in step 103, the scaled corrected pixel blocks are spliced together in turn to form a corrected image.
7. An apparatus for correcting a distorted image, comprising:
the acquisition module is used for acquiring a reference image and a detection image;
the comparison module is used for comparing the reference image with the detection image, obtaining the distortion degree of the detection image, and calculating the size of the correction pixel block according to the distortion degree;
the calculating module is used for dividing the detection image into a plurality of correction pixel blocks according to the sizes of the correction pixel blocks, traversing each correction pixel block and calculating the corresponding actual width of each correction pixel block in the reference image;
the splicing module is used for scaling each correction pixel block according to the corresponding actual width of the correction pixel block in the reference image, and splicing the correction pixel blocks to obtain a corrected image;
wherein, the comparison module is specifically used for:
taking the left upper corner of the reference image as an origin, respectively taking the directions parallel to the transverse edge and the longitudinal edge of the reference image as an x axis and a y axis downwards to the right, and establishing a two-dimensional coordinate system;
respectively acquiring line pixels of a reference image and line pixels of a detection image;
converting each pixel value on the line pixels of the reference image into a feature vector associated with its coordinate position; acquiring a feature vector set F of pixels of a reference image line;
dividing a detection image into n pixel blocks; wherein n= [ width/a ]]Width is the width of the image, a is the width of the pixel block, []Represents rounding; acquiring line images of pixel blocksFeature vector of coordinates l, r on left and right boundaries of elementAnd will beFeature vectors respectively serving as left and right boundaries of the pixel block;
separately calculateAnd->Euclidean distances to all elements in the feature vector set F are obtained separately +.>Similarity set A with all elements in F, and +.>Similarity set B with all elements in F;
sorting the elements in A and B to obtain the minimum element of the set A and the minimum element of the set B, wherein the minimum element and the minimum element are respectively used as the actual coordinate values of the coordinates l and r in the reference image on the left and right boundaries of the line pixels of the pixel block;
the distortion degree of the detection image is calculated according to the actual coordinate value of the coordinates l and r on the left and right boundaries of the line pixels of the pixel block in the reference image.
8. An electronic device, comprising:
at least one processor, at least one memory, a communication interface, and a bus; wherein,,
the processor, the memory and the communication interface complete the communication with each other through the bus;
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of claims 1-6.
9. A non-transitory computer readable storage medium storing computer instructions that cause the computer to perform the method of any one of claims 1 to 6.
CN201811327232.2A 2018-11-08 2018-11-08 Distortion image correction method and device Active CN111161140B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811327232.2A CN111161140B (en) 2018-11-08 2018-11-08 Distortion image correction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811327232.2A CN111161140B (en) 2018-11-08 2018-11-08 Distortion image correction method and device

Publications (2)

Publication Number Publication Date
CN111161140A CN111161140A (en) 2020-05-15
CN111161140B true CN111161140B (en) 2023-09-19

Family

ID=70555238

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811327232.2A Active CN111161140B (en) 2018-11-08 2018-11-08 Distortion image correction method and device

Country Status (1)

Country Link
CN (1) CN111161140B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111681186A (en) * 2020-06-10 2020-09-18 创新奇智(北京)科技有限公司 Image processing method and device, electronic equipment and readable storage medium
CN111986089A (en) * 2020-08-28 2020-11-24 计易数据科技(上海)有限公司 Image storage and comparison method, device, equipment and medium with characteristic value being integer
CN112288710A (en) * 2020-10-28 2021-01-29 哈尔滨工程大学 Automatic solution method for spray penetration distance and cone angle of marine diesel engine porous spray image

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103279939A (en) * 2013-04-27 2013-09-04 北京工业大学 Image stitching processing system
JP2013239791A (en) * 2012-05-11 2013-11-28 Canon Inc Image processing device, image processing method, and program
JP2014010776A (en) * 2012-07-02 2014-01-20 Canon Inc Image processing apparatus, image processing method, and program
CN103810678A (en) * 2014-01-21 2014-05-21 公安部第一研究所 Distorted image rectification method of back scattering X-ray huma body safety check equipment
CN105096269A (en) * 2015-07-21 2015-11-25 北京交通大学 Radial image distortion rectifying method and system based on distorted linear structure detection
CN105825203A (en) * 2016-03-30 2016-08-03 大连理工大学 Ground arrowhead sign detection and identification method based on dotted pair matching and geometric structure matching
CN105959514A (en) * 2016-04-20 2016-09-21 河海大学 Weak target imaging detection device and method
CN106295478A (en) * 2015-06-04 2017-01-04 深圳市中兴微电子技术有限公司 A kind of image characteristic extracting method and device
CN106327441A (en) * 2016-08-19 2017-01-11 北京交通大学 Image radial distortion automatic correction method and system
CN106657789A (en) * 2016-12-29 2017-05-10 核动力运行研究所 Thread panoramic image synthesis method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7620246B2 (en) * 2002-07-30 2009-11-17 Fujifilm Corporation Method and apparatus for image processing
TWI423659B (en) * 2010-11-09 2014-01-11 Avisonic Technology Corp Image corretion method and related image corretion system thereof
JP6352050B2 (en) * 2014-05-19 2018-07-04 キヤノンメディカルシステムズ株式会社 Ultrasonic diagnostic equipment

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013239791A (en) * 2012-05-11 2013-11-28 Canon Inc Image processing device, image processing method, and program
JP2014010776A (en) * 2012-07-02 2014-01-20 Canon Inc Image processing apparatus, image processing method, and program
CN103279939A (en) * 2013-04-27 2013-09-04 北京工业大学 Image stitching processing system
CN103810678A (en) * 2014-01-21 2014-05-21 公安部第一研究所 Distorted image rectification method of back scattering X-ray huma body safety check equipment
CN106295478A (en) * 2015-06-04 2017-01-04 深圳市中兴微电子技术有限公司 A kind of image characteristic extracting method and device
CN105096269A (en) * 2015-07-21 2015-11-25 北京交通大学 Radial image distortion rectifying method and system based on distorted linear structure detection
CN105825203A (en) * 2016-03-30 2016-08-03 大连理工大学 Ground arrowhead sign detection and identification method based on dotted pair matching and geometric structure matching
CN105959514A (en) * 2016-04-20 2016-09-21 河海大学 Weak target imaging detection device and method
CN106327441A (en) * 2016-08-19 2017-01-11 北京交通大学 Image radial distortion automatic correction method and system
CN106657789A (en) * 2016-12-29 2017-05-10 核动力运行研究所 Thread panoramic image synthesis method

Also Published As

Publication number Publication date
CN111161140A (en) 2020-05-15

Similar Documents

Publication Publication Date Title
CN110414507B (en) License plate recognition method and device, computer equipment and storage medium
CN111161140B (en) Distortion image correction method and device
CN106296578B (en) Image processing method and device
CN112598922B (en) Parking space detection method, device, equipment and storage medium
CN111105452B (en) Binocular vision-based high-low resolution fusion stereo matching method
CN108898148A (en) A kind of digital picture angular-point detection method, system and computer readable storage medium
CN113066088A (en) Detection method, detection device and storage medium in industrial detection
CN113469201A (en) Image acquisition equipment offset detection method, image matching method, system and equipment
CN110472640B (en) Target detection model prediction frame processing method and device
CN112330618B (en) Image offset detection method, device and storage medium
CN117252815A (en) Industrial part defect detection method, system, equipment and storage medium based on 2D-3D multi-mode image
WO2014054124A1 (en) Road surface markings detection device and road surface markings detection method
CN110866484A (en) Driver face detection method, computer device and computer readable storage medium
CN113096090B (en) End face gap visual measurement method with chamfer, device, equipment and storage medium
CN116363064A (en) Defect identification method and device integrating target detection model and image segmentation model
CN111488762A (en) Lane-level positioning method and device and positioning equipment
CN115170489A (en) Method and device for identifying and measuring steel bars
CN110706263B (en) Image processing method, device, equipment and computer readable storage medium
CN113469955A (en) Photovoltaic module fault area image detection method and system
JPH11219435A (en) White line detector for automobile
CN114322793B (en) Workpiece size measuring method and device based on global segmentation network and storage medium
CN117593516B (en) Target detection method, device, equipment and storage medium
JP2015125695A (en) Traffic lane identification device and traffic lane identification method
CN113469299B (en) Defect detection method and defect detection device in industrial detection
CN118096751A (en) Injection molding appearance defect detection method and device, electronic equipment and storage medium

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