原文:Win8 Metro(C#)数字图像处理--2.65形态学轮廓提取算法



[函数名称]

  形态学轮廓提取函数

      WriteableBitmap MorcontourextractionProcess(WriteableBitmap src)

       /// <summary>
/// Morgraphy contour extraction process.
/// </summary>
/// <param name="src">The source image.</param>
/// <returns></returns>
public static WriteableBitmap MorcontourextractionProcess(WriteableBitmap src)////形态学轮廓提取
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap corrosionImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
byte[] tempMask = (byte[])temp.Clone();
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
if (i == 0 || i == w - 1 || j == 0 || j == h - 1)
{
temp[i * 4 + j * w * 4] = (byte)255;
temp[i * 4 + 1 + j * w * 4] = (byte)255;
temp[i * 4 + 2 + j * w * 4] = (byte)255;
}
else
{
if (tempMask[i * 4 - 4 + j * w * 4] == 255 && tempMask[i * 4 + j * w * 4] == 255 && tempMask[i * 4 + 4 + j * w * 4] == 255
&& tempMask[i * 4 + (j - 1) * w * 4] == 255 && tempMask[i * 4 + (j + 1) * w * 4] == 255)
{
temp[i * 4 + j * w * 4] = (byte)255;
temp[i * 4 + 1 + j * w * 4] = (byte)255;
temp[i * 4 + 2 + j * w * 4] = (byte)255;
}
else
{
temp[i * 4 + j * w * 4] = 0;
temp[i * 4 + 1 + j * w * 4] = 0;
temp[i * 4 + 2 + j * w * 4] = 0;
}
}
}
}
for (int i = 0; i < temp.Length; i++)
{
temp[i] = (byte)(tempMask[i]-temp[i]);
}
Stream sTemp = corrosionImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return corrosionImage;
}
else
{
return null;
}
}

最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:

Win8 Metro(C#)数字图像处理--2.65形态学轮廓提取算法的更多相关文章

  1. Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法

    原文:Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法  [函数名称]   二值图像轮廓提取         ContourExtraction(WriteableBitm ...

  2. Win8 Metro(C#)数字图像处理--2.64图像高斯滤波算法

    原文:Win8 Metro(C#)数字图像处理--2.64图像高斯滤波算法  [函数名称]   高斯平滑滤波器      GaussFilter(WriteableBitmap src,int r ...

  3. Win8 Metro(C#)数字图像处理--2.60部分彩色保留算法

    原文:Win8 Metro(C#)数字图像处理--2.60部分彩色保留算法  [函数名称]   部分彩色保留函数       WriteableBitmap PartialcolorProcess ...

  4. Win8 Metro(C#)数字图像处理--2.51图像统计滤波算法

    原文:Win8 Metro(C#)数字图像处理--2.51图像统计滤波算法  [函数名称]   图像统计滤波   WriteableBitmap StatisticalFilter(Writeab ...

  5. Win8 Metro(C#)数字图像处理--2.44图像油画效果算法

    原文:Win8 Metro(C#)数字图像处理--2.44图像油画效果算法  [函数名称]   图像油画效果      OilpaintingProcess(WriteableBitmap src ...

  6. Win8 Metro(C#)数字图像处理--2.47人脸红眼去除算法

    原文:Win8 Metro(C#)数字图像处理--2.47人脸红眼去除算法  [函数名称]   红眼去除     RedeyeRemoveProcess(WriteableBitmap src) ...

  7. Win8 Metro(C#)数字图像处理--2.43图像马赛克效果算法

    原文:Win8 Metro(C#)数字图像处理--2.43图像马赛克效果算法  [函数名称] 图像马赛克效果        MosaicProcess(WriteableBitmap src, i ...

  8. Win8 Metro(C#)数字图像处理--2.35图像肤色检测算法

    原文:Win8 Metro(C#)数字图像处理--2.35图像肤色检测算法  [函数名称] 肤色检测函数SkinDetectProcess(WriteableBitmap src) [算法说明] ...

  9. Win8 Metro(C#)数字图像处理--2.36角点检测算法

    原文:Win8 Metro(C#)数字图像处理--2.36角点检测算法  [函数名称] Harris角点检测函数    HarrisDetect(WriteableBitmap src, int  ...

随机推荐

  1. 【机器学习实战】第9章 树回归(Tree Regression)

    第9章 树回归 <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/ ...

  2. 雷观(十):管理自己的任务列表(TodoList)很重要

    由幼年,到青年,再到成年,你会发现自己有越来越多的事情要做.参加工作后,很可能要在多个战线上同时忙碌. 最常见的有,工作(可能会加班加点).爱情(不少人忙着恋爱,需要花费很多心思).个人娱乐(玩游戏看 ...

  3. 【codeforces 750B】New Year and North Pole

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. CSS盒子模型中距离的通俗解释

    设一个有两个div,一大一小,小的div在大的div里面,而小的div和大div直接的距离就叫外边距,用margin.margin-left.margin-right.margin-top.margi ...

  5. iOS解决json串中的NSNull类型

    iOS解决json串中的NSNull类型   后端返回的数据中总会出现一些NSNull类型,当我们一处理程序就会崩溃,因此想到把返回的数据中的NSNull类型全部转换成@""空字符 ...

  6. 《Windows核心编程》之“完成端口”(对所有IO都是如此,不仅仅是对socket)

    <Windows核心编程>第10章开头部分一再强调:“IO Completion Port”是“构建高性能.可升缩的应用程序”的最佳设施之一,它不仅适用于处理设备IO,也适用于其它越来越多 ...

  7. kindeditor 4 指定生成文件的时间日期/动态获取My97的时间

    最近后台要求要指定上传附件的时间日期,编辑器是kindeditor,仔细研究后发现可以借助clickToolbar事件,传递时间到后台,但是中途发现传递的时间总是初始化my97的时间,改变后的时间只有 ...

  8. freemarker中间split字符串切割

    freemarker中间split字符串切割 1.简易说明 split切割:用来依据另外一个字符串的出现将原字符串切割成字符串序列 2.举例说明 <#--freemarker中的split字符串 ...

  9. 【24.58%】【BZOJ 1001】狼抓兔子

    Time Limit: 15 Sec Memory Limit: 162 MB Submit: 19227 Solved: 4726 [Submit][Status][Discuss] Descrip ...

  10. 《iOS8 Swift编程指南》类书图像

    终于拿到了样书.虽然已经猜到这将是一本很厚的书(63万字),但要真正看到实体书或者当我吃了一惊: 从以下这张照片看则更直观了.居然比艾伦.J.马库斯的<投资学>(634页)还要厚: 这本书 ...