原文:Win8Metro(C#)数字图像处理--2.13Roberts边缘检测



[函数名称]

图像Roberts边缘检测函数RobertEdgeProcess(WriteableBitmap
src)

[函数代码]

       ///<summary>

       ///
Roberts edge detection.

       ///</summary>

       ///<param
name="src">Source image.</param>

       ///<returns></returns>

       publicstaticWriteableBitmap
RobertEdgeProcess(WriteableBitmap src)////13
Robert边缘检测

       {

           if(src!=null
)

           {

           int
w = src.PixelWidth;

           int
h = src.PixelHeight;

           WriteableBitmap
robertImage =newWriteableBitmap(w,h);

           byte[]
temp = src.PixelBuffer.ToArray();

           byte[]
tempMask = (byte[])temp.Clone();

           int
b = 0, g = 0, r = 0;

           for
(int j = 1; j < h - 1; j++)

           {

               for
(int i = 4; i < w * 4 - 4; i += 4)

               {

                   if
(i == 0 || i == w - 4 || j == 0 || j == h - 1)

                   {

                       temp[i + j * w * 4] = (byte)0;

                       temp[i + 1 + j * w * 4] = (byte)0;

                       temp[i + 2 + j * w * 4] = (byte)0;

                   }

                   else

                   {

                       b =Math.Abs(tempMask[i
+ j * w * 4] - tempMask[i - 4 + (j+1) * w * 4]) + Math.Abs(tempMask[i
- 4 + j * w * 4] - tempMask[i + (j + 1) * w * 4]);

                       g =Math.Abs(tempMask[i
+ 1 + j * w * 4] - tempMask[i - 4 + 1 + (j + 1) * w * 4]) + Math.Abs(tempMask[i
- 4 + 1 + j * w * 4] - tempMask[i + 1 + (j + 1) * w * 4]);

                       r =Math.Abs(tempMask[i
+ 2 + j * w * 4] - tempMask[i - 4 + 2 + (j + 1) * w * 4]) + Math.Abs(tempMask[i
- 4 + 2 + j * w * 4] - tempMask[i + 2 + (j + 1) * w * 4]);

                       temp[i + j * w * 4] = (byte)(b
> 0 ? (b < 255 ? b : 255) : 0);

                       temp[i + 1 + j * w * 4] = (byte)(g
> 0 ? (g < 255 ? g : 255) : 0);

                       temp[i + 2 + j * w * 4] = (byte)(r
> 0 ? (r < 255 ? r : 255) : 0);

                   }

                   b = 0; g = 0; r = 0;

               }

           }

           Stream
sTemp = robertImage.PixelBuffer.AsStream();

           sTemp.Seek(0,SeekOrigin.Begin);

           sTemp.Write(temp, 0, w * 4 * h);

           return
robertImage;

           }

           else

           {

               returnnull;

           }  

       }

[图像效果]

Win8Metro(C#)数字图像处理--2.13Roberts边缘检测的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.14Prewitt 边缘检测

    原文:Win8Metro(C#)数字图像处理--2.14Prewitt 边缘检测  [函数名称] 图像Prewitt边缘检测函数PrewittEdgeProcess(WriteableBitmap ...

  2. Win8Metro(C#)数字图像处理--2.12Sobel边缘检测

    原文:Win8Metro(C#)数字图像处理--2.12Sobel边缘检测  [函数名称] 图像Sobel边缘检测函数SobelEdgeProcess(WriteableBitmap src) [ ...

  3. Win8Metro(C#)数字图像处理--2.33图像非线性变换

    原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换  [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...

  4. Win8Metro(C#)数字图像处理--2.34直方图规定化

    原文:Win8Metro(C#)数字图像处理--2.34直方图规定化  [函数名称] WriteableBitmap HistogramSpecificateProcess(WriteableBi ...

  5. Win8Metro(C#)数字图像处理--2.30直方图均衡化

    原文:Win8Metro(C#)数字图像处理--2.30直方图均衡化 [函数名称] 直方图均衡化函数HistogramEqualProcess(WriteableBitmap src) [算法说明] ...

  6. Win8Metro(C#)数字图像处理--2.31灰度拉伸算法

    原文:Win8Metro(C#)数字图像处理--2.31灰度拉伸算法  [函数名称] 灰度拉伸函数GrayStretchProcess(WriteableBitmap src) [算法说明]    ...

  7. Win8Metro(C#)数字图像处理--2.32图像曝光算法

    原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法  [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...

  8. Win8Metro(C#)数字图像处理--2.27图像加法运算

    原文:Win8Metro(C#)数字图像处理--2.27图像加法运算  [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...

  9. Win8Metro(C#)数字图像处理--2.28图像乘法运算

    原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算  [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...

随机推荐

  1. iOS开发系列之三 - UITextField 使用方法小结

    // 初始化输入框并设置位置和大小 UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 100, 30 ...

  2. [SVG] Add an SVG as an Embedded Background Image

    Learn how to set an elements background image to embedded SVG. This method has an added benefit of n ...

  3. Undefined symbols for architecture i386: "_OBJC_CLASS_$_KKGridView", referenced from:

    Undefined symbols for architecture i386: "_OBJC_CLASS_$_KKGridView", referenced from:

  4. 【前端统计图】echarts多条折线图和横柱状图实现

    参考链接:echarts官网:http://echarts.baidu.com/ 原型图(效果图): 图片.png 代码: <!DOCTYPE html> <html> < ...

  5. 【codeforces 776C】Molly's Chemicals

    [题目链接]:http://codeforces.com/contest/776/problem/C [题意] 让你找区间[i,j] 使得sum[i..j]=k^t,这里t=0,1,2,3.. -10 ...

  6. 利用WPF建立自己的3d gis软件(非axhost方式)(十二)SDK中的导航系统

    原文:利用WPF建立自己的3d gis软件(非axhost方式)(十二)SDK中的导航系统 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV0bPew ...

  7. Android小游戏:功夫蛇 团队开发经验总结

    前言 曾经没有代码管理的习惯,不用回版本控制工具.这种陋习虽然让原来千穿百孔的代码远离了实现,但这种逃避未必就是一件好事吧;). 于是从博客中挖出了原来的文章,并千辛万苦找到了最早的代码贴出来. 这篇 ...

  8. HDU 4847-Wow! Such Doge!(定位)

    Wow! Such Doge! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. 各个 C# 版本的主要特性、发布日期和发布方式(C# 1.0 - 7.3)

    原文 各个 C# 版本的主要特性.发布日期和发布方式(C# 1.0 - 7.3) 本文收集各个 C# 版本的主要特性.发布日期和发布方式. C# 8.0 尚在预览版本 C# 7.3 2018 年 5 ...

  10. Java高级应用(一个)-文件夹监控服务

    最近.在研究一些比较成熟的框架.他们还发现,他们中的一些相当不错的文章.现在,对于一些在你们中间一个简单的翻译(版的英文文章,非常有帮助). 译:原文链接 你有没有发现,当你编辑一个文件.同一时候使用 ...