Summary of the invention
The present invention provides a kind of method, apparatus of correcting distorted image, abnormal to solve correction existing in the prior art
Become the lower technical problem of the processing speed of image.
In a first aspect, in order to solve the above technical problems, a kind of small method of correcting distorted figure provided in an embodiment of the present invention
Technical solution it is as follows:
The initial data of point-by-point reception fault image line by line;
By the drawing coefficient and correction coefficient of setting, every row pixel of the fault image received is stretched
It is corrected simultaneously, until obtaining the distortion after completing to the stretching and calibration of the last line pixel of the fault image
The correction image of image;
Wherein, the drawing coefficient is the multiple for stretching the fault image, and the correction coefficient is as described in acquisition
What the radial distortion parameter and tangential distortion parameter of optical lens used in fault image determined, it is every in the fault image
A original pixel has one group of correction coefficient, and corresponding with a correction pixels in the correction image.
Pass through the initial data of reception fault image point-by-point line by line;By the drawing coefficient and correction coefficient of setting, docking
Every row pixel of the fault image received is corrected while stretching, until completing the last line picture to fault image
After the stretching and calibration of element, the correction image of fault image is obtained;Wherein, drawing coefficient is the multiple for stretching fault image,
Correction coefficient is that the radial distortion parameter of the optical lens as used in acquisition fault image and tangential distortion parameter determine, abnormal
The each original pixel become in image has one group of correction coefficient, and corresponding with a correction pixels in correction image.Due to
It is corrected while stretching during receiving fault image to every row pixel of fault image, so that receiving one
The initial data of fault image just completes the correction of a part of fault image, has received the original number of last part fault image
According to rear, the correction to the complete initial data of fault image is just completed, to effectively raise the processing speed of correcting distorted image
Degree, and the initial data of complete fault image is stored in advance due to being not necessarily to during correcting distorted image,
So storage resource has also effectively been saved, so that above scheme provided by the invention when being handled using FPGA, can have
The processing speed of the raising FPGA of effect, the storage resource for saving FPGA.
Optionally, by the drawing coefficient of setting and correction coefficient, to every row pixel of the fault image received into
Row is corrected while stretching, comprising:
The initial data for often receiving the one-row pixels point of the fault image, just according to the drawing coefficient to described one
Row pixel is stretched, the one-row pixels point of the fault image after being stretched;
While stretching the one-row pixels point, with the corresponding one group of correction coefficient of each original pixel, to described
Multiple adjacent pixels of corresponding correction pixels and the correction pixels are corrected in correction image;
Wherein, the number of the corresponding one group of correction coefficient of each original pixel and the correction pixels and the multiple neighbour
The number of pixels of pixel is identical, and the coverage area of each original pixel after the stretch is in the correction pixels and the multiple neighbour
In the coverage area of pixel, the multiple neighbour's pixel is adjacent picture of the correction pixels on the fault image draw direction
Element.
Optionally, with the corresponding one group of correction coefficient of each original pixel, to corresponding correction in the correction image
Pixel and multiple adjacent pixels of the correction pixels are corrected, comprising:
Based on the index of each original pixel in the fault image, each preimage is obtained from default correction coefficient table
The corresponding one group of correction coefficient of element;Wherein, the default correction coefficient table is the index of each original pixel in the fault image
With the mapping relations of one group of correction coefficient and corresponding correction pixels;
It is corresponding to calculate each original pixel for original pixel value and corresponding correction coefficient based on each original pixel
The pixel value of correction pixels;And by the pixel value of the correction pixels, as the correction pixels and corresponding multiple adjacent pixels
Pixel correction value, while the correction pixels and the multiple adjacent pixel are written into the correction chart in the pixel correction value
Respective memory locations in the correspondence memory block of picture;Wherein, for same pixel, there are multiple pixels in the correction image
Corrected value, the pixel correction value before the pixel correction value replacement obtained after.
Optionally, the index based on each original pixel in the fault image, from default correction coefficient table described in acquisition
The corresponding one group of correction coefficient of each original pixel, comprising:
Used line synchronising signal and frame synchronizing signal and timeticks when according to the acquisition fault image, really
Head office's columns of the fixed fault image;Wherein, the corresponding width fault image of each frame synchronizing signal, each line synchronising signal pair
Answer the one-row pixels in the width fault image, the corresponding original pixel of each timeticks;
The ranks number of total columns and each original pixel based on the fault image, determines each original pixel
Index;
Based on the index of each original pixel, it is corresponding that each original pixel is obtained from the default correction coefficient table
One group of correction coefficient and correction pixels.
Optionally, formula used in the pixel value of the corresponding correction pixels of each original pixel is calculated specifically:
Pi,i(W, H)=(Ci,0 +Ci,1+..+Ci,j) × Pi(x, y);
Wherein, Pi,i(W, H) is the pixel value of the correction pixels, PiThe pixel value of (x, y) described each original pixel, i are
The index of each original pixel, the number that j is one group of correction coefficient, x, y are respectively each original pixel described
Ranks number in fault image, W, H are respectively ranks number of the correction pixels in the correction image, Ci,0 ~Ci,jFor institute
State the corresponding one group of correction coefficient of each original pixel.
Optionally, the correction pixels and the multiple adjacent pixel are written into the correction image in the pixel correction value
Correspondence memory block in respective memory locations before, further includes:
Long-pending operation is carried out with the drawing coefficient to total columns of the fault image, total line number respectively, obtains the school
The maximum virtual value of the line number of positive pixel, columns;
Based on the index of the corresponding original pixel of the correction pixels, the correction is obtained from the default correction coefficient table
The ranks number of pixel, judges whether the ranks number of the correction pixels is not more than the line number of the correction pixels, the maximum of columns
Virtual value;
If YES then determining that the correction pixels are effective correction pixels, the correction is written into the pixel correction value
The respective memory locations of pixel and the multiple adjacent pixel in the correspondence memory block of the correction image.
Optionally, the correction pixels and the multiple adjacent pixel are written into the correction image in the pixel correction value
Correspondence memory block in respective memory locations, comprising:
Long-pending operation is carried out to drawing coefficient described in total columns of the fault image and the line number of each pixel, is obtained intermediate
As a result;Wherein, each pixel is any one pixel in the correction pixels and the multiple adjacent pixel;
Columns progress and operation to the intermediate result and each pixel, with obtaining the storage of each pixel
The index of location;
The index of the storage address of initial address and each pixel based on the correction image, by the pixel school
Each corresponding storage location of pixel is written in positive value.
Optionally, the method also includes:
If retaining the complete marginal information of the correction image, the drawing coefficient is set greater than to 1 value;
If keeping the correction image identical as the size of the fault image, set the value of the drawing coefficient to
1。
Second aspect, the embodiment of the invention provides a kind of devices for correcting distorted image, comprising:
Receiving unit, the initial data for reception fault image point-by-point line by line;
Unit is corrected, every row for the drawing coefficient and correction coefficient by setting, to the fault image received
It is corrected while pixel is stretched, until completing the stretching and calibration to the last line pixel of the fault image
Afterwards, the correction image of the fault image is obtained;Wherein, the drawing coefficient is the multiple for stretching the fault image, institute
Stating correction coefficient is that radial distortion parameter as acquiring optical lens used in the fault image and tangential distortion parameter are true
Fixed, each original pixel in the fault image has one group of correction coefficient, and corrects with one in the correction image
Pixel is corresponding.
Optionally, the correction unit is used for:
The initial data for often receiving the one-row pixels point of the fault image, just according to the drawing coefficient to described one
Row pixel is stretched, the one-row pixels point of the fault image after being stretched;
While stretching the one-row pixels point, with the corresponding one group of correction coefficient of each original pixel, to described
Multiple adjacent pixels of corresponding correction pixels and the correction pixels are corrected in correction image;
Wherein, the number of the corresponding one group of correction coefficient of each original pixel and the correction pixels and the multiple neighbour
The number of pixels of pixel is identical, and the coverage area of each original pixel after the stretch is in the correction pixels and the multiple neighbour
In the coverage area of pixel, the multiple neighbour's pixel is adjacent picture of the correction pixels on the fault image draw direction
Element.
Optionally, the correction unit is used for:
Based on the index of each original pixel in the fault image, each preimage is obtained from default correction coefficient table
The corresponding one group of correction coefficient of element;Wherein, the default correction coefficient table is the index of each original pixel in the fault image
With the mapping relations of one group of correction coefficient and corresponding correction pixels;
It is corresponding to calculate each original pixel for original pixel value and corresponding correction coefficient based on each original pixel
The pixel value of correction pixels;And by the pixel value of the correction pixels, as the correction pixels and corresponding multiple adjacent pixels
Pixel correction value, while the correction pixels and the multiple adjacent pixel are written into the correction chart in the pixel correction value
Respective memory locations in the correspondence memory block of picture;Wherein, for same pixel, there are multiple pixels in the correction image
Corrected value, the pixel correction value before the pixel correction value replacement obtained after.
Optionally, the correction unit is used for:
Used line synchronising signal and frame synchronizing signal and timeticks when according to the acquisition fault image, really
Head office's columns of the fixed fault image;Wherein, the corresponding width fault image of each frame synchronizing signal, each line synchronising signal pair
Answer the one-row pixels in the width fault image, the corresponding original pixel of each timeticks;
The ranks number of total columns and each original pixel based on the fault image, determines each original pixel
Index;
Based on the index of each original pixel, it is corresponding that each original pixel is obtained from the default correction coefficient table
One group of correction coefficient and correction pixels.
Optionally, formula used in the pixel value of the corresponding correction pixels of each original pixel is calculated specifically:
Pi,i(W, H)=(Ci,0 +Ci,1+..+Ci,j) × Pi(x, y);
Wherein, Pi,i(W, H) is the pixel value of the correction pixels, PiThe pixel value of (x, y) described each original pixel, i are
The index of each original pixel, the number that j is one group of correction coefficient, x, y are respectively each original pixel described
Ranks number in fault image, W, H are respectively ranks number of the correction pixels in the correction image, Ci,0 ~Ci,jFor institute
State the corresponding one group of correction coefficient of each original pixel.
Optionally, the correction unit is also used to:
Long-pending operation is carried out with the drawing coefficient to total columns of the fault image, total line number respectively, obtains the school
The maximum virtual value of the line number of positive pixel, columns;
Based on the index of the corresponding original pixel of the correction pixels, the correction is obtained from the default correction coefficient table
The ranks number of pixel, judges whether the ranks number of the correction pixels is not more than the line number of the correction pixels, the maximum of columns
Virtual value;
If YES then determining that the correction pixels are effective correction pixels, the correction is written into the pixel correction value
The respective memory locations of pixel and the multiple adjacent pixel in the correspondence memory block of the correction image.
Optionally, the correction unit is used for:
Long-pending operation carried out to total columns of the fault image and the line number of each pixel and the drawing coefficient, in acquisition
Between result;
Columns progress and operation to the intermediate result and each pixel, with obtaining the storage of each pixel
The index of location;
The index of the storage address of initial address and each pixel based on the correction image, by the pixel school
Each corresponding storage location of pixel is written in positive value.
Optionally, the correction unit is also used to:
If retaining the complete marginal information of the correction image, the drawing coefficient is set greater than to 1 value;
If keeping the correction image identical as the size of the fault image, set the value of the drawing coefficient to
1。
The technical solution in said one or multiple embodiments through the embodiment of the present invention, the embodiment of the present invention at least have
There is following technical effect:
In embodiment provided by the invention, pass through the initial data of reception fault image point-by-point line by line;By setting
Drawing coefficient and correction coefficient are corrected while stretching to every row pixel of the fault image received, until complete
After the stretching and calibration of the last line pixel of pairs of fault image, the correction image of fault image is obtained;Wherein, drawing coefficient
For the multiple for stretching fault image, correction coefficient is the radial distortion parameter of the optical lens as used in acquisition fault image
Determined with tangential distortion parameter, each original pixel in fault image has one group of correction coefficient, and in correction image
One correction pixels is corresponding.While due to being stretched during receiving fault image to every row pixel of fault image
It is corrected, so that the initial data for receiving a fault image just completes the correction of a part of fault image, has received most
After the initial data of rear portion fault image, the correction to the complete initial data of fault image is just completed, to effectively mention
The high processing speed of correcting distorted image, and due to without in advance to complete distortion during correcting distorted image
The initial data of image is stored, so storage resource has also effectively been saved, so that above scheme provided by the invention exists
When being handled using FPGA, it can effectively improve the processing speed of FPGA, save the storage resource of FPGA.
Further, the correction system of original pixel is quickly found out from default correction coefficient table by the index by original pixel
Number, and corrected in time after finding correction coefficient, so that without the address relationship table for storing correction image and fault image,
Correction coefficient only need to be stored, to reduce the difficulty of index, improves the treatment effeciency of correcting distorted image.
Further, since embodiment provided by the invention is stretched to the partial data of the fault image received
While be corrected, so entire correction course is without storing complete fault image, so as to effectively save storage
Space reduces hardware cost.
Further, due to embodiment provided by the invention when correcting image using the mode of stretching, as long as school
The size of positive image allows, and can retain the marginal information of image, to avoid the loss of critical data, promote the processing of correction
Speed.
Specific embodiment
Implementation column of the present invention provides a kind of method, apparatus of correcting distorted image, to solve school existing in the prior art
The lower technical problem of the processing speed of pincushion distortion image.
In order to solve the above technical problems, general thought is as follows for technical solution in the embodiment of the present application:
There is provided a kind of method of correcting distorted image, comprising: the initial data of point-by-point reception fault image line by line;By setting
Fixed drawing coefficient and correction coefficient is corrected, directly while stretching to every row pixel of the fault image received
To after completing to the stretching and calibration of the last line pixel of fault image, the correction image of fault image is obtained;Wherein, it stretches
Coefficient is the multiple for stretching fault image, and correction coefficient is the radial distortion of the optical lens as used in acquisition fault image
What parameter and tangential distortion parameter determined, each original pixel in fault image has one group of correction coefficient, and with correction image
In a correction pixels it is corresponding.
Due in the above scheme, passing through the initial data of reception fault image point-by-point line by line;By the stretching system of setting
Several and correction coefficient, is corrected while stretching to every row pixel of the fault image received, until completing to abnormal
After becoming the stretching and calibration of the last line pixel of image, the correction image of fault image is obtained;Wherein, drawing coefficient be will be abnormal
Become the multiple of image stretch, correction coefficient is the radial distortion parameter of the optical lens as used in acquisition fault image and tangential
What distortion parameter determined, each original pixel in fault image has one group of correction coefficient, and with a school in correction image
Positive pixel is corresponding.Due to carrying out school while stretching during receiving fault image to every row pixel of fault image
Just, so that the initial data for receiving a fault image just completes the correction of a part of fault image, last portion has been received
After dividing the initial data of fault image, the correction to the complete initial data of fault image is just completed, to effectively raise school
The processing speed of pincushion distortion image, and due to without in advance to complete fault image during correcting distorted image
Initial data is stored, so storage resource has also effectively been saved, so that above scheme provided by the invention is using
When FPGA is handled, it can effectively improve the processing speed of FPGA, save the storage resource of FPGA.
In order to better understand the above technical scheme, below by attached drawing and specific embodiment to technical solution of the present invention
It is described in detail, it should be understood that the specific features in the embodiment of the present invention and embodiment are to the detailed of technical solution of the present invention
Thin explanation, rather than the restriction to technical solution of the present invention, in the absence of conflict, the embodiment of the present invention and embodiment
In technical characteristic can be combined with each other.
Referring to FIG. 1, the embodiment of the present invention provides a kind of method of correcting distorted figure, the treatment process of this method is as follows.
Step 101: the initial data of point-by-point reception fault image line by line;
Step 102: by the drawing coefficient and correction coefficient of setting, every row pixel of the fault image received being drawn
It is corrected while stretching, until obtaining fault image after completing to the stretching and calibration of the last line pixel of fault image
Correction image;Wherein, drawing coefficient is the multiple for stretching fault image, and correction coefficient is used by acquisition fault image
Optical lens radial distortion parameter and tangential distortion parameter determine that each original pixel in fault image has one group of school
Positive coefficient, and it is corresponding with a correction pixels in correction image.
Specifically, drawing by the drawing coefficient and correction coefficient of setting every row pixel of the fault image received
It is corrected, can be accomplished by the following way while stretching:
Firstly, the initial data of the one-row pixels point of fault image is often received, just according to drawing coefficient to one-row pixels
Point is stretched, the one-row pixels point of the fault image after being stretched.
Secondly, while stretching one-row pixels point, with the corresponding one group of correction coefficient of each original pixel, to correction image
In multiple adjacent pixels of corresponding correction pixels and correction pixels be corrected.
Wherein, the pixel of the number of the corresponding one group of correction coefficient of each original pixel and correction pixels and multiple adjacent pixels
Number is identical, and the coverage area of each original pixel after the stretch is in the coverage area of correction pixels and multiple adjacent pixels, Duo Gelin
Pixel is adjacent pixel of the correction pixels on fault image draw direction.
For example, it is assumed that fault image is the image of 640 × 640 pixels, drawing coefficient 1.5 is receiving fault image
The first row pixel (640 pixels of the first row) after, 640 pixels of this row are stretched 1.5 times, then in fault image the
Each original pixel corresponding one group of correction coefficient is to each correction pixels and each correction pixels after stretching in one-row pixels
Adjacent pixel is corrected, such as correction pixels are P(W, H), wherein W is the line number of correction pixels, and H is the columns of correction pixels,
Then it draw direction adjacent pixel be P(W+1, H), P(W, H+1), P(W+1, H+1), Fig. 2 is referred to, to draw fault image
After extending to correction image size, the positional diagram of original pixel and correction pixels and multiple adjacent pixels, 201 are in Fig. 2
An original pixel in fault image, 202 is correction pixels corresponding with original pixel 201 in correction image, the stretching side in Fig. 2
3 pixels adjacent with correction pixels 202 are its adjacent pixel upwards, and 203 is are covered in correction image after stretching original pixel
The region of lid.
Specifically, with the corresponding one group of correction coefficient of each original pixel, to corresponding correction pixels and school in correction image
Multiple adjacent pixels of positive pixel are corrected, and can be accomplished by the following way:
It is corresponding to obtain each original pixel from default correction coefficient table for index first based on original pixel each in fault image
One group of correction coefficient;Wherein, the index and one group of correction coefficient that correction coefficient table is each original pixel in fault image are preset
And the mapping relations of corresponding correction pixels.
And then original pixel value and corresponding correction coefficient based on each original pixel, it is corresponding to calculate each original pixel
The pixel value of correction pixels;And by the pixel value of correction pixels, as correction pixels and the pixel school of corresponding multiple adjacent pixels
Positive value, while correction pixels and multiple adjacent pixels accordingly depositing in the correspondence memory block of correction image is written into pixel correction value
Storage space is set;Wherein, in correction image for same pixel there are multiple pixel correction values, the pixel correction value that is obtained after
Pixel correction value before replacement.
For example, it is assumed that the corresponding correction pixels of each original pixel have 3 adjacent pixels, then each original pixel is one group corresponding
The number of correction coefficient is 4, and the default correction coefficient table of fault image is as shown in table 1:
Table 1
The index of original pixel |
Correction coefficient 0 |
Correction coefficient 1 |
Correction coefficient 2 |
Correction coefficient 3 |
Correction pixels |
0 |
C00 |
C01 |
C02 |
C03 |
P(W0,H0) |
1 |
C10 |
C11 |
C12 |
C13 |
P(W1,H1) |
2 |
C20 |
C21 |
C22 |
C23 |
P(W2,H2) |
….. |
…… |
……. |
…… |
…. |
…. |
n |
Cn0 |
Cn1 |
Cn2 |
Cn3 |
P(Wn,Hn) |
In table 1, P(W0,H0) ~ P(Wn,Hn) it is correction pixels corresponding with 0 ~ n of index of original pixel, W0,H0~Wn,Hn
It is followed successively by P(W0,H0) ~ P(Wn,Hn) ranks number.
Correction coefficient in default correction coefficient table can be joined by the radial distortion parameter of optical lens and tangential distortion
Number determines that due to the common method that determining method is the prior art, therefore details are not described herein.Obtaining default correction coefficient table
Later, default correction coefficient table can be stored in fixed memory space, such as the random access memory (Random of FPGA
Access Memory, RAM) in, while FPGA receives the one-row pixels or a pixel of fault image, read from RAM
Default correction coefficient table is taken, in case the use when being corrected to the fault image after stretching.
Specifically, the index based on original pixel each in fault image, obtains each preimage from default correction coefficient table
The corresponding one group of correction coefficient of element, is achieved in the following ways:
Firstly, used line synchronising signal and frame synchronizing signal and timeticks when according to acquisition fault image, really
Determine head office's columns of fault image;Wherein, the corresponding width fault image of each frame synchronizing signal, each line synchronising signal correspond to institute
State the one-row pixels in a width fault image, the corresponding original pixel of each timeticks.
Secondly, the ranks number of total columns and each original pixel based on the fault image, determines each original
The index of pixel;
Finally, the index based on each original pixel, obtains each preimage from the default correction coefficient table
The corresponding one group of correction coefficient of element and correction pixels.
Since the index of any pixel in fault image and the columns of fault image are related, so being carried out to fault image
The one-row pixels of fault image, current synchronization signal and timeticks have at least first been received before correction, determine fault image
Then columns calculates the index of each pixel received according to the index calculation formula of original pixel in fault image, specifically
Hypothesis P(x, y) indicate original pixel, x, y are ranks number of the original pixel in fault image, then original pixel P(x, y) index
For index(x, y)=m × x+y, wherein m is total columns of fault image.It should be noted that assuming that fault image here
The coordinate of first pixel is (0,0), if the coordinate of first pixel is (1,1), then x should be changed to x-1).
Then, so that it may which each original pixel is obtained from default correction coefficient table according to the index of calculated each original pixel
Corresponding one group of correction coefficient and correction pixels.
For example, it is assumed that being currently received with frame synchronizing signal, it is determined that prepare to receive a width frame image (i.e. width distortion figure
Picture), after receiving first line synchronising signal, prepare the first row pixel for receiving the fault image, and according to each clock
Beat determines a corresponding pixel, is to determine that the first row pixel receives, and unite when receiving second line synchronising signal
It counts out and receives 640 pixels altogether, 640 be the columns of fault image, according to the columns of fault image and the preimage received
The coordinate value of element determines the index of the original pixel received, if the coordinate of the 3rd pixel in the 0th row pixel is (0,2), the
The index of the 3rd pixel in 0 row pixel is index (0,2)=640 × 0+2=2, is then found from default correction coefficient table
Index is that 2 corresponding one group of correction coefficient are C2,0、C2,1、C2,2、C2,3And correction pixels P(W2, H2).
After obtaining each corresponding correction pixels of original pixel and one group of correction coefficient, the pixel of correction pixels can be calculated
Value, and using the pixel value as the pixel value of multiple adjacent pixels of correction pixels and correction pixels, to complete to correction pixels
Correction.Specifically, calculating the formula of the pixel value of correction pixels are as follows:
Pi,i(W, H)=(Ci,0 +Ci,1+..+Ci,j) × Pi(x, y);
Wherein, Pi,i(W, H) is the pixel value of correction pixels, PiThe pixel value of (x, y) each original pixel, i are each preimage
The index of element, the number that j is one group of correction coefficient, x, y are respectively ranks number of each original pixel in fault image, and W, H divide
Not Wei correction pixels correction image in ranks number, Ci,0 ~Ci,jFor the corresponding one group of correction coefficient of each original pixel.
After calculating the pixel value of correction pixels, correction pixels and multiple adjacent pixels are written into school in pixel correction value
Before respective memory locations in the correspondence memory block of positive image, it is also necessary to first determine whether correction pixels are effective correction picture
Element, specifically:
Firstly, carrying out long-pending operation with drawing coefficient respectively to total columns of fault image, total line number, correction pixels are obtained
The maximum virtual value of line number, columns;Secondly, the index based on the corresponding original pixel of correction pixels, from default correction coefficient table
The ranks number for obtaining correction pixels, judges whether the ranks number of correction pixels is not more than the line number of correction pixels, the maximum of columns
Virtual value;Finally, correction pixels and more are written in pixel correction value if YES then determine that correction pixels are effective correction pixels
Respective memory locations of a neighbour's pixel in the correspondence memory block of correction image.
For example, it is assumed that obtaining correction pixels by default correction coefficient table (inquiry table 1) is P(W, H), W is correction pixels
Line number, the columns that H is correction pixels, head office's columns of fault image is m, n, drawing coefficient scale, if W≤Scale
× m and H≤Scale × n, it is determined that fault image be stretched after image without departing from stored boundary, which is to have
The correction pixels of effect are retained, and otherwise correction pixels are invalid, should give discarding.
It should be noted that determine correction pixels whether be effective correction pixels opportunity can also calculate correct picture
Before the pixel value of element.
After determining that correction pixels are effective correction pixels, correction pixels and multiple can be written in pixel correction value
Respective memory locations of the adjacent pixel in the correspondence memory block of correction image, are realized particular by following manner:
Firstly, carrying out long-pending operation to total line number of fault image and the columns of each pixel and drawing coefficient, obtain intermediate
As a result;Wherein, each pixel is any one pixel in correction pixels and multiple adjacent pixels;Again to intermediate result and each pixel
Line number carry out and operation, obtain the index of the storage address of each pixel;Finally, based on the initial address for correcting image and often
Each corresponding storage location of pixel is written in pixel correction value by the index of the storage address of a pixel.
The specific index for calculating each pixel in correction image, used formula are as follows:
index_WH=Scale×n×W+H;Wherein, index_WH is the rope for correcting the pixel that coordinate in image is (W, H)
Drawing value, W is the line number of each pixel, the columns that H is each pixel, and Scale is drawing coefficient, and m is total columns of fault image,
N is total line number of fault image.
Each correction pixels of correction image and the index of corresponding multiple adjacent pixels are calculated according to above-mentioned formula, and will
Each correction pixels and the pixel value of corresponding multiple adjacent pixels are written in corresponding storage location.For example, fault image be 4 ×
4 image (value of row, column number is respectively 0 ~ 3), the drawing coefficient used when being corrected to fault image are 2, then count
Calculate the pixel in corresponding correction image are as follows:
In the 0th row pixel data for receiving fault image, the original pixel of the 0th row is P(0,0), P(0,1), P(0,
2), P(0,3), according to index the calculation formula index(x, y of original pixel) and=m × y+x, calculate separately out four originals of the one 0 row
The index of pixel is followed successively by 0,4,8,12, and then according to the index of each original pixel, it is corresponding that this four original pixel are found from table 1
Correction pixels successively are as follows: P(W0,H0), P(W4,H4), P(W8,H8), P(W12,H12), calculate the row of the fault image after stretching
The value range of columns is W≤8 and H≤8, and the correction pixels within the scope of this ranks number are effective correction pixels, if above-mentioned
It is P(0 that four correction pixels are practical, 0), P(4,4), P(8,8), P(12,12), then P(0,0), P(4,4), P(8,8) these three
Correction pixels are effective correction pixels, P(12,12) it is that invalid correction pixels do discard processing.
Then, according to index formula index_WH=Scale × m × H+W of correction pixels, calculate P(0,0), P(4,4),
P(8,8) these three correction pixels and the index of their adjacent pixel, and according to the initial address of correction image and each pixel
The index of storage address, by the storage location of corresponding pixel correction value write-in respective pixel.
In embodiment provided by the invention, if retaining the correction complete marginal information of image, drawing coefficient is arranged
For the value greater than 1;If keeping correction image identical as the size of fault image, 1 is set by the value of drawing coefficient.
Embodiment provided by the invention, can be applied to use FPGA as processing chip electronic equipment in, FPGA can
To select Xilinx Kintex logical series chip, the camera of electronic equipment can select OV5640, and be configured defeated
Mode is set as 640 × 480YUV format out, and the external memory chip of electronic equipment can select 2GibDDR3.Default correction system
Number table can store in the external memory chip, after receiving the initial data of fault image, to synchronize from default
Correction parameter needed for being read in correction coefficient table.
Fig. 3 is referred to, to use FPGA as the structural schematic diagram of the electronic equipment of processing chip.In Fig. 2, electronics is set
Standby camera acquires fault image, and the initial data of collected fault image is sent to FPAG, makes FPGA according to abnormal
Become the index of current original pixel in image, the synchronous correction coefficient that original pixel is read from DDR memory (i.e. external memory)
(i.e. progress data are synchronous), then stretches the original pixel in distortion figure by drawing coefficient, and to the school in correction image
Positive pixel and multiple adjacent pixels are corrected, and obtain and storage section correction image is into DDR memory, when the number of fault image
After having received, consequently also obtain completely correcting image in Double Data Rate (Double Data Rate, DDR) memory,
FPGA can be allowed to carry out the processing of pipeline system in this way, and can effectively save the storage resource of FPGA, improve correction efficiency.
Based on the same inventive concept, a kind of for correcting the device of fault image, the dress is provided in one embodiment of the invention
The specific embodiment for setting the method for correcting distorted image can be found in the description of embodiment of the method part, and it is no longer superfluous to repeat place
It states, refers to Fig. 4, which includes:
Receiving unit 401, the initial data for reception fault image point-by-point line by line;
Unit 402 is corrected, for the drawing coefficient and correction coefficient by setting, to the every of the fault image received
Row pixel is corrected while stretching, until completing the stretching and calibration to the last line pixel of the fault image
Afterwards, the correction image of the fault image is obtained;Wherein, the drawing coefficient is the multiple for stretching the fault image, institute
Stating correction coefficient is that radial distortion parameter as acquiring optical lens used in the fault image and tangential distortion parameter are true
Fixed, each original pixel in the fault image has one group of correction coefficient, and corrects with one in the correction image
Pixel is corresponding.
Optionally, the correction unit 402 is used for:
The initial data for often receiving the one-row pixels point of the fault image, just according to the drawing coefficient to described one
Row pixel is stretched, the one-row pixels point of the fault image after being stretched;
While stretching the one-row pixels point, with the corresponding one group of correction coefficient of each original pixel, to described
Multiple adjacent pixels of corresponding correction pixels and the correction pixels are corrected in correction image;
Wherein, the number of the corresponding one group of correction coefficient of each original pixel and the correction pixels and the multiple neighbour
The number of pixels of pixel is identical, and the coverage area of each original pixel after the stretch is in the correction pixels and the multiple neighbour
In the coverage area of pixel, the multiple neighbour's pixel is adjacent picture of the correction pixels on the fault image draw direction
Element.
Optionally, the correction unit 402 is used for:
Based on the index of each original pixel in the fault image, each preimage is obtained from default correction coefficient table
The corresponding one group of correction coefficient of element;Wherein, the default correction coefficient table is the index of each original pixel in the fault image
With the mapping relations of one group of correction coefficient and corresponding correction pixels;
It is corresponding to calculate each original pixel for original pixel value and corresponding correction coefficient based on each original pixel
The pixel value of correction pixels;And by the pixel value of the correction pixels, as the correction pixels and corresponding multiple adjacent pixels
Pixel correction value, while the correction pixels and the multiple adjacent pixel are written into the correction chart in the pixel correction value
Respective memory locations in the correspondence memory block of picture;Wherein, for same pixel, there are multiple pixels in the correction image
Corrected value, the pixel correction value before the pixel correction value replacement obtained after.
Optionally, the correction unit 402 is used for:
Used line synchronising signal and frame synchronizing signal and timeticks when according to the acquisition fault image, really
Head office's columns of the fixed fault image;Wherein, the corresponding width fault image of each frame synchronizing signal, each line synchronising signal pair
Answer the one-row pixels in the width fault image, the corresponding original pixel of each timeticks;
The ranks number of total columns and each original pixel based on the fault image, determines each original pixel
Index;
Based on the index of each original pixel, it is corresponding that each original pixel is obtained from the default correction coefficient table
One group of correction coefficient and correction pixels.
Optionally, formula used in the pixel value of the corresponding correction pixels of each original pixel is calculated specifically:
Pi,i(W, H)=(Ci,0 +Ci,1+..+Ci,j) × Pi(x, y);
Wherein, Pi,i(W, H) is the pixel value of the correction pixels, PiThe pixel value of (x, y) described each original pixel, i are
The index of each original pixel, the number that j is one group of correction coefficient, x, y are respectively each original pixel described
Ranks number in fault image, W, H are respectively ranks number of the correction pixels in the correction image, Ci,0 ~Ci,jFor institute
State the corresponding one group of correction coefficient of each original pixel.
Optionally, the correction unit 402 is also used to:
Long-pending operation is carried out with the drawing coefficient to total columns of the fault image, total line number respectively, obtains the school
The maximum virtual value of the line number of positive pixel, columns;
Based on the index of the corresponding original pixel of the correction pixels, the correction is obtained from the default correction coefficient table
The ranks number of pixel, judges whether the ranks number of the correction pixels is not more than the line number of the correction pixels, the maximum of columns
Virtual value;
If YES then determining that the correction pixels are effective correction pixels, the correction is written into the pixel correction value
The respective memory locations of pixel and the multiple adjacent pixel in the correspondence memory block of the correction image.
Optionally, the correction unit 402 is used for:
Long-pending operation carried out to total columns of the fault image and the line number of each pixel and the drawing coefficient, in acquisition
Between result;Wherein, each pixel is any one pixel in the correction pixels and the multiple adjacent pixel;
Columns progress and operation to the intermediate result and each pixel, with obtaining the storage of each pixel
The index of location;
The index of the storage address of initial address and each pixel based on the correction image, by the pixel school
Each corresponding storage location of pixel is written in positive value.
Optionally, the correction unit 402 is also used to:
If retaining the complete marginal information of the correction image, the drawing coefficient is set greater than to 1 value;
If keeping the correction image identical as the size of the fault image, set the value of the drawing coefficient to
1。
Based on the same inventive concept, a kind of device for correcting distorted figure is provided in the embodiment of the present invention, comprising:
On-site programmable gate array FPGA, and the image acquisition device being connected with the FPGA, on described image collector
It is provided with an optical lens, the fault image of target object is acquired by described image collector;
At least one processor is provided in the FPGA;
Wherein, at least one processor is stored with the instruction that can be executed by the FPGA, and the FPGA passes through execution
The instruction of at least one processor storage, the method for executing correction fault image as described above.
Based on the same inventive concept, the embodiment of the present invention also mentions a kind of computer readable storage medium, comprising:
The computer-readable recording medium storage has computer instruction, when the computer instruction is run on computers
When, so that the method that computer executes correction fault image as described above.
In embodiment provided by the invention, pass through the initial data of reception fault image point-by-point line by line;By setting
Drawing coefficient and correction coefficient are corrected while stretching to every row pixel of the fault image received, until complete
After the stretching and calibration of the last line pixel of pairs of fault image, the correction image of fault image is obtained;Wherein, drawing coefficient
For the multiple for stretching fault image, correction coefficient is the radial distortion parameter of the optical lens as used in acquisition fault image
Determined with tangential distortion parameter, each original pixel in fault image has one group of correction coefficient, and in correction image
One correction pixels is corresponding.While due to being stretched during receiving fault image to every row pixel of fault image
It is corrected, so that the initial data for receiving a fault image just completes the correction of a part of fault image, has received most
After the initial data of rear portion fault image, the correction to the complete initial data of fault image is just completed, to effectively mention
The high processing speed of correcting distorted image, and due to without in advance to complete distortion during correcting distorted image
The initial data of image is stored, so storage resource has also effectively been saved, so that above scheme provided by the invention exists
When being handled using FPGA, it can effectively improve the processing speed of FPGA, save the storage resource of FPGA.
Further, the correction system of original pixel is quickly found out from default correction coefficient table by the index by original pixel
Number, and corrected in time after finding correction coefficient, so that without the address relationship table for storing correction image and fault image,
Correction coefficient only need to be stored, to reduce the difficulty of index, improves the treatment effeciency of correcting distorted image.
Further, since embodiment provided by the invention is stretched to the partial data of the fault image received
While be corrected, so entire correction course is without storing complete fault image, so as to effectively save storage
Space reduces hardware cost.
Further, due to embodiment provided by the invention when correcting image using the mode of stretching, as long as school
The size of positive image allows, and can retain the marginal information of image, to avoid the loss of critical data, promote the processing of correction
Speed.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as the production of method, system or computer program
Product.Therefore, in terms of the embodiment of the present invention can be used complete hardware embodiment, complete software embodiment or combine software and hardware
Embodiment form.Moreover, it wherein includes computer available programs generation that the embodiment of the present invention, which can be used in one or more,
The meter implemented in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of code
The form of calculation machine program product.
The embodiment of the present invention be referring to according to the method for the embodiment of the present invention, equipment (system) and computer program product
Flowchart and/or the block diagram describe.It should be understood that can be realized by computer program instructions in flowchart and/or the block diagram
The combination of process and/or box in each flow and/or block and flowchart and/or the block diagram.It can provide these calculating
Processing of the machine program instruction to general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices
Device is to generate a machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute
For realizing the function of being specified in one or more flows of the flowchart and/or one or more blocks of the block diagram
Device.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Obviously, various changes and modifications can be made to the invention without departing from essence of the invention by those skilled in the art
Mind and range.In this way, if these modifications and changes of the present invention belongs to the range of the claims in the present invention and its equivalent technologies
Within, then the present invention is also intended to include these modifications and variations.