Background technology
In imaging system, camera lens has a best image planes position to object image-forming, departs from this position and will cause image blurringly, and image quality descends; Can therefore, accurately focus to an imaging system be crucial.Imaging system based on digital picture adopts automatic focusing method, and its key is focusing evaluation function.Desirable focusing evaluation function curve shows as the class parabolic shape, and its peak value is corresponding to the optimal imaging position, and the focusing evaluation function value reduces when leaving optimum.Therefore automatic focusing process essence is to ask for the peaked process of focusing evaluation function.
Usually, the energy major part of image concentrates on the low frequency and the Mid Frequency of image frequency domain, but the richness of the acutance of image outline and details then depends on the high frequency composition of image.When clear picture, details is abundant, and eigenwert (as gray scale, the color etc.) variation that shows as neighbor on the spatial domain is bigger, and the high fdrequency component that then shows as frequency spectrum at frequency domain is many.Focusing evaluation function commonly used is divided into two kinds: the spatial domain with frequency domain.Several spatial domains focusing evaluation function commonly used comprises Laplacian operator, Sobel operator, Prewitt operator and energy variance operator etc.Less relatively based on the operand that the focusing evaluation method in spatial domain is required, but its shortcoming is to be subjected to The noise bigger, and promptly noise immunity is relatively poor.Frequency domain focusing evaluation method then needs earlier image to be carried out Fourier transform or other conversion, comes the sharpness of evaluation map picture again according to conversion coefficient.The focusing evaluation method of frequency domain is utilized the overall permanence of image, but calculated amount is often very big.Therefore, how to reduce the key issue that computation complexity is a frequency domain focusing evaluation method.
The invention provides a kind of fast automatic focusing method based on the Hadamard conversion, this method not only possesses the advantage of frequency domain focusing evaluation method, and calculated amount is little, is easy to hardware and realizes.
Summary of the invention
Technical matters to be solved by this invention provide a kind of calculated amount little, be easy to the hard-wired digital micro imaging method of focusing automatically.
The present invention solves the problems of the technologies described above the technical scheme that is adopted: a kind of digital micro imaging based on Hadamard conversion method of focusing automatically, it may further comprise the steps: 1. for the digital micro imaging system, continuously focusing is with the input signal of the image that obtains sharpness and have nothing in common with each other; 2. the two-dimentional input signal f to every width of cloth image carries out the Hadamard conversion, obtains Hadamard transform coefficient matrix H=h
nFh
n, h wherein
nBe the Hadamard transformation matrix; 3. define focusing evaluation function F and be Hadamard conversion coefficient in the region R ange weighted energy and
In the formula, H
I, jBe Hadamard conversion coefficient, w
kBe H
I, jWeight, k=1,2, ..., K, K are the number of Hadamard conversion coefficient among the Range, Range represents the coordinate set of some conversion coefficients selected among the Hadamard transform coefficient matrix H, the input signal of every width of cloth image is calculated the value of its focusing evaluation function F; 4. when the variation tendency of focusing back focusing evaluation function F value changed continuously, the readjustment focal length occurred until the image input signal corresponding to focusing evaluation function F maximum value, finishes the focusing process then; 5. get the image that promptly obtains sharpness the best of correct focusing corresponding to the image of the focusing evaluation function F maximum value of input signal.
In order to reduce computation complexity, reach the purpose of rapid focus, also can adopt following focusing evaluation function
Two dimension input signal f can be the combination or the down-sampled signal of Zone Full or the regional area or the regional area of digital micro imaging image.
Region R ange can be the coordinate set of some high frequency conversion coefficients selected among the Hadamard transform coefficient matrix H.
Hadamard transform coefficient matrix H can be refined as 4 * 4 zoned format, and choose the focusing evaluation function F calculating selected region R ange of the zone of the 3rd row the 3rd row as the Hadamard conversion.
Compare with existing classical focusing evaluation method, the method for focusing automatically of the digital micro imaging based on the Hadamard conversion of the present invention not only has unimodality, unbiasedness, can reflect the fundamental characteristics such as polarity of out of focus, and has good noiseproof feature.Simultaneously, because the Hadamard conversion has only plus and minus calculation, need not to carry out multiplying, the calculated amount of conversion own is very low, so the inventive method also possesses characteristics such as algorithm is simple, fast operation.
Embodiment
Embodiment describes in further detail the present invention below in conjunction with accompanying drawing.
A kind of digital micro imaging based on Hadamard conversion method of focusing automatically is characterized in that it may further comprise the steps: 1. for the digital micro imaging system, focusing is with the input signal of the image that obtains sharpness and have nothing in common with each other continuously; 2. the two-dimentional input signal f to every width of cloth image carries out the Hadamard conversion, obtains Hadamard transform coefficient matrix H=h
nFh
n, the Hadamard transformation matrix h of 2D signal
nCan be by kernel matrix
Recursion obtains:
Wherein is the symbol of the straight base of matrix (Kronecker); 3. define focusing evaluation function F and be Hadamard conversion coefficient in the region R ange weighted energy and
In the formula, H
I, jBe Hadamard conversion coefficient, i.e. H
I, jFor being positioned at position (i, coefficient j), w among the H
kBe H
I, jWeight, k=1,2, ..., K, K are the number of Hadamard conversion coefficient among the Range, Range represents the coordinate set of some conversion coefficients selected among the Hadamard transform coefficient matrix H, the input signal of every width of cloth image is calculated the value of its focusing evaluation function F; 4. when continuously the variation tendency of focusing back focusing evaluation function F value changes (becoming successively decreases or become by successively decreasing increases progressively by increasing progressively), the readjustment focal length finishes the focusing process then until the image input signal appearance corresponding to focusing evaluation function F maximum value; 5. get the image that promptly obtains sharpness the best of correct focusing corresponding to the image of the focusing evaluation function F maximum value of input signal.
In order to reduce computation complexity, reach the purpose of rapid focus, the focusing evaluation function in the said method also can adopt as giving a definition
In said method, the Zone Full that two-dimentional input signal f can be the digital micro imaging image or the combination or the down-sampled signal of regional area or regional area.
Because the high frequency composition of image has characterized the acutance of image outline and the richness of details, therefore the high frequency coefficient that can choose the Hadamard transform coefficient matrix usually calculates focusing evaluation function, even Range is the coordinate set of some high frequency conversion coefficient among the Hadamard transform coefficient matrix H.But consider the noiseproof feature of focusing evaluation function F, also can suitably select part intermediate frequency and low frequency coefficient weighting to count among the focusing evaluation function F, promptly choose Range and be the coordinate set of some high frequency and medium and low frequency conversion coefficient among the Hadamard transform coefficient matrix H.
The part coefficient that digital micro imaging focusing method automatically based on the Hadamard conversion of the present invention has been chosen the Hadamard frequency domain particularly high frequency coefficient calculates focusing evaluation function, the advantage of existing frequency domain focusing method, utilize the Hadamard conversion to need not the very low characteristics of multiplying, calculated amount again, overcome the big shortcomings of general frequency domain focusing method calculated amount such as Fourier transform, discrete cosine transform, sine transform, wavelet transformation.
The micro-image (picture size is 1024 * 1280) of the pumpkin stem section that the sharpness that is obtained for one group of continuous focusing has nothing in common with each other has carried out the focusing test, Fig. 1 (a) has provided the different image of 2 width of cloth focusing degree wherein with Fig. 1 (b), and Fig. 1 (a) is fuzzy, Fig. 1 (b) is clear.In the practical application since the image of gathering often size is bigger, for quickening the speed of focusing automatically, can be from original image the selection portion subregion as the focusing zone.In the present embodiment, Hadamard transform coefficient matrix H is refined as shown in Figure 24 * 4 zoned format, and chooses wherein zone 11 as the medium-high frequency part of Hadamard transform domain, selected region R ange during promptly focusing evaluation function F calculates.
In image acquisition process, because the relation of actual imaging condition tends to introduce certain noise, therefore good focusing evaluation method need possess good noiseproof feature.Present embodiment provides the contrast and experiment of utilizing the automatic focusing evaluation method based on the Hadamard conversion of the present invention and classical focusing evaluation method under following three kinds of situations:
Situation-1. adopt original image, picture size is 1024 * 1280;
The middle section of the intercepting of situation-2. original image 512 * 512;
The middle section of the intercepting of situation-3. original image 512 * 512, and to apply variance after the normalization be 0.1 white Gaussian noise.
Fig. 3, Fig. 4, Fig. 5 have provided respectively under above-mentioned three kinds of situations, automatic focusing method and the classics experimental result contrast of focusing method automatically based on the Hadamard conversion of the present invention.
Classics that present embodiment is selected for use focusing evaluation method comprises: Laplacian operator, Sobel operator, Prewitt operator, energy variance operator and based on the focusing evaluation method of wavelet transformation.In Fig. 3, Fig. 4, Fig. 5, curve hadamard represents the present invention's evaluation method of focusing, laplacian represents to adopt the focusing evaluation method of Laplacian operator, sobel represents to adopt the focusing evaluation method of Sobel operator, prewitt represents to adopt the focusing evaluation method of Prewitt operator, standard represents to adopt the focusing evaluation method of energy variance operator, and wavelet represents the focusing evaluation method based on wavelet transformation.
Desirable focusing evaluation function not only should have unimodality, unbiasedness, the polarity fundamental characteristics such as (still are defocused position in burnt front position) that can reflect out of focus, and reply is subjected to the image of noise to have good noiseproof feature, also should possess characteristics such as algorithm is simple, fast operation simultaneously.Interpretation to Fig. 3, Fig. 4 and Fig. 5 can get: under above-mentioned preceding two kinds of situations (being situation-1, situation-2), the peak value of classical focusing evaluation function and the focusing evaluation function based on the Hadamard conversion of the present invention is all corresponding to the 8th width of cloth image, can think that this image is the accurate focusing position of this series micro-image, wherein the focusing evaluation function curve based on the automatic focusing evaluation method of Hadamard conversion is the most precipitous, shows its focusing best performance.Under the third situation (being situation-3), be subjected to when input picture under the situation of noise, show by experimental result shown in Figure 5, classical focusing evaluation method generally is subjected to influence in various degree, even generation peakdeviation, it is the picture numbers that evaluation result has departed from actual accurate focusing, focusing evaluation method based on the Hadamard conversion of the present invention has then kept good unimodality and accuracy, demonstrates the automatic focusing method based on the Hadamard conversion of the present invention and has good noise immunity.
In sum, compare with existing classical focusing evaluation method, the focusing evaluation method based on the Hadamard conversion of the present invention not only has unimodality, unbiasedness, can reflect the fundamental characteristics such as polarity of out of focus, and has good noiseproof feature.Simultaneously, because the Hadamard conversion only need carry out signed magnitude arithmetic(al), do not have multiplying, the calculated amount of conversion own is very low, so the inventive method also possesses characteristics such as algorithm is simple, fast operation.
Obviously, digital micro imaging focusing method automatically based on the Hadamard conversion of the present invention is not limited in the digital micro imaging field, can utilize the present invention well at digital image capture devices such as image scanner, video camera, digital cameras, therefore under the situation of the spirit and scope of the universal that does not deviate from claim and equal scope and limited, the example that the present invention is not limited to specific details and illustrates here and describe.