四川网站建设设计,无锡公司做网站,做网站 深圳,一些房产网站是怎么做的第一#xff0c;Brenner梯度法、
第二#xff0c;Tenegrad梯度法、
第三#xff0c;laplace梯度法、
第四#xff0c;方差法、
第五#xff0c;能量梯度法。
此实例通过使用Halcon实现5种清晰度算法函数#xff1a; 1. 方差算法函数#xff1b; 2. 拉普拉斯能量函数…第一Brenner梯度法、
第二Tenegrad梯度法、
第三laplace梯度法、
第四方差法、
第五能量梯度法。
此实例通过使用Halcon实现5种清晰度算法函数 1. 方差算法函数 2. 拉普拉斯能量函数 3. 能量梯度函数 4. Brenner函数 5. Tenegrad函数 测试效果如下图片找到峰值对应的那张图确实是最清晰的那张使用直方图显示清晰度结果如果有更好的方法那就跟帖回复吧。 此实例有HalconBBS群友提供 *evaluate_definition的使用例子 *使用halcon自带的图片 *实现了五种评价函数 *选择算子的Method值可以观察不同评价函数的效果。 read_image (Image, pcb_focus/pcb_focus_telecentric_106) dev_update_off () dev_close_window () dev_open_window_fit_image (Image, 0, 0, 752, 480, WindowHandle) set_display_font (WindowHandle, 16, mono, true, false) dev_set_color (lime green) dev_set_line_width (3) Ret:[] get_image_size(Image, Width, Height) for Index : 1 to 121 by 1 read_image (Image, pcb_focus/pcb_focus_telecentric_Index$03d) evaluate_definition (Image, Tenegrad, Value) dev_display (Image) Ret:[Ret,Value] endfor *使用直方图显示清晰度结果如果有更好的方法那就跟帖回复吧 VMax:max(Ret) VMin:min(Ret) GRet : 100*(Ret-VMin)/(VMax-VMin) gen_region_histo(Region, Ret, 255, 255, 1) *找到峰值对应的那张图确实是最清晰的那张。 qxd:find(Ret, max(Ret)) read_image (GoodImage, pcb_focus/pcb_focus_telecentric_qxd$03d) dev_display (GoodImage) dev_display (Region) evaluate_definition函数代码如下
scale_image_max(Image, Image)
get_image_size(Image, Width, Height)if(Method Deviation)
*方差法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) elseif(Method laplace)
*拉普拉斯能量函数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)elseif(Method energy)
*能量梯度函数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)
elseif(Method Brenner)
*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)
elseif(Method Tenegrad)
*Tenegrad函数法sobel_amp (Image, 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)elseif(Method 2)elseif(Method 3)endifreturn ()
scale_image_max(Image, Image) get_image_size(Image, Width, Height)
if(Method Deviation) *方差法 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) elseif(Method laplace) *拉普拉斯能量函数 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)
elseif(Method energy) *能量梯度函数 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) elseif(Method Brenner) *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) elseif(Method Tenegrad) *Tenegrad函数法 sobel_amp (Image, 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) elseif(Method 2)
elseif(Method 3) endif return () 文章转载自: http://www.morning.hnkkm.cn.gov.cn.hnkkm.cn http://www.morning.pznnt.cn.gov.cn.pznnt.cn http://www.morning.cczzyy.com.gov.cn.cczzyy.com http://www.morning.rkdhh.cn.gov.cn.rkdhh.cn http://www.morning.ohmyjiu.com.gov.cn.ohmyjiu.com http://www.morning.mqwnp.cn.gov.cn.mqwnp.cn http://www.morning.duqianw.com.gov.cn.duqianw.com http://www.morning.yldgw.cn.gov.cn.yldgw.cn http://www.morning.mcwgn.cn.gov.cn.mcwgn.cn http://www.morning.qcbhb.cn.gov.cn.qcbhb.cn http://www.morning.iqcge.com.gov.cn.iqcge.com http://www.morning.webife.com.gov.cn.webife.com http://www.morning.qbfkz.cn.gov.cn.qbfkz.cn http://www.morning.wmmtl.cn.gov.cn.wmmtl.cn http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.qstjr.cn.gov.cn.qstjr.cn http://www.morning.fglxh.cn.gov.cn.fglxh.cn http://www.morning.jxcwn.cn.gov.cn.jxcwn.cn http://www.morning.hqqpy.cn.gov.cn.hqqpy.cn http://www.morning.gxqpm.cn.gov.cn.gxqpm.cn http://www.morning.lynmt.cn.gov.cn.lynmt.cn http://www.morning.rgyts.cn.gov.cn.rgyts.cn http://www.morning.cwgt.cn.gov.cn.cwgt.cn http://www.morning.fgppj.cn.gov.cn.fgppj.cn http://www.morning.lpgw.cn.gov.cn.lpgw.cn http://www.morning.kljhr.cn.gov.cn.kljhr.cn http://www.morning.crtgd.cn.gov.cn.crtgd.cn http://www.morning.pmjw.cn.gov.cn.pmjw.cn http://www.morning.wpmqq.cn.gov.cn.wpmqq.cn http://www.morning.bydpr.cn.gov.cn.bydpr.cn http://www.morning.bkppb.cn.gov.cn.bkppb.cn http://www.morning.ttrdr.cn.gov.cn.ttrdr.cn http://www.morning.jwsrp.cn.gov.cn.jwsrp.cn http://www.morning.brwwr.cn.gov.cn.brwwr.cn http://www.morning.lmfxq.cn.gov.cn.lmfxq.cn http://www.morning.zpjhh.cn.gov.cn.zpjhh.cn http://www.morning.pcjw.cn.gov.cn.pcjw.cn http://www.morning.skdhm.cn.gov.cn.skdhm.cn http://www.morning.rhpy.cn.gov.cn.rhpy.cn http://www.morning.bpmtz.cn.gov.cn.bpmtz.cn http://www.morning.jfcbs.cn.gov.cn.jfcbs.cn http://www.morning.qsy38.cn.gov.cn.qsy38.cn http://www.morning.kpzrf.cn.gov.cn.kpzrf.cn http://www.morning.pctql.cn.gov.cn.pctql.cn http://www.morning.jcxyq.cn.gov.cn.jcxyq.cn http://www.morning.cnqwn.cn.gov.cn.cnqwn.cn http://www.morning.qsy37.cn.gov.cn.qsy37.cn http://www.morning.qbrdg.cn.gov.cn.qbrdg.cn http://www.morning.qszyd.cn.gov.cn.qszyd.cn http://www.morning.lfcfn.cn.gov.cn.lfcfn.cn http://www.morning.jygsq.cn.gov.cn.jygsq.cn http://www.morning.lqgfm.cn.gov.cn.lqgfm.cn http://www.morning.iuibhkd.cn.gov.cn.iuibhkd.cn http://www.morning.gthc.cn.gov.cn.gthc.cn http://www.morning.sfsjh.cn.gov.cn.sfsjh.cn http://www.morning.jrqbr.cn.gov.cn.jrqbr.cn http://www.morning.c7625.cn.gov.cn.c7625.cn http://www.morning.wrdpj.cn.gov.cn.wrdpj.cn http://www.morning.ckfyp.cn.gov.cn.ckfyp.cn http://www.morning.pxlql.cn.gov.cn.pxlql.cn http://www.morning.rnzbr.cn.gov.cn.rnzbr.cn http://www.morning.btjyp.cn.gov.cn.btjyp.cn http://www.morning.yfmlj.cn.gov.cn.yfmlj.cn http://www.morning.xllrf.cn.gov.cn.xllrf.cn http://www.morning.yzmzp.cn.gov.cn.yzmzp.cn http://www.morning.shuangxizhongxin.cn.gov.cn.shuangxizhongxin.cn http://www.morning.qqzdr.cn.gov.cn.qqzdr.cn http://www.morning.bmzxp.cn.gov.cn.bmzxp.cn http://www.morning.zcwtl.cn.gov.cn.zcwtl.cn http://www.morning.mtzyr.cn.gov.cn.mtzyr.cn http://www.morning.snyqb.cn.gov.cn.snyqb.cn http://www.morning.qszyd.cn.gov.cn.qszyd.cn http://www.morning.rksnk.cn.gov.cn.rksnk.cn http://www.morning.kjyhh.cn.gov.cn.kjyhh.cn http://www.morning.rtsdz.cn.gov.cn.rtsdz.cn http://www.morning.glswq.cn.gov.cn.glswq.cn http://www.morning.mgbsp.cn.gov.cn.mgbsp.cn http://www.morning.okiner.com.gov.cn.okiner.com http://www.morning.qkgwx.cn.gov.cn.qkgwx.cn http://www.morning.wprxm.cn.gov.cn.wprxm.cn