(canny+算法)地java实现+

(canny+算法)地java实现+

ID:34813365

大小:213.50 KB

页数:10页

时间:2019-03-11

(canny+算法)地java实现+_第1页
(canny+算法)地java实现+_第2页
(canny+算法)地java实现+_第3页
(canny+算法)地java实现+_第4页
(canny+算法)地java实现+_第5页
资源描述:

《(canny+算法)地java实现+》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、实用标准边缘检测算法的基本步骤(1)滤波。边缘检测主要基于导数计算,但受噪声影响。但滤波器在降低噪声的同时也导致边缘强度的损失。(2)增强。增强算法将邻域中灰度有显著变化的点突出显示。一般通过计算梯度幅值完成。(3)检测。但在有些图象中梯度幅值较大的并不是边缘点。最简单的边缘检测是梯度幅值阈值判定。(4)定位。精确确定边缘的位置。Canny边缘检测算法step1:用高斯滤波器平滑图象;step2:用一阶偏导的有限差分来计算梯度的幅值和方向;step3:对梯度幅值进行非极大值抑制;step4:用双阈值算法检测和连接边缘。效果图如下:代码如下:packagetools; 文档实

2、用标准importjava.awt.*;importjava.awt.image.*; publicclassEdgeDetectorextendsComponent{ publicEdgeDetector(){threshold1=50;threshold2=230;setThreshold(128);setWidGaussianKernel(15);} publicvoidprocess()throwsEdgeDetectorException{if(threshold<0

3、

4、threshold>255)thrownewEdgeDetectorException("Th

5、evalueofthethresholdisoutofitsvalidrange.");if(widGaussianKernel<3

6、

7、widGaussianKernel>40)thrownewEdgeDetectorException("ThevalueofthewidGaussianKernelisoutofitsvalidrange.");width=sourceImage.getWidth(this);height=sourceImage.getHeight(this);picsize=width*height;data=newint[picsize];magnit

8、ude=newint[picsize];orientation=newint[picsize];floatf=1.0F;canny_core(f,widGaussianKernel);thresholding_tracker(threshold1,threshold2);for(inti=0;ithreshold)data[i]=0xff000000;elsedata[i]=-1; edgeImage=pixels2image(data);data=null;magnitude=null;orientation=null;} 

9、privatevoidcanny_core(floatf,inti){booleanflag=false;booleanflag1=false;derivative_mag=newint[picsize];文档实用标准floataf4[]=newfloat[i];floataf5[]=newfloat[i];floataf6[]=newfloat[i];data=image2pixels(sourceImage);intk4=0;do{if(k4>=i)break;floatf1=gaussian(k4,f);if(f1<=0.005F&&k4>=2)break;float

10、f2=gaussian((float)k4-0.5F,f);floatf3=gaussian((float)k4+0.5F,f);floatf4=gaussian(k4,f*0.5F);af4[k4]=(f1+f2+f3)/3F/(6.283185F*f*f);af5[k4]=f3-f2;af6[k4]=1.6F*f4-f1;k4++;}while(true);intj=k4;floataf[]=newfloat[picsize];floataf1[]=newfloat[picsize];intj1=width-(j-1);intl=width*(j-1);inti1=wi

11、dth*(height-(j-1));for(intl4=j-1;l4

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。