A kind of focusing method of imaging system and device, imaging system
Technical field
The present invention relates to field of photography, more particularly to a kind of focusing method of imaging system and device, imaging system.
Background technology
Developing rapidly and extensively applying with Morden Image Processing Technology and digital signal processor, Autofocus Technology
A new digital Age is entered, Autofocus Technology is one of key technology of all kinds of imaging systems.In camera, shooting
There is extensive purposes in the imaging systems such as machine, microscope, endoscope.Such as digital camera, the mobile phone with camera function etc. exist
In imaging process, it usually needs the conversion according to photographed scene is focused in real time, make shooting result clear.
Focus process is generally all completed by auto-focusing algorithm, halfway without the need for human intervention, during focusing, auto-focusing algorithm
Constantly lens location is finally fixed on by adjustment lens location, the picture readability after each adjustment lens location of assessment
Picture is most clearly located, and completes focus process.
Whether clearly the acutance of image often as judging picture foundation.If the sharpness value of described image is inaccurate,
Auto-focusing algorithm cannot correctly be judged to the readability of image that its consequence is that focusing is inaccurate, and shooting result is obscured, pole
Big impact image visual effect.
Simplest auto-focusing algorithm finds out the image collected by each lens location by traveling through all positions of camera lens
Sharpness value in acutance maximum, optimal focusing position is determined with this.Think under normal circumstances, when sharpness value reaches maximum
Lens location, be exactly optimal focusing position.The sharpness value of image, is obtained by edge detection operator.Edge inspection at present
The species of measuring and calculating is a lot, and Laplace operator, Sobel Operator, Luo Baici operators are wherein to compare to be widely used for extraction figure
Operator as sharpness value.
Although a variety of operators can effectively extract the sharpness value in most scenes, have one all the time
A little scenes can cause certain some failure in above-mentioned operator, be embodied in, the corresponding lens location of acutance maximum non-real
Positive optimal focusing position.If now auto-focusing algorithm uses the operator of failure, focusing generally can not be successful, leads
Cause shooting result to obscure, seriously reduce picture quality.So our digital camera, mobile phone etc., during taking pictures, all can
There is focusing failure, the ambiguous situation of shooting result.
Content of the invention
The problem that the present invention is solved is under some scenes, if the operator of the failure of auto-focusing algorithm employing, right
Jiao would generally be unsuccessful, causes shooting result to obscure, the serious problem for reducing picture quality.
For solving the above problems, the present invention provides a kind of focusing method of imaging system, including:Using M kind rim detections
Every kind of operator in operator is extracted in the sharpness value of the image collected by each lens location, wherein, M >=2 respectively;Obtain every kind of
The first focusing position corresponding to operator, the first focusing position corresponding to the operator are the acutance using this kind of operator extraction
The lens location corresponding to image when value is maximum;The first focusing position corresponding to the operator of N kind location matches determines
Two focusing positions, the operator of the location matches are that the difference between corresponding the first focusing position in the M kinds operator is little
In or operator equal to position threshold.
Optionally, each lens location is respectively each camera lens that camera lens is moved in mobile range with pre- fixed step size
Position, the position threshold are more than or equal to the pre- fixed step size.
Optionally, the pre- fixed step size is the integral multiple of the minimum range that the camera lens can be moved.
Optionally, second focusing position is the first focusing position corresponding to the operator of the N kinds location matches
Average.
Optionally, second focusing position is the first focusing position corresponding to the operator of the N kinds location matches
Weighted mean.
Optionally, if the M kinds operator includes the second of the first operator of N1 kind location matches and N2 kind location matches
Operator and N1>N2, then N=N1.
Optionally, the N is less than or equal to operator amount threshold, and the operator amount threshold is by the accuracy requirement that focuses
Determine with reliability requirement.
Optionally, the operator is Laplace operator, Sobel Operator, Luo Baici operators, Prewitt operator, Tuscany
Operator or gradient detective operators.
Optionally, M=3, N=2, the M kinds operator are respectively Laplace operator, Sobel Operator and Luo Baici operators.
For solving the above problems, technical solution of the present invention also provides a kind of focusing mechanism of imaging system, including:Extract single
Unit, for being extracted in the sharp of image that each lens location is collected respectively using the every kind of operator in M kind edge detection operators
Angle value, wherein, M >=2;Acquiring unit, for obtaining the first focusing position corresponding to every kind of operator, corresponding to the operator
First focusing position is the lens location corresponding to the image maximum using the sharpness value of this kind of operator extraction;Determining unit, uses
The second focusing position, the operator of the location matches is determined in the first focusing position corresponding to the operator by N kind location matches
For the operator that the difference between corresponding the first focusing position in the M kinds operator is less than or equal to position threshold.
Optionally, the determining unit includes averaging unit, for calculating the second focusing position, second focusing position
The average of the first focusing position corresponding to the operator of the N kinds location matches.
Optionally, the determining unit includes weighted average unit, for calculating the second focusing position, second focusing
Position is the weighted mean of the first focusing position corresponding to the operator of the N kinds location matches.
For solving the above problems, technical solution of the present invention also provides a kind of imaging system, including:Camera lens and as mentioned above into
Focusing mechanism as system.
Compared with prior art, technical scheme has advantages below:
The image collected by each lens location extracts sharpness value respectively using multiple operators, then adopts multiple calculations
The method of the focusing position coupling of son so can be avoided only with one to the full extent determining final optimal focusing position
Cause the problem of focusing failure when planting operator because operator fails;And focusing position is determined by the operator of multiple location matches
The accuracy of focusing position can be improved, so as to ensure system imaging quality.
Further, the value of the operator of the location matches can according to the accuracy requirement and reliability requirement of auto-focusing
It is adjusted, when the operator using less location matches determines optimal focusing position, algorithm is simple, and the reliability of algorithm can be effectively
Strengthen;When the operator using more location matches determines that optimal focusing position, the degree of accuracy of algorithm can be effectively improved.
Description of the drawings
Fig. 1 is the relation schematic diagram of the lens location of imaging system provided in an embodiment of the present invention and image sharpness value;
Fig. 2 is the schematic flow sheet of the focusing method of the imaging system that technical solution of the present invention is provided;
Fig. 3 A are the location of pixels schematic diagrames of image provided in an embodiment of the present invention;
Fig. 3 B are the weight schematic diagrames of Laplace operator provided in an embodiment of the present invention;
Fig. 3 C are the weight schematic diagrames of Sobel Operator provided in an embodiment of the present invention;
Fig. 3 D are the weight schematic diagrames of Luo Baici operators provided in an embodiment of the present invention;
Fig. 4 is the schematic flow sheet of the focusing method of imaging system provided in an embodiment of the present invention;
Fig. 5 is the structural representation of the focusing mechanism of imaging system provided in an embodiment of the present invention.
Specific embodiment
In prior art, image of the auto-focusing algorithm by each lens location of collection, using a kind of edge detection operator
The sharpness value of the image of each lens location of the collection is extracted, the acutance maximum of image is found out, optimal focusing is determined with this
Position.
The species that edge detection operator contains at present is a lot, such as Laplce(Laplace)Operator, Sobel(Sobel)
Operator, Luo Baici(Roberts)Operator, Prewitt(Prewitt)Operator, Tuscany(Canny)Operator or gradient detective operators
Deng.
Simplest auto-focusing algorithm passes through to travel through all positions of camera lens, according to the gathered image in all positions of camera lens
Sharpness value determine the relation of optimal focusing position, the image sharpness value of each lens location of collection and lens location as shown in figure 1,
Think under normal circumstances, the lens location when sharpness value reaches maximum, be exactly optimal focusing position.
The extraction of the sharpness value in existing auto-focusing algorithm is generally dependent upon single edge detection operator.Although it is each
The sharpness value that different operators effectively can be extracted in most scenes is planted, work can be stablized under most of scenes
Make, but cannot ensure which there are all accurately and reliably, all the time some scenes that operator can be caused to fail in all of environment, now such as
Fruit auto-focusing algorithm uses the operator of failure, now the corresponding lens location of acutance maximum non-real optimal right
Burnt position, focusing generally can not be successful, cause shooting result to obscure, and seriously reduce picture quality.
For solving the above problems, technical solution of the present invention provides a kind of focusing method of imaging system, including:Using M kinds
Every kind of operator in edge detection operator is extracted in the sharpness value of the image collected by each lens location respectively, obtains every kind of calculation
The first focusing position corresponding to son, the first focusing position corresponding to the operator of N kind location matches determine the second focusing position
Put.The method passes through the sharpness value for extracting the collected image of each lens location using multiple edge detection operators respectively, and then
Obtain optimal focusing position.
Fig. 2 is the schematic flow sheet of the focusing method of the imaging system that technical solution of the present invention is provided.As shown in Fig. 2 institute
The focusing method for stating imaging system comprises the steps:
Step S1, is extracted in what each lens location was collected respectively using the every kind of operator in M kind edge detection operators
The sharpness value of image, wherein, M >=2.
Each lens location institute is extracted respectively using each operator in the M kind operators in the edge detection operator
The sharpness value of collection image, thus for the image collected by each lens location, all can have M sharpness value, corresponding to M
Operator is planted, the value of the M is more than or equal to 2.
Each lens location is respectively each lens location that camera lens is moved in mobile range with pre- fixed step size.Institute
State the integral multiple that pre- fixed step size is the minimum range that the camera lens can be moved.
In the moveable scope of camera lens, the minimum range that can be moved according to camera lens determines the predetermined step of camera lens movement
Long.It is camera lens that the pre- fixed step size can be the distance that the minimum range that the camera lens can be moved, i.e. camera lens often move once
The lowest distance value that can be moved;The pre- fixed step size can also be the integral multiple of the minimum range that the camera lens can be moved,
Such as, the pre- fixed step size is set to 5 times of the lowest distance value that camera lens can be moved, then the distance that camera lens often moves once is camera lens
5 times of the lowest distance value that can be moved.The selection of the pre- fixed step size can be according to the adjustable scope of camera lens and camera lens
Mobile lowest distance value is set.
Step S2, obtains the first focusing position corresponding to every kind of operator, the first focusing position corresponding to the operator
The lens location corresponding to image when being the sharpness value maximum using this kind of operator extraction.
In step sl, every kind of operator has been extracted in the sharpness value of the image collected by each lens location, then in step
In rapid S2, for each operator, the camera lens position corresponding to image when obtaining the sharpness value maximum using this kind of operator extraction
Put, and determine that the lens location is the first focusing position corresponding to the operator, thereby determine that each operator in M kind operators
The first corresponding focusing position.
Due to the first focusing position corresponding to every kind of operator be the operator extraction sharpness value maximum when image
The position at place, so the first focusing position corresponding to every kind of operator is the optimal focusing position determined by the operator
Put.
Step S3, the first focusing position corresponding to the operator of N kind location matches determine the second focusing position, institute's rheme
The operator for putting coupling is that the difference between corresponding the first focusing position in the M kinds operator is less than or equal to position threshold
Operator.
In step s 2, after determining the first focusing position corresponding to M kinds operator each operator, first, by described
The first focusing position corresponding to each operator determines the operator of location matches in M kind operators.If having N kinds in M kind operators
The difference between the first focusing position corresponding to operator is less than or equal to position threshold, it is determined that the N kinds operator is position
The operator of coupling, wherein, 0<N≤M.As the first focusing position corresponding to operator is the optimal focusing that determined by the operator
Position, if so the difference between the first focusing position corresponding to two kinds of operators is less than or equal to position threshold, can be with
Determine determined by each operator in both operators the distance between optimal focusing position very close to, you can to think this
What in two kinds of operators, optimal focusing position determined by each operator was pointed to is same focusing position.In the embodiment of the present invention
In, the operator of the N kinds location matches is referred between the first focusing position in this N kind operator corresponding to any two kinds of operators
Difference is less than or equal to position threshold.
As camera lens is moved with pre- fixed step size, the pre- fixed step size often moves distance value once for camera lens, so
The distance between any two position of camera lens collection image should be more than or equal to pre- fixed step size, as the position threshold is
The span of the difference of the first focusing position corresponding to the operator of location matches set in advance, i.e., described first focusing position
Difference be gather image two positions between difference, so the position threshold should be greater than or be equal to the pre- fixed step size.
After determining the operator of N kind location matches in M kind operators, corresponding to the operator of the N kinds location matches the
One focusing position determines that the second focusing position, second focusing position are the final optimal focusing position for determining.Described
Two focusing positions can be the average of the first focusing position corresponding to the operator of the N kinds location matches.Second focusing
Position can also be the weighted mean of the first focusing position corresponding to the operator of the N kinds location matches.By N kind location matches
Operator corresponding to the first focusing position method for specifically determining the second focusing position, be not limited thereto.
Technical solution of the present invention is described in detail with reference to specific embodiment.
In the present embodiment, specifically, M kinds edge detection operator is set as three kinds of edge detection operators, i.e. M=3 is described
Three kinds of edge detection operators are respectively Laplace operator, Sobel Operator and Luo Baici operators.
The present embodiment specifically gives the method for determining optimal focusing position using three kinds of edge detection operators, in other realities
Apply in mode, optimal focusing position can be determined using multiple edge detection operators, the edge detection operator can be that drawing is general
Laplacian operater, Sobel Operator, Luo Baici operators, Prewitt operator, Canny operator or gradient detective operators, here do not do too
Many restrictions.
Laplace operator is the relatively common one kind of edge detection operator, and the Laplace operator extracts the sharp of image
If the method for angle value is to extract the sharpness value in certain region of image, by extracting each pixel in the region
Sharpness value, then the sharpness value summation of all pixels point in the region is obtained the sharpness value in the described image region, by institute
The sharpness value for stating the region may determine that the readability of image in the region.
During auto-focusing, if extracting sharpness value to the pixel for constituting entire image, not only need a large amount of
Time, make auto-focusing speed extremely low, and the accuracy that focuses done harm rather than good, so focusing window can be selected, utilize
Edge detection operator extracts the sharpness value of the image in focusing window region.
Common focusing window is the zonule of K × L pixel for selecting image central authorities, or selects the tool in image
Have the several regions for representing meaning as focusing window, it would however also be possible to employ nonuniform sampling focusing window or based on skin visit
Focusing window of survey etc., the selection of focusing window can be selected using existing multiple methods, be not limited thereto.
The method for extracting the sharpness value of image using edge detection operator is to extract the sharpness value in certain region of image, by institute
The sharpness value for stating the region judges the readability of the image.
Specifically, during the sharpness value of a pixel of the Laplace operator in extraction region, with the pixel
The sharpness value that sues for peace as central pixel point is weighted in the image-region of 3 × 3 put centered on point to each pixel, described
The sharpness value of central pixel point is the sharpness value of the pixel.
Fig. 3 A are the pixel position views of image provided in an embodiment of the present invention, and Fig. 3 B are that the embodiment of the present invention is provided
Laplace operator weight schematic diagram, as shown in Figure 3A, if asked(X, y)The sharpness value of the pixel at place, then first obtain
It is able to(X, y)9 pixels in the image-region of 3 × 3 centered on the pixel at place, then the picture to 9 pixels
Element value weighted sum, the weight of 9 pixels is as shown in Figure 3 B, then(X, y)Place pixel sharpness value be:4×P
(x-1, y) (x+1, y)-P (x, y+1), wherein, x is that pixel is believed in the position in X-coordinate direction to-P to (x, y)-P (x, y-1)-P
Breath, y be pixel Y-coordinate direction positional information, P(X, y)Represent and in coordinate be(X, y)The pixel value of the pixel at place.
Further, the sharpness value of each pixel in the region is obtained by said process, the acutance to each pixel
Value summation then can be in the hope of the image sharpness value in the region, in this, as the sharpness value of entire image.
Sobel Operator be another kind be widely used for extract image sharpness value operator, and Laplace operator extract figure
As the method for sharpness value is similar, Fig. 3 C are the weight schematic diagrames of Sobel Operator provided in an embodiment of the present invention, Sobel Operator
Horizontal weight and longitudinal weight as shown in Figure 3 C, in image-region of the Sobel Operator to 3 × 3 centered on a certain pixel
Each pixel is weighted summation, respectively obtains horizontal sharpness value Gx of the pixel and sharpness value Gy of longitudinal direction, and will
Horizontal sharpness value Gx is added with the absolute value of sharpness value Gy of longitudinal direction, the acutance of the result of addition as central pixel point
Value, i.e., the sharpness value of described pixel.
Incorporated by reference to Fig. 3 A and Fig. 3 C are referred to, if asked with Sobel Operator(X, y)Place pixel sharpness value, to(X,
y)The pixel value of 9 pixels in the image-region of 3 × 3 centered on the pixel at place is respectively using horizontal weight and longitudinal direction
Weight is obtained(X, y)Horizontal sharpness value Gx of place's pixel and sharpness value Gy of longitudinal direction.Specifically,(X, y)Place's pixel
Horizontal sharpness value Gx is:-P(x-1,y+1)+2×P(x,y+1)-P(x+1,y+1)-P(x-1,y-1)+2×P(x,y-1)-P
(x+1, y-1),(X, y)Sharpness value Gy of longitudinal direction of place's pixel is:-P(x-1,y+1)+2×P(x-1,y)-P(x-1,y-1)-
P (x+1, y+1)+2 × P (then will by x+1, y)-P (x+1, y-1)(X, y)Horizontal sharpness value Gx of place's pixel and longitudinal direction
The absolute value of sharpness value Gy is added, and will add up result as pixel(X, y)The sharpness value at place, equally can be with by Sobel Operator
The sharpness value of each pixel is obtained, and then the sharpness value of entire image can be obtained.
Additionally, Luo Baici operators are also well used, the operator is similar with Sobel Operator, first passes through the side of weighted sum
Method obtains the horizontal and vertical sharpness value of a certain pixel respectively, then the absolute value of the horizontal and vertical sharpness value
With as the final sharpness value of the pixel.Except for the difference that, Luo Baici operators only need to 2 × 2 image-region, final acquisition
Be top left corner pixel sharpness value.Fig. 3 D are the weight schematic diagrames of Luo Baici operators provided in an embodiment of the present invention, Luo Baici
The horizontal weight of operator and longitudinal weight as shown in Figure 3 D, image district of the Luo Baici operators to 2 × 2 centered on a certain pixel
In domain, each pixel is weighted summation, respectively obtains horizontal sharpness value Gx of a certain pixel and the sharpness value of longitudinal direction
Gy, and horizontal sharpness value Gx is added with the absolute value of sharpness value Gy of longitudinal direction, itself and as top left corner pixel point
Sharpness value.
Incorporated by reference to Fig. 3 A and Fig. 3 D are referred to, if asked with Luo Baici operators(X, y)The sharpness value of the pixel at place, to
(X, y)The pixel at place is 4 pixels in the 2 × 2 of upper left corner image-region, respectively using horizontal weight and longitudinal direction power
Weight, obtains(X, y)Horizontal sharpness value Gx of the pixel at place and sharpness value Gy of longitudinal direction.Specifically,(X, y)The horizontal stroke of place's pixel
To sharpness value Gx be:P (x, y)-P (x+1, y-1),(X, y)Sharpness value Gy of longitudinal direction of place's pixel is:P(x+1,y)-P
(x, y-1), then will(X, y)Pixel horizontal sharpness value Gx in place's is added with the absolute value of sharpness value Gy of longitudinal direction, be will add up
As a result conduct(X, y)The sharpness value of place's pixel, equally can be obtained the sharpness value of each pixel, be entered by Luo Baici operators
And the sharpness value of entire image can be obtained.
Based on above-mentioned discussion, each mirror is extracted in respectively using Laplace operator, Sobel Operator and Luo Baici operators
The sharpness value of the image collected by head position, obtains the first focusing position corresponding to every kind of operator, further confirms that described
The number of the operator of the location matches in three kinds of edge detection operators, if there are two kinds of operators for location matches operator, then by
The first focusing position corresponding to the operator of described two location matches determines the second focusing position, the optimal position of focusing of final determination
Put.
Fig. 4 is the schematic flow sheet of the focusing method of the imaging system that the present embodiment is provided.As shown in figure 4, in imaging system
During system focusing, step S401 is first carried out.
Step S401, adjusts lens location.
In step S401, camera lens is adjusted to a certain position and is fixed, be subsequently to be imaged and calculate sharpness value to prepare.
Each lens location that the lens location can be moved with pre- fixed step size in mobile range for camera lens.
The adjustable position of camera lens is that the scope of the fixation is in camera lens or image within the scope of a fixation
Have determined when sensor module is dispatched from the factory.
The pre- fixed step size of the distance moved every time by camera lens, i.e. camera lens movement, can preset according to actual conditions, example
Such as, by taking mobile phone camera module as an example, if its camera lens adjustable range be divided into 1000 parts, i.e. camera lens can be at 1000
Position carries out shooting imaging, then, in focus process, focus algorithm, is judged to some of which position with pre- fixed step size adjustment camera lens
The sharpness value of the imaging of these positions, so as to finding optimal image space.If focus algorithm is using the mode of traversal, then
Focus process is equivalent to camera lens from the beginning of first position, and to last 1000th position, i.e., pre- fixed step size can be moved for camera lens
Dynamic minimum range, each position are imaged once, calculate the sharpness value of imaging every time, finally obtain 1000 sharpness values, look for
Maximum therein is arrived, then finds the corresponding lens location of the maximum, the position is exactly optimal focusing position.If focusing
Algorithm is attempted with pre- fixed step size 10 using quick mode, i.e., in position 1, position 10, and position 20 etc. is shot simultaneously
Calculate sharpness value, then will finally obtain 100 acutancees, and then find maximum therein, then find corresponding optimal focusing
Position, then, in the method for rapid focus, pre- fixed step size is 10 times of the minimum range that camera lens can be moved.
It will be evident that the focusing precision of the method for above-mentioned traversal and quick method is different.But focusing has certain
Tolerance.For example, the 120th position is actually focused optimal position, but on 110~130 positions into all
Picture, human eye are regarded as clearly, that is, do not see difference.This is the reason for fast method can be set up.
The method of adjustment of lens location is as it is known to those skilled in the art that can take the side of simplest traversal
Method, it would however also be possible to employ more optimal fast method, is not discussed in detail herein for lens location method of adjustment.Need
Bright, no matter using which kind of mode, the technical program is not construed as limiting.
After lens location is adjusted, execution step S402.
Step S402, scene imaging.
Specifically, image is gathered at the lens location that adjusts in step S401.
After the image that step S402 collects at the lens location, then execution step S403 is to step S405.
Step S403 is utilized respectively Laplace operator, Sobel Operator and Luo Baici operator extractions to step S405
The sharpness value of the lens location acquired image in step S402.
The method of Laplace operator, Sobel Operator and Luo Baici operator extraction image sharpness values is as explained above,
Will not be described here.
After the sharpness value for extracting described image using the operator respectively, execution step S406.
Step S406, judges that camera lens regulates whether to complete.
In this step, can be according to Laplace operator, Sobel Operator and sieve in step S403 to step S405
The every kind of operator of primary thatch operator obtains the sharpness value of each lens location acquired image and judges that camera lens regulates whether to complete.
Specifically, if each lens location institute with Laplace operator, Sobel Operator and Luo Baici operator extractions
Maximum in the sharpness value of collection image is respectively it has been determined that then judge that camera lens adjustment has been completed.
Such as, in step S406, it can be determined that whether each lens location all collecting images, and each lens location institute
The sharpness value of the image of collection is all obtained using every kind of operator, if it is, each camera lens position in every kind of operator extraction
Put in the sharpness value of gathered image and can just find out acutance maximum, now judge that camera lens adjustment has been completed;Otherwise return
To step S401, with pre- fixed step size, moving lens, to next lens location, repeats step S401 in the mobile range
To step S406, each the lens location collecting image in lens location mobile range, and to each camera lens position
Put the sharpness value of acquired image all using the acquisition of every kind of operator till.
It should be noted that during in step S401, lens location is adjusted, the pre- fixed step size of the camera lens movement
The minimum range that be able to can move for the camera lens of value, or the integer of the minimum range that the camera lens can be moved
Times.
Method for the maximum in the sharpness value of each lens location acquired image for determining every kind of operator acquisition
May also take on ramping constraint and determine whether image sharpness maximum has obtained, as the ramping constraint is this
Known to art personnel, here is not discussed in detail.
For the method for the maximum in the sharpness value of each lens location acquired image for determining every kind of operator acquisition,
Can be carried out using multiple methods well-known to those skilled in the art, here is not particularly limited.
If judging that in step S406 camera lens adjustment is completed, execution step S407 is to step S409;Otherwise return
Repeat step S401 to step S406, till judging that camera lens adjustment is completed.
Step S407, obtains the first focusing position corresponding to Luo Baici operators.
When the first focusing position corresponding to the Luo Baici operators is the sharpness value maximum using this kind of operator extraction
Lens location corresponding to image.Specifically, according to the gathered figure of each lens location of Luo Baici operator extractions in step S403
As sharpness value, determine that corresponding lens location when maximum of the image sharpness value that extracts, lens location now are Luo Baici
The first focusing position corresponding to operator.In an embodiment of the present invention, by the first focusing position corresponding to Luo Baici operators
It is designated as Pr.
Step S408, obtains the first focusing position corresponding to Sobel Operator.
Same as above, the first focusing position corresponding to the Sobel Operator is the acutance that is extracted using Sobel Operator
The lens location corresponding to image when value is maximum.Also according to each lens location institute that Sobel Operator in step S404 is extracted
Collection image sharpness value, determines that corresponding lens location when maximum of the image sharpness value that extracts is corresponding to Sobel Operator
The first focusing position.In an embodiment of the present invention, the first focusing position corresponding to Sobel Operator is designated as Ps.
Step S409, obtains the first focusing position corresponding to Laplace operator.
Above-mentioned discussion is based on, the gathered image sharpness of each lens location that can be extracted by step S405 Laplace operator
Value determines the first focusing position corresponding to Laplace operator.In an embodiment of the present invention, will be right for Laplace operator institute
The first focusing position that answers is designated as Pl.
Obtained after the first focusing position corresponding to every kind of operator by step S407 to step S409, execution step S410.
Step S410, determines the second focusing position.
In this step, institute is distinguished by Laplace operator, three kinds of operators of Sobel Operator and Luo Baici operators first
Corresponding first focusing position determines the operator of the location matches in three kinds of operators.The operator of the location matches is described
Operator of the difference in three kinds of operators between the first corresponding focusing position less than or equal to position threshold.The position threshold
It is more than or equal to pre- fixed step size.
As Laplace operator, three kinds of operators of Sobel Operator and Luo Baici operators are in the sharpness value for extracting image
During, the weight for using and the difference of specific algorithm, so when the image sharpness value determined by three kinds of operators is maximum
Corresponding lens location can be different, Laplace operator, Sobel Operator and Luo Baici operators institute obtained from
Corresponding first focusing position Pl, Ps and Pr are that each operator may be different.
In an embodiment of the present invention, if corresponding to Laplace operator, Sobel Operator and Luo Baici operators
First focusing position Pl, the difference between Ps and Pr between certain two values are less than or equal to position threshold, it is determined that described two
The individual operator for being worth the corresponding operator for location matches, i.e., in described three kinds of operators between the first corresponding focusing position
Difference is less than or equal to the operator that the operator of position threshold is defined as location matches.
The position threshold should be greater than or be equal to pre- fixed step size.By taking mobile phone camera module in step S401 as an example, camera lens
Shooting imaging can be carried out 1000 positions, by taking the result for traveling through as an example, pre- fixed step size is the most narrow spacing that camera lens can be moved
From that is, pre- fixed step size is the distance of a position, can be with the value of predeterminated position threshold value as 5, if Laplace operator, Sobel
The difference between the first focusing position in operator and Luo Baici operators corresponding to two operators is less than or equal to 5, then it is assumed that institute
The operator that two operators are configurations match is stated, the value of position threshold size equally will rely on focusing tolerance, i.e., in position
Acquired image on all positions within threshold range, human eye are regarded as clearly.But, if in step S401
With immediate mode focus method in, i.e., pre- fixed step size be 10 when, predeterminated position threshold value be 5 just cannot because quickly
The pre- fixed step size of method is 10, and more than 5, the value of the rational position threshold of now comparison should be 20, in sum, position
The value of threshold value is relevant with focusing method, and the position threshold should be more than or equal to pre- fixed step size.
Specifically, if corresponding to Laplace operator, three kinds of operators of Sobel Operator and Luo Baici operators first
Difference in focusing position Pl, Ps and Pr between the first focusing position of any two is respectively less than position threshold, it is determined that described
Three kinds of operators are entirely the operator of location matches;If the first focusing position Pl, Ps and Pr corresponding to three kinds of operators
Between difference between Pl and Ps be less than position threshold, and the difference between Pr and Pl and Ps is more than the position threshold, then really
Determine the operator of operator Laplace operator corresponding to Pl and Ps and Sobel Operator for location matches;If three kinds of operators
The first corresponding focusing position Pl, the difference between Ps and Pr are all higher than the position threshold, then confirm do not have position
The operator that matches somebody with somebody.
Location matches in Laplace operator, three kinds of operators of Sobel Operator and Luo Baici operators are confirmed by said process
Operator after, the first focusing position corresponding to the operator of the location matches determines the second focusing position.
In the present embodiment, if as long as have in three kinds of operators two kinds of operators be location matches operator, by institute
State the first focusing position corresponding to the operator of two kinds of location matches and determine the second focusing position, determine second focusing position
For reliable optimal focusing position.
Second focusing position is the average of the first focusing position corresponding to the operator of the location matches.For example,
If it is determined that the operator of Laplace operator and Sobel Operator for location matches, then the position of the second focusing is:P=(Pl+
Ps)/2.If the operator of all location matches of three kinds of operators, the second focusing position is:(Pl+Ps+Pr)/3.
In other embodiments, second focusing position can also be first corresponding to the operator of the location matches
The weighted mean of focusing position.For example, if it is determined that Laplace operator and Sobel Operator for location matches operator when, institute
The weight for stating the first focusing position corresponding to the operator of every kind of location matches can be according to the operator extraction of the location matches
The first focusing position at image sharpness value determine, if Laplace operator extract the first corresponding focusing position at figure
As sharpness value is Rl, at the first corresponding focusing position that Sobel Operator is extracted, image sharpness value is Rs, it is determined that La Pu
Weight Wl of the first focusing position corresponding to Laplacian operater is:Rl/(Rl+Rs), determine first corresponding to Sobel Operator
Weight Ws of focusing position is:Rs/(Rl+Rs).The first focusing corresponding to above-mentioned Laplace operator and Sobel Operator
The weight of position confirms that the second focusing position is:(Pl×Wl+Ps×Ws)/2.
Can being determined using other methods for the weight of first focusing position, is not limited thereto.
After step S410 determines the second focusing position, execution step S411.
Step S411, focusing position are exported.
Lens location is adjusted to the second focusing position that step S410 is obtained, determines that second focusing position is final
The optimal focusing position for determining.
In the present embodiment, employ the sharpness value that three kinds of different operators calculate images, using 2/3 judgement method come
Determine optimal focusing position, that is, adopt the first focusing position corresponding to the operator of two kinds of location matches in three kinds of operators to determine
Second focusing position.
Above-described embodiment is illustrated by taking M=3 as an example, it is also possible to which extension is applied to M>3 situation.Further, as M > 3
When, it is also possible to there is situations below:If the M kinds operator includes the first operator of N1 kind location matches and N2 kind location matches
The second operator, and N1>N2, then N values are N1, i.e. N=N1.
Specifically, if had in the M kind edge detection operators for adopting between the first focusing position corresponding to N1 kind operators
Difference be less than or equal to position threshold, herein by the N1 kinds operator with the first operator representation;Also, the M kinds edge
There is the difference between the first focusing position corresponding to N2 kind operators to be less than or equal to position threshold in detective operators, herein will
The N2 kinds operator is with the second operator representation.Wherein, any one first focusing position corresponding to the first operator with any
A kind of difference between the first focusing position corresponding to second operator is more than position threshold.
If number N1 of the first operator is more than number N2 of the second operator, corresponding to the operator of N1 kind location matches
The first focusing position determine the second focusing position, this is that result of focusing is put as the number of the operator of location matches
Reliability is higher, i.e. the degree of accuracy is higher.
Image that each lens location collected is extracted in respectively for example with the every kind of operator in 5 kinds of edge detection operators
Sharpness value, obtain the first focusing position corresponding to every kind of operator.There is 3 kind of first operator in five kinds of operators, 2 kind second
Operator, then the first focusing position corresponding to 3 kind of first operator determine the second focusing position.
In other embodiments, the reliability and standard of focus algorithm can be ensured using more edge detection operators
True property.If the sharpness value for calculating image using more edge detection operators, hypothesis without loss of generality employs M altogether here
Plant the sharpness value that edge detection operator calculates image, then optimal focusing position can be determined using the method for N/M judgements, its
In 0<N≤M, i.e., using the N kind location matches in M kind edge detection operators operator corresponding to the first focusing position determine
Two focusing positions, closer to M, the degree of accuracy of algorithm is higher for N, and, closer to 0, the reliability of algorithm is stronger for N.I.e. N is bigger, then calculate
Require in son that the operator of location matches is more, then the confidence level of this result is higher, i.e. the degree of accuracy is higher, but due to
The number of operator is more, then various operators be given different optimal focusing positions probability bigger, want to obtain N kind location matches
Its difficulty of operator is also just bigger, and under worst case, N kinds operator provides N kind Different Results, cannot now obtain N kind location matches
Operator, runs counter to desire, and algorithm fails;N is less, for example, be equal to 1, then as long as there is a kind of operator provide result, algorithm would not
Failure, therefore reliability is higher.
Specifically, the concrete value of M and N is not construed as limiting to this patent.
In the above-described embodiments, the operator using whole location matches in M kind operators is come final optimal right for determining
Burnt position(That is the second focusing position), that is, the sum of the operator that number N of the operator of location matches is all location matches
Amount.And in other embodiments, it is also possible to is determined from the operator of selected part location matches in the operator of all location matches
Two focusing positions, such as N directly can also determine according to the accuracy requirement and reliability requirement of focusing that N is selected part
The quantity of the operator of location matches;Or can also predetermined location coupling operator amount threshold, the operator of location matches
Number N be less than or equal to operator amount threshold.
For example, when the operator for having 8 kinds of location matches by the first focusing position determination corresponding to each operator, with
Operator amount threshold is equal to as a example by 5, then select the first focusing position corresponding to 5 kinds of operators in this 8 kinds of operators to determine the
Two focusing positions, typically, can select the immediate 5 kinds of operators of the first focusing position.
The operator amount threshold can be determined according to the accuracy requirement of focusing and reliability requirement.Specifically, if
During focusing, for focusing accuracy requirement high when, the value of operator amount threshold can be larger, and for
When the reliability requirement of focusing is high, then the value of operator amount threshold can be with smaller;In actual applications, can be with equilibrium
Accuracy and reliability requirement and set a suitable operator amount threshold.
Right by the method using N/M judgements, i.e. the operator institute using the N kind location matches in M kind edge detection operators
The method that the first focusing position that answers determines the second focusing position so as to same image, due to being calculated using multiple rim detections
Sub, it is ensured that focusing failure will not be caused because individual rim detective operators fail, fail from focusing is avoided to the full extent
Situation occurs, so as to ensure system imaging quality.
The focusing method of corresponding above-mentioned imaging system, technical solution of the present invention also provide a kind of focusing for determining imaging system
The device of method, as shown in figure 5, including:Extraction unit U11, acquiring unit U12 and determining unit U13.
Extraction unit U11, for being extracted in each lens location institute respectively using the every kind of operator in M kind edge detection operators
The sharpness value of the image for collecting, wherein, M >=2.
Each lens location is respectively each lens location that camera lens is moved in mobile range with pre- fixed step size.Profit
Each lens location acquired image is extracted respectively with each operator in the M kind operators in the edge detection operator
Sharpness value.
Acquiring unit U12, for obtaining the first focusing position corresponding to every kind of operator, first corresponding to the operator
Focusing position is the lens location corresponding to the image maximum using the sharpness value of this kind of operator extraction.
In an embodiment of the present invention, it has been extracted in each lens location by the every kind of operators of extraction unit U11 to be collected
Image sharpness value, for each operator, obtain sharpness value using this kind of operator extraction maximum when image corresponding to
Lens location, determine that the lens location is the first focusing position corresponding to the operator, thereby determine that each in M kind operators
Plant the first focusing position corresponding to operator.
Determining unit U13, determines the second focusing position for the first focusing position corresponding to the operator of N kind location matches
Put, the operator of the location matches is that the difference between corresponding the first focusing position in the M kinds operator is less than or equal to
The operator of position threshold.
After determining the first focusing position corresponding to M kinds operator each operator by acquiring unit U12, first, by institute
State the operator that the first focusing position corresponding to each operator determines location matches in M kind operators.If having N in M kind operators
The difference that plants between the first focusing position corresponding to operator is less than or equal to position threshold, it is determined that the N kinds operator is position
Put the operator of coupling, wherein, 0<N≤M.The first focusing position corresponding to the operator of the N kinds location matches determines second
Focusing position.
In one embodiment, determining unit U13 can include averaging unit, for calculating the second focusing position,
Second focusing position can be the average of the first focusing position corresponding to the operator of the N kinds location matches.
In another embodiment, determining unit U13 can also include weighted average unit, for calculating second pair
Burnt position, second focusing position are the weighted mean of the first focusing position corresponding to the operator of the N kinds location matches.
The realization of a unit concrete function in said apparatus, may refer to the focusing method kind offer of above-mentioned imaging system
Specific embodiment, will not be described here.
The present invention also provides a kind of imaging system, in addition to the basic elements of character such as camera lens, photo-sensitive cell and image processor are included,
Also include the focusing mechanism of above-mentioned imaging system.It will be understood by those skilled in the art that there is multiple prior arts, can will be upper
The focusing mechanism for stating above-mentioned imaging system is combined in the imaging system, and the present invention is not specifically limited to this.
Although present disclosure is as above, the present invention is not limited to this.Any those skilled in the art, without departing from this
In the spirit and scope of invention, can make various changes or modifications, therefore protection scope of the present invention should be with claim institute
The scope of restriction is defined.