原文:Win8 Metro(C#)数字图像处理--2.37Wallis图象锐化



[函数名称]

Wallis图象锐化        WallisSharpen(WriteableBitmap src)

[算法说明]

 Wallis锐化算法是在拉普拉斯算子的基础上,考虑人的视觉特性中包含一个对数环节,因此在锐化时,采用对数处理的方法进行改进,公式如下:

<strong><span style="font-size:14px;">[函数代码]</span></strong>
/// <summary>
/// Wallis sharpen process.
/// </summary>
/// <param name="src">The source image.</param>
/// <returns></returns>
public static WriteableBitmap WallisSharpen(WriteableBitmap src)////37Wallis锐化函数
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap sharpenImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
byte[] tempMask = (byte[])temp.Clone();
double b = 0, g = 0, r = 0, srR = 0, srG = 0, srB = 0;
for (int j = 1; j < h - 1; j++)
{
for (int i = 4; i < w * 4 - 4; i += 4)
{ srB = tempMask[i + j * w * 4];
srG = tempMask[i + 1 + j * w * 4];
srR = tempMask[i + 2 + j * w * 4];
b = 46*Math.Abs(5 * Math .Log(srB+1) - Math .Log(tempMask[i - 4 + j * w * 4]+1) - Math .Log(tempMask[i + 4 + j * w * 4]+1) - Math .Log(tempMask[i + (j - 1) * w * 4]+1) - Math .Log(tempMask[i + (j + 1) * w * 4]+1));
g = 46*Math.Abs(5 * Math .Log(srG+1) - Math .Log(tempMask[i - 4 + 1 + j * w * 4]+1) - Math .Log(tempMask[i + 4 + 1 + j * w * 4]+1) - Math .Log(tempMask[i + 1 + (j - 1) * w * 4]+1) - Math .Log(tempMask[i + 1 + (j + 1) * w * 4]+1));
r = 46*Math.Abs(5 * Math .Log(srR+1) - Math .Log(tempMask[i - 4 + 2 + j * w * 4]+1) - Math .Log(tempMask[i + 4 + 2 + j * w * 4]+1) - Math .Log(tempMask[i + 2 + (j - 1) * w * 4]+1) - Math .Log(tempMask[i + 2 + (j + 1) * w * 4]+1));
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; srR = 0; srG = 0; srB = 0;
}
}
Stream sTemp = sharpenImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return sharpenImage;
}
else
{
return null;
}
}
<strong><span style="font-size:14px;">[图象效果]</span></strong>


Win8 Metro(C#)数字图像处理--2.37Wallis图象锐化的更多相关文章

  1. Win8 Metro(C#)数字图像处理--2.75灰度图像的形态学算法

    原文:Win8 Metro(C#)数字图像处理--2.75灰度图像的形态学算法 前面章节中介绍了二值图像的形态学算法,这里讲一下灰度图的形态学算法,主要是公式,代码略. 1,膨胀算法 2,腐蚀算法 3 ...

  2. Win8 Metro(C#)数字图像处理--4图像颜色空间描述

    原文:Win8 Metro(C#)数字图像处理--4图像颜色空间描述  图像颜色空间是图像颜色集合的数学表示,本小节将针对几种常见颜色空间做个简单介绍. /// <summary> / ...

  3. Win8 Metro(C#)数字图像处理--3.2图像方差计算

    原文:Win8 Metro(C#)数字图像处理--3.2图像方差计算 /// <summary> /// /// </summary>Variance computing. / ...

  4. Win8 Metro(C#)数字图像处理--3.3图像直方图计算

    原文:Win8 Metro(C#)数字图像处理--3.3图像直方图计算 /// <summary> /// Get the array of histrgram. /// </sum ...

  5. Win8 Metro(C#)数字图像处理--3.4图像信息熵计算

    原文:Win8 Metro(C#)数字图像处理--3.4图像信息熵计算 [函数代码] /// <summary> /// Entropy of one image. /// </su ...

  6. Win8 Metro(C#)数字图像处理--3.5图像形心计算

    原文:Win8 Metro(C#)数字图像处理--3.5图像形心计算 /// <summary> /// Get the center of the object in an image. ...

  7. Win8 Metro(C#)数字图像处理--2.73一种背景图像融合特效

    原文:Win8 Metro(C#)数字图像处理--2.73一种背景图像融合特效 /// <summary> /// Image merge process. /// </summar ...

  8. Win8 Metro(C#)数字图像处理--3.1图像均值计算

    原文:Win8 Metro(C#)数字图像处理--3.1图像均值计算 /// <summary> /// Mean value computing. /// </summary> ...

  9. Win8 Metro(C#)数字图像处理--2.74图像凸包计算

    原文:Win8 Metro(C#)数字图像处理--2.74图像凸包计算 /// <summary> /// Convex Hull compute. /// </summary> ...

随机推荐

  1. [Angular] Scrolling the Message List To the Bottom Automatically Using OnChanges

    Let's say the message list can Input (messages) from parent component, and what we want to do is whe ...

  2. Java环境搭建若干问题

    0.总体说明   本次搭建环境,为了偷懒,使用的是,阿里云镜像.   自带了Nginx.Tomcat.JDK等.   比较坑爹的是,虽然镜像带了很多安装好的软件,但是也有各种问题,比如它修改了tomc ...

  3. 【codeforces 758B】Blown Garland

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. erlang数字转字符串

    http://fengmm521.blog.163.com/blog/static/2509135820147922355273/ 如果有一个数字,你想要转换成字符串这个在Erlang中是怎么操作的, ...

  5. SignalR+NAudio实现语音会话[WPF]

    原文:SignalR+NAudio实现语音会话[WPF] 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/lordwish/article/detai ...

  6. Linux中vim编辑器莫名下方出现H的问题

    在使用vim编辑文件的时候,不知道自己是按了哪个快捷键,导致了,每次编辑文件时,下方命令行出现数字+H的格式命令,使得整个文件没法编辑,强制退出后进入不能解决问题,各种文件的编辑都不行,找不出原因,最 ...

  7. 选择性编译代码:如 #ifdef __IPHONE_7_0

    选择性编译代码: 选择性编译代码和选择性运行代码是不一样的,区别在于: 1.选择性编译代码是在硬件或者系统不支持的情况下不会对该段代码进行编译,也就不会由于不兼容的问题导致报错 #import < ...

  8. 【codeforces 776D】The Door Problem

    [题目链接]:http://codeforces.com/contest/776/problem/D [题意] 每个门严格由两个开关控制; 按一下开关,这个开关所控制的门都会改变状态; 问你能不能使所 ...

  9. 【18.40%】【codeforces 631D】Messenger

    time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...

  10. wpf DoEvents

    原文:wpf DoEvents 如果在执行一段卡UI的代码,这时如何让UI响应.如果存在代码需要获得依赖属性,那么代码就需要在UI线程执行,但是这时就会卡UI,为了让UI响应,所以就需要使用DoEve ...