A kind of correcting method for deformation of lens imaging
Technical field
The present invention relates to digital image processing field, relate in particular to a kind of correcting method for deformation of lens imaging.
Background technology
Generally can there be distortion to a certain degree in the ordinary optical camera lens in imaging, concrete manifestation can be divided into two kinds of situations: pincushion distortion (pin-cushion distortion), and barrel distortion (Barrel distortion).Because the existence of distortion, when camera lens when rectangle is taken, imaging no longer is a rectangle, but shape as shown in Figure 1.After most applications servant saw image after the distortion, big brain-capacity was carried out from normal moveout correction it, and the result is the perception that does not influence basically image content, but for computing machine and a lot of software, this can cause serious consequence.Therefore be necessary the image of distortion is suitably proofreaied and correct.
The method of present existing compensating images distortion, as the applying date be the Chinese patent 98122712.0 on November 26th, 1998, all be to read a correcting sheet earlier, have the chequered with black and white striped of scheduled volume on this correcting sheet, the exact position of black streaking is known.After correcting sheet reads, the chequered with black and white striped of corresponding scheduled volume can be got, after judging calculating, the black streaking position can be got.Then, calculate the exact position of the chequered with black and white striped of this scheduled volume and the difference that image reads the back calculating location, promptly get the amount of distortion of each reference point.Deposit the amount of distortion of each reference point in the storer end correcting sheet fetch program.Carry out image when reading, each amount of distortion that is stored in the storer is removed at every turn, to revise the pattern distortion that optical system causes.
But there is certain problem in these class methods.What at first, obtain behind its calculating black and white strip is the amount of distortion of several reference points.This makes that the effect of this distortion correction is not very accurate, can not obtain complete satisfactory correcting image.Secondly, the amount of distortion of each reference point is stored in the storer.And for varifocal camera lens, distortion is different under different focal lengths.End at focal range produces pincushion distortion, then produces barrel distortion at the other end.Obviously the amount of distortion of each reference point of getting off of prestoring can not adapt to the distortion that the variation of focal length brings, and after focusing, need read correcting sheet again at every turn, and the amount of distortion of reference point is calculated.For the occasion of often carrying out focus adjustment, for example digital camera, or PC Camera, this obviously is unpractical.In addition, solve the problem of optical system distortion, the most basic approach is, a strict mathematics model is set up in the generation of distortion, studies the reason of its generation on this basis and finds solution.Under these circumstances, the solution of new optical system distortion is by demand.
Summary of the invention
In order to solve the problems of the prior art and deficiency, the object of the present invention is to provide a kind of easy-to-use flexibly method that distortion is proofreaied and correct to lens imaging.It can be used for various occasions of often carrying out focus adjustment easily, and can be proofreaied and correct the result accurately.
A kind of correcting method for deformation of lens imaging, this method comprises the following steps:
1) carries out image and read, produce one group of corresponding image information;
2) rule of thumb or under the situation of man-machine interaction by the people to correction coefficient k
1, k
2... k
n, n is any natural number, carries out assignment;
3) according to the correction coefficient value k of appointment
1, k
2... k
n, calculate the amount of distortion of each point in the image, the image after obtaining proofreading and correct;
4) dynamically revise correction coefficient value k according to calibration result
1, k
2... k
n, and execution in step 3), until obtaining satisfied correcting image.
Above-mentioned correction coefficient k
1, k
2... k
nDefine by the following step:
Setting amount of distortion is that center of circle O is isotropic for focus point, on certain bar radius OP mathematical model is set up in distortion;
Some P after set proofreading and correct is positioned at the Q point place on the extended line of OP, OP=r, OQ=R, amount of distortion dr=R-r;
Amount of distortion dr can be expressed as dr=k
1* R+k
2* R
3+ k
3* R
5+ ..., k
1, k
2... k
nBe distortion factor.
The present invention can also proofread and correct image before carrying out step 1) in advance, and described step of proofreading and correct in advance is: 1) obtain the amount of distortion Δ X (i) of each reference point, and i=1,2,3 ..., M; 2) carry out image and read, produce a corresponding image information; 3) according to described each amount of distortion Δ X (i), described image information is compensated.
The above-mentioned correction in advance can also be with following steps for carrying out: 1) carry out image and read, produce a corresponding image information; 2) obtain the amount of distortion Δ X (i) of each reference point, i=1,2,3 ..., M; 3) according to described each amount of distortion Δ X (i), described image information is compensated.
The amount of distortion Δ X (i) of above-mentioned each reference point is produced by the following step:
One correcting sheet is provided, has the chequered with black and white striped of scheduled volume on the correcting sheet, the exact position of described black and white strip is a given value, X (1), X (2), X (3) ... X (M) is referred to as reference point;
Image read-out is read have on the correcting sheet the chequered with black and white clause pattern of predetermined quantity, produce a corresponding image information;
By correspondence image information, can obtain the position X` (1) of described candy strip after the calculating, X` (2), X` (3) ... X` (M);
The exact position and the image that calculate the chequered with black and white candy strip of this predetermined quantity read the difference of position, back, obtain the amount of distortion Δ X (1) of each reference point, Δ X (2), Δ X (3) ... Δ X (M);
With the amount of distortion Δ X (1) of each reference point, Δ X (2), Δ X (3) ... Δ X (M) deposits a storer in.
Because the present invention proposes a kind of mathematical model that pattern distortion is set up to the pin optical lens, and to its method of proofreading and correct.Make the present invention to carry out calibration to the image that has distortion exactly, and can adjust proofreading and correct the result at any time as required.It can be proofreaied and correct imaging in advance with the method that reads the black and white strip correcting sheet, also can carry out manual correction to prior image without any correction at an easy rate.The invention solves focus in the prior art at every turn after, need read correcting sheet again, the problem that the amount of distortion of reference point is calculated.For the occasion of often carrying out focus adjustment, for example digital camera, or PC Camera can rule of thumb or under the situation of man-machine interaction carry out assignment by the people to distortion factor easily, according to the value of distortion factor image is proofreaied and correct then.It can solve pincushion distortion and barrel distortion, and has easy-to-use characteristics flexibly on using.
Description of drawings
Fig. 1 takes the synoptic diagram that distortion takes place for camera lens to rectangle;
Fig. 2 is a workflow diagram of the present invention;
Fig. 3 sets up the schematic diagram of mathematical model for the present invention.
Embodiment
Referring to Fig. 2, a kind of correcting method for deformation of lens imaging, this method comprises the following steps:
1) carries out image and read, produce one group of corresponding image information;
2) rule of thumb or under the situation of man-machine interaction by the people to correction coefficient k
1, k
2... k
n, n is any natural number, carries out assignment;
3) according to the correction coefficient value k of appointment
1, k
2... k
n, calculate the amount of distortion of each point in the image, the image after obtaining proofreading and correct;
4) dynamically revise correction coefficient value k according to calibration result
1, k
2... k
n, and execution in step 3), until obtaining satisfied correcting image.
Referring to Fig. 3, above-mentioned correction coefficient k
1, k
2... k
nDefine by the following step: suppose to proofread and correct Q point place on the extended line that back point P should be positioned at OP, make OP=r, OQ=R, then amount of distortion dr is defined as:
dr=R-r
When dr was positive number, pincushion distortion was represented in expression barrel distortion during for negative.
Obviously, the amount of distortion at certain some place is different and different along with its radius.Generally speaking, more near edge of image, it is severe more to distort.
In addition, when R become-during R, i.e. the point on the extended line in the opposite direction, its amount of distortion dr also becomes-dr.
So we can be expressed as dr
dr=k
1*R+k
2*R
3+k
3*R
5+…
Wherein, k
1, k
2, k
3Deng being coefficient undetermined.For the convenience that illustrates, suppose only to get three of fronts and do approximate:
dr=k
1*R+k
2*R
3+k
3*R
5
The present invention can carry out assignment by the people to correction coefficient according to experience or under the situation of man-machine interaction.In this case, according to the k of appointment
1, k
2, k
3Value can calculate the image after the correction, and dynamically revises k according to calibration result
1, k
2, k
3Value generally just can reach effect preferably after revising several times.
The present invention is making k
1, k
2, k
3After the value, just can proofread and correct the image that obtains.When the calculation correction image, because parameter or result can be integer just generally, some occurs in the image after proofread and correct and put situation about being calculated never, the method for a kind of " Converse solved " is proposed here.Suppose to want the point in the image behind the calculation correction (a, brightness value b) or color-values, a wherein, b is an integer.We can obtain the radius R of this point, in the formula above the R substitution, obtain dr, and then according to r=R-dr, obtain r.Notice that radius r is the value in the image before correction.Find corresponding point (a ', b ') in so just can the image before correction, because a ' and b ' generally are not integers, we can obtain the brightness value or the color-values of this point by interpolation algorithm.
The present invention can also proofread and correct image before carrying out step 1) in advance, and described step of proofreading and correct in advance is: 1) obtain the amount of distortion Δ X (i) of each reference point, and i=1,2,3 ..., M; 2) carry out image and read, produce a corresponding image information; 3) according to described each amount of distortion Δ X (i), described image information is compensated.
The described correction in advance can also be carried out with following steps: 1) carry out image and read, produce a corresponding image information; 2) obtain the amount of distortion Δ X (i) of each reference point, i=1,2,3 ..., M; 3) according to described each amount of distortion Δ X (i), described image information is compensated.
The amount of distortion Δ X (i) of above-mentioned each reference point is produced by the following step:
One correcting sheet is provided, has the chequered with black and white striped of scheduled volume on the correcting sheet, the exact position of described black and white strip is a given value, X (1), X (2), X (3) ... X (M) is referred to as reference point;
Image read-out is read have on the correcting sheet the chequered with black and white clause pattern of predetermined quantity, produce a corresponding image information;
By correspondence image information, can obtain the position X` (1) of described candy strip after the calculating, X` (2), X` (3) ... X` (M);
The exact position and the image that calculate the chequered with black and white candy strip of this predetermined quantity read the difference of position, back, obtain the amount of distortion Δ X (1) of each reference point, Δ X (2), Δ X (3) ... Δ X (M);
With the amount of distortion Δ X (1) of each reference point, Δ X (2), Δ X (3) ... Δ X (M) deposits a storer in.