- 7
- 0
- 约1.24万字
- 约 11页
- 2020-03-03 发布于江苏
- 举报
public class EdgeDetect : ImageInfo??? {??????? /************************************************************???????? * ???????? * Roberts, Sobel, Prewitt, Kirsch, GaussLaplacian???????? * 水平检测、垂直检测、边缘增强、边缘均衡化???????? * ???????? ************************************************************/
?
??? /// summary??? /// 对两幅图像进行梯度运算??? /// /summary??? /// param name=b1位图 1/param??? /// param name=b2位图 2/param??? /// returns/returns??? private Bitmap Gradient(Bitmap b1, Bitmap b2)??? {????? ????? int width = b1.Width;????? int height = b1.Height;
????? BitmapData data1 = b1.LockBits(new Rectangle(0, 0, width, height),??????? ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);????? BitmapData data2 = b2.LockBits(new Rectangle(0, 0, width, height),??????? ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
????? unsafe????? {??????? byte* p1 = (byte*)data1.Scan0;??????? byte* p2 = (byte*)data2.Scan0;
??????? int offset = data1.Stride - width * BPP;
??????? for (int y = 0; y height; y++)??????? {????????? for (int x = 0; x width; x++)????????? {??????????? for (int i = 0; i 3; i++)??????????? {????????????? int power = (int)Math.Sqrt((p1[i] * p1[i] + p2[i] * p2[i]));????????????? p1[i] = (byte)(power 255 ? 255 : power);??????????? } // i
??????????? p1 += BPP;??????????? p2 += BPP;????????? } // x
????????? p1 += offset;????????? p2 += offset;??????? } // y????? }
????? b1.UnlockBits(data1);????? b2.UnlockBits(data2);
????? Bitmap dstImage = (Bitmap)b1.Clone();
????? b1.Dispose();????? b2.Dispose();
????? return dstImage;??? } // end of Gradient
??? /// summary??? /// 按 Roberts 算子进行边缘检测??? /// /summary??? /// param name=b位图流/param??? /// returns/returns??? public Bitmap Roberts(Bitmap b)??? {????? int width = b.Width;????? int height = b.Height;
????? Bitmap dstImage = new Bitmap(width, height);
????? BitmapData srcData = b.LockBits(new Rectangle(0, 0, width, height),??????? ImageLockMode.ReadOnly, PixelFormat.Format3
您可能关注的文档
最近下载
- 心脑血管的危害和防治.ppt
- 上海2024年高考英语试卷.doc VIP
- 2026春新版人教版八年级下册单词默写单词表(全)U1-U8中译英.docx
- 07 王涛-教师资格-数学学科知识与教学能力(高中)-第三部分第五章至第八章(46-48讲).pdf VIP
- 《业财一体化实训教程-----金蝶云星空V7.5》.pptx VIP
- 2014广东粤西北事业单位考试真题及答案——通用类.doc VIP
- 基于PLC的运料小车自动控制设计研究.docx VIP
- ISO 9001(DIS)-2026《质量管理体系——要求》(含附录使用指南-中文版-译-2025年9月).docx VIP
- 《宋代点茶文化与艺术》全套教学课件.pptx
- 年产3000吨猕猴桃果汁工厂设计_毕业设计.doc VIP
原创力文档

文档评论(0)