ImageOut := Image
scale_image_max (ImageOut, ImageOut)
get_image_size (ImageOut, Width, Height)
if(Method = ‘Deviation’)
*方差法
region_to_mean (ImageOut, ImageOut, ImageMean)
convert_image_type (ImageMean, ImageMean, ‘real’)
convert_image_type (ImageOut, ImageOut, ‘real’)
sub_image (ImageOut, ImageMean, ImageSub, 1, 0)
mult_image(ImageSub, ImageSub, ImageResult, 1, 0)
intensity(ImageResult, ImageResult, Value, Deviation)
elseif(Method = ‘laplace’)
*拉普拉斯能量函数
laplace (ImageOut, ImageLaplace4, ‘signed’, 3, ‘n_4’)
laplace (ImageOut, 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)
elseif(Method = ‘energy’)
*能量梯度函数
crop_part (ImageOut, ImagePart00, 0, 0, Width-1, Height-1)
crop_part (ImageOut, ImagePart01, 0, 1, Width-1, Height-1)
crop_part (ImageOut, 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)
elseif(Method = ‘Brenner’)
*Brenner函数法
crop_part (ImageOut, ImagePart00, 0, 0, Width, Height-2)
convert_image_type (ImagePart00, ImagePart00, ‘real’)
crop_part (ImageOut, 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)
elseif(Method = ‘Tenegrad’)
*Tenegrad函数法
sobel_amp (ImageOut, EdgeAmplitude, ‘sum_sqrt’, 3)
min_max_gray(EdgeAmplitude, EdgeAmplitude, 0, Min, Max, Range)
threshold(EdgeAmplitude, Region1, 11.8, 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)
endif
return ()
下面是封装函数,并调用测试.图像中间的圆区域是模糊的,大圆与小圆之间的圆环区域是清晰的。根据
函数返回值的大小判断清晰度。值越大,越清晰。
read_image (Image0, ‘E:/source.bmp’)
gen_circle (ROI_0, 1135.65, 1238.88, 128.777)
gen_circle (ROI_1, 1136.5, 1239.38, 178.645)
difference (ROI_1, ROI_0, RegionDifference2)
reduce_domain (Image0, ROI_0, ImageReduced1)
reduce_domain (Image0, RegionDifference2, ImageReduced2)
evaluate_definition (ImageReduced1, ‘Tenegrad’, Value)
evaluate_definition (ImageReduced2, ‘Tenegrad’, Value1)