Dowemo
0 0 0 0

Image clarity is an important index to measure image quality. For camera, it generally works in the mode of no reference image, so it's necessary to control. Focusing isn't accurate, the image will become ambiguous. When the camera is focused, the distance of the lens and ccd is controlled by some definition indicators. In general, there's a adjustment process, the image from blur to clear, to fuzzy, to determine the peak value, and finally reach the most clear position.
Common image definition evaluation is usually based on gradient method. This paper will introduce five simple evaluation indexes, brenner gradient method, tenegrad gradient.

Brenner gradient method

The gray difference between two pixels in two different units is calculated:
FBrenner=MN(f(x+2,y)f(x,y))2
In type (f(x+2,y)f(x,y))2>Threshold
Algorithm accuracy depends on threshold selection.

Tenegrad gradient method

The gradient of horizontal and vertical direction is extracted by sobel operator.
FTenegrad=MN|G(x,y)|
G(x,y)>Threshold
G(x,y)=Gx(x,y)2+Gy(x,y)2Square square
The sobel operator template is as follows:
Gx=14121000121I
Gy=14101202101I

Laplace gradient method

The laplace gradient function is identical with tenegrad, which only needs to replace the sobel operator with the laplace operator.
L=161414204141I

Variance method

Focusing clear image is larger than that of fuzzy image, and the variance function can be used as evaluation.
Fvariance=MN(f(x,y)E2)
The average gray value of the whole image, which is sensitive to noise sensitivity.

Energy gradient method

Energy gradient function is suitable for real-time evaluation of image clarity:
FBrenner=MN((f(x+1,y)f(x,y))2+(f(x,y+1)f(x,y))2)

Instance code

Implementation of Halcon:

//方差法region_to_mean(Image, Image, &ImageMean);
 convert_image_type(ImageMean, &ImageMean, "real");
 convert_image_type(Image, &Image, "real");
 sub_image(Image, ImageMean, &ImageSub, 1, 0);
 mult_image(ImageSub, ImageSub, &ImageResult, 1, 0);
 intensity(ImageResult, ImageResult, &Value, &Deviation);
//拉普拉斯梯度函数laplace(Image, &ImageLaplace4, "signed", 3, "n_4");
 laplace(Image, &ImageLaplace8, "signed", 3, "n_8");
 add_image(ImageLaplace4, ImageLaplace4, &ImageResult1, 1, 0);
 add_image(ImageLaplace4, ImageResult1, &ImageResult1, 1, 0);
 add_image(ImageLaplace8, ImageResult1, &ImageResult1, 1, 0);
 mult_image(ImageResult1, ImageResult1, &ImageResult, 1, 0);
 intensity(ImageResult, ImageResult, &Value, &Deviation);
//能量梯度函数crop_part(Image, &ImagePart00, 0, 0, Width-1, Height-1);
 crop_part(Image, &ImagePart01, 0, 1, Width-1, Height-1);
 crop_part(Image, &ImagePart10, 1, 0, Width-1, Height-1);
 convert_image_type(ImagePart00, &ImagePart00, "real");
 convert_image_type(ImagePart10, &ImagePart10, "real");
 convert_image_type(ImagePart01, &ImagePart01, "real");
 sub_image(ImagePart10, ImagePart00, &ImageSub1, 1, 0);
 mult_image(ImageSub1, ImageSub1, &ImageResult1, 1, 0);
 sub_image(ImagePart01, ImagePart00, &ImageSub2, 1, 0);
 mult_image(ImageSub2, ImageSub2, &ImageResult2, 1, 0);
 add_image(ImageResult1, ImageResult2, &ImageResult, 1, 0);
 intensity(ImageResult, ImageResult, &Value, &Deviation);
//Brenner梯度法crop_part(Image, &ImagePart00, 0, 0, Width, Height-2);
 convert_image_type(ImagePart00, &ImagePart00, "real");
 crop_part(Image, &ImagePart20, 2, 0, Width, Height-2);
 convert_image_type(ImagePart20, &ImagePart20, "real");
 sub_image(ImagePart20, ImagePart00, &ImageSub, 1, 0);
 mult_image(ImageSub, ImageSub, &ImageResult, 1, 0);
 intensity(ImageResult, ImageResult, &Value, &Deviation);
//Tenegrad梯度法sobel_amp(Image, &EdgeAmplitude, "sum_sqrt", 3);
 min_max_gray(EdgeAmplitude, EdgeAmplitude, 0, &Min, &Max, &Range);
 threshold(EdgeAmplitude, &Region1, 20, 255);
 region_to_bin(Region1, &BinImage, 1, 0, Width, Height);
 mult_image(EdgeAmplitude, BinImage, &ImageResult4, 1, 0);
 mult_image(ImageResult4, ImageResult4, &ImageResult, 1, 0);
 intensity(ImageResult, ImageResult, &Value, &Deviation);

Results analysis

The processing image is a set of images from blur to clear and to blur, as shown in the three images:
这里写图片描述
In the middle, the most clear image.
By using five evaluation functions, a hundreds of images are calculated, and the results are normalized, and the results are shown as follows:
这里写图片描述
A good evaluation function needs to have,, sensitivity, in this case, using laplace, energy gradient and brenner gradient method better.




Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs