欢迎来到天天文库
浏览记录
ID:57892540
大小:55.00 KB
页数:11页
时间:2020-04-02
《边缘提取算法.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、publicclassEdgeDetect:ImageInfo { /************************************************************ * *Roberts,Sobel,Prewitt,Kirsch,GaussLaplacian *水平检测、垂直检测、边缘增强、边缘均衡化 * ************************************************************/
2、 /// ///对两幅图像进行梯度运算 /// ///位图1 ///位图2 /// privateBitmapGradient(Bitmapb1,Bitmapb2) { intwidth=b1.Width; intheight=b1.Height; BitmapDatadata1=b1.LockBits(
3、newRectangle(0,0,width,height), ImageLockMode.ReadWrite,PixelFormat.Format32bppArgb); BitmapDatadata2=b2.LockBits(newRectangle(0,0,width,height), ImageLockMode.ReadOnly,PixelFormat.Format32bppArgb); unsafe { byte*p1=(byte*)data1.Scan0;
4、byte*p2=(byte*)data2.Scan0; intoffset=data1.Stride-width*BPP; for(inty=0;y5、=(byte)(power>255?255:power); }//i p1+=BPP; p2+=BPP; }//x p1+=offset; p2+=offset; }//y } b1.UnlockBits(data1); b2.UnlockBits(data2); BitmapdstImage=(Bitmap)b1.Clone(); b1.Dispose(); b2.Dis6、pose(); returndstImage; }//endofGradient /// ///按Roberts算子进行边缘检测 /// ///位图流 /// publicBitmapRoberts(Bitmapb) { intwidth=b.Width; intheight=b.Height; BitmapdstImage=newBitmap(width7、,height); BitmapDatasrcData=b.LockBits(newRectangle(0,0,width,height), ImageLockMode.ReadOnly,PixelFormat.Format32bppArgb); BitmapDatadstData=dstImage.LockBits(newRectangle(0,0,width,height), ImageLockMode.WriteOnly,PixelFormat.Format32bppArgb); in8、tstride=srcData.Stride; intoffset=stride-width*BPP; unsafe { byte*src=(byte*)s
5、=(byte)(power>255?255:power); }//i p1+=BPP; p2+=BPP; }//x p1+=offset; p2+=offset; }//y } b1.UnlockBits(data1); b2.UnlockBits(data2); BitmapdstImage=(Bitmap)b1.Clone(); b1.Dispose(); b2.Dis
6、pose(); returndstImage; }//endofGradient /// ///按Roberts算子进行边缘检测 /// ///位图流 /// publicBitmapRoberts(Bitmapb) { intwidth=b.Width; intheight=b.Height; BitmapdstImage=newBitmap(width
7、,height); BitmapDatasrcData=b.LockBits(newRectangle(0,0,width,height), ImageLockMode.ReadOnly,PixelFormat.Format32bppArgb); BitmapDatadstData=dstImage.LockBits(newRectangle(0,0,width,height), ImageLockMode.WriteOnly,PixelFormat.Format32bppArgb); in
8、tstride=srcData.Stride; intoffset=stride-width*BPP; unsafe { byte*src=(byte*)s
此文档下载收益归作者所有