Win8Metro(C#)数字图像处理--2.22二值图像膨胀
原文:Win8Metro(C#)数字图像处理--2.22二值图像膨胀
[函数名称]
二值图像膨胀函数DilationProcess(WriteableBitmap
src)
[算法说明]
膨胀算法也是属于形态学算法的范畴,前一节已经简单介绍了形态学,这里不再累赘。
我们这里介绍的膨胀算法依旧采用上一节腐蚀中的结构元素S,则算法过程如下:
用通俗的话讲就是,用结构元素作为模板在原始二值图像种平滑一遍,扫描图像的每一个像素,用结构元素中的每一个元素与其覆盖的二值图像做“或”操作(假设结构元素都为1),如果结果为1,则二值图像中对应结构元素原点位置的像素值为1,否则为0。
[函数代码]
///<summary>
///
Dilation process.
///</summary>
///<param
name="src">The source image(It should be the binary image).</param>
///<returns></returns>
publicstaticWriteableBitmap
DilationProcess(WriteableBitmap src)////22图像膨胀运算
{
if
(src !=null)
{
int
w = src.PixelWidth;
int
h = src.PixelHeight;
WriteableBitmap
dilationImage =newWriteableBitmap(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;
}
}
}
}
Stream
sTemp = dilationImage.PixelBuffer.AsStream();
sTemp.Seek(0,
SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return
dilationImage;
}
else
{
returnnull;
}
}
[图像效果]
Win8Metro(C#)数字图像处理--2.22二值图像膨胀的更多相关文章
- Win8Metro(C#)数字图像处理--2.24二值图像闭运算
原文:Win8Metro(C#)数字图像处理--2.24二值图像闭运算 [函数名称] 二值图像闭运算函数CloseOperateProcess(WriteableBitmap src) [算法说 ...
- Win8Metro(C#)数字图像处理--2.23二值图像开运算
原文:Win8Metro(C#)数字图像处理--2.23二值图像开运算 [函数名称] 二值图像开运算函数OpenOperateProcess(WriteableBitmap src) [算法说明 ...
- Win8Metro(C#)数字图像处理--2.21二值图像腐蚀
原文:Win8Metro(C#)数字图像处理--2.21二值图像腐蚀 [函数名称] 二值图像腐蚀函数CorrosionProcess(WriteableBitmap src) [算法说明] 二值 ...
- Win8Metro(C#)数字图像处理--2.25二值图像距离变换
原文:Win8Metro(C#)数字图像处理--2.25二值图像距离变换 [函数名称] 二值图像距离变换函数DistanceTransformProcess(WriteableBitmap sr ...
- Win8Metro(C#)数字图像处理--2.40二值图像轮廓提取
http://dongtingyueh.blog.163.com/blog/static/4619453201271481335630/ [函数名称] 二值图像轮廓提取 Contour ...
- Win8Metro(C#)数字图像处理--2.33图像非线性变换
原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换 [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...
- Win8Metro(C#)数字图像处理--2.34直方图规定化
原文:Win8Metro(C#)数字图像处理--2.34直方图规定化 [函数名称] WriteableBitmap HistogramSpecificateProcess(WriteableBi ...
- Win8Metro(C#)数字图像处理--2.30直方图均衡化
原文:Win8Metro(C#)数字图像处理--2.30直方图均衡化 [函数名称] 直方图均衡化函数HistogramEqualProcess(WriteableBitmap src) [算法说明] ...
- Win8Metro(C#)数字图像处理--2.31灰度拉伸算法
原文:Win8Metro(C#)数字图像处理--2.31灰度拉伸算法 [函数名称] 灰度拉伸函数GrayStretchProcess(WriteableBitmap src) [算法说明] ...
随机推荐
- Cocos2D-html5 公布游戏js编译为jsc
搞了老半天.这么回事啊.工具都在tools中. jsb模式下是通过打包spidermonkey来执行JS代码的. JS文件都在assets目录中.我们都知道assets目录.打包后的结果,将apk包解 ...
- 删除vector中的重复数据(unique)
#include <iostream> #include <vector> #include <algorithm> #include <assert.h&g ...
- iOS开发系列之三 - UITextField 使用方法小结
// 初始化输入框并设置位置和大小 UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 100, 30 ...
- 20+ 个很有用的 jQuery 的 Google 地图插件 (英语)
20+ 个很有用的 jQuery 的 Google 地图插件 (英语) 一.总结 一句话总结:英语提上来我才能快速去google上面找资源啊.google上面的资源要比百度丰富很多,然后有了英语就可以 ...
- zookeeper 客户端操作
代码 /** * 创建zk客户端 * 实现循环监听的两个必要条件:1.程序不能结束2.递归调用监听器 * @author tele * */ public class Demo { ; //多个节点用 ...
- 【codeforces 534C】Polycarpus' Dice
[题目链接]:http://codeforces.com/contest/534/problem/C [题意] 给你n个奇怪的骰子,第i个骰子有di个面; 然后给你n个骰子的点数之和; 问你每一个骰子 ...
- 单核、多线程与时间片,以Node.js为例
去年写了篇文章<线程与进程的理解>,当时认为线程和CPU的单核多核无关,操作系统可以有很多个线程.但今天看<深入浅出Node.js>一书时,多次提到单线程无法利用多核CPU一类 ...
- Android获取Context(任意位置任意地方,全局上下文)
一般获取context的方法 1.Activity.this的context (一般用法)返回当前activity的上下文,属于activity ,activity 摧毁他就摧毁 2.getAppli ...
- Clustered filesystem with membership version support
A computer system with read/write access to storage devices creates a snapshot of a data volume at a ...
- Alien Widgets加速了绘制、减少了闪烁。但通过设置,还可以使用Native Widget
QWidget::createWindowContainer和QWindow::setParentNative Widgets vs Alien Widgets http://doc.qt.io/qt ...