原文:Win8Metro(C#)数字图像处理--2.11图像锐化



[函数名称]

图像锐化函数SharpeningProcess(WriteableBitmap
src,double sharpenValue)

[函数代码]

///<summary>

///
Sharpening process.

///</summary>

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

///<returns></returns>

publicstaticWriteableBitmap
SharpeningProcess(WriteableBitmap src)////11锐化处理

{

if(src!=null
)

{

int
w = src.PixelWidth;

int
h = src.PixelHeight;

WriteableBitmap
sharpenImage =newWriteableBitmap(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 =Math.Abs(5
* srB - tempMask[i - 4 + j * w * 4] - tempMask[i + 4 + j * w * 4] - tempMask[i + (j - 1) * w * 4] - tempMask[i + (j + 1) * w * 4]);

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

r =Math.Abs(5
* srR - tempMask[i - 4 + 2 + j * w * 4] - tempMask[i + 4 + 2 + j * w * 4] - tempMask[i + 2 + (j - 1) * 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; 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

{

returnnull;

}

}

 [图像效果]


Win8Metro(C#)数字图像处理--2.11图像锐化的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.3图像反色

    原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明]     反色公式如下: ...

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

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

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

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

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

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

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

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

  6. Win8Metro(C#)数字图像处理--2.29图像除法运算

    原文:Win8Metro(C#)数字图像处理--2.29图像除法运算  [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...

  7. Win8Metro(C#)数字图像处理--2.26图像减法

    原文:Win8Metro(C#)数字图像处理--2.26图像减法  [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...

  8. Win8Metro(C#)数字图像处理--2.19图像水平镜像

    原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像  [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码]      ...

  9. Win8Metro(C#)数字图像处理--2.20图像垂直镜像

    原文:Win8Metro(C#)数字图像处理--2.20图像垂直镜像  [函数名称] 图像垂直镜像函数MirrorYProcess(WriteableBitmap src) [函数代码]      ...

随机推荐

  1. Linux网络编程——原始套接字编程

    原始套接字编程和之前的 UDP 编程差不多,无非就是创建一个套接字后,通过这个套接字接收数据或者发送数据.区别在于,原始套接字可以自行组装数据包(伪装本地 IP,本地 MAC),可以接收本机网卡上所有 ...

  2. C# WebQQ协议群发机器人(一)

    原创性申明 本文地址 http://blog.csdn.net/zhujunxxxxx/article/details/38931287 转载的话请注明出处. 之前我也写过一篇使用python来实现的 ...

  3. 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(3)输入输出函数

    一.基本的输入和输出函数的用法 1.printf()  //屏幕输出 用法: (1)printf("字符串\n"); (2)printf("输出控制符", 输出 ...

  4. hdu 1292 &quot;下沙野骆驼&quot;ACM夏令营 (递推)

    "下沙野骆驼"ACM夏令营 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/ ...

  5. asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二)

    原文:asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二) 续上一篇文章:asp.net core2.0 部署centos7/linux系统 -- ...

  6. Linux中export导入环境变量的几种方式

    1.首先类似于windows中的设定系统环境变量的方式为,在/etc/profile中 export PATH=$PATH:....:... 注意间隔符为: 然后复用原来路径是$PATH的方式 2.用 ...

  7. java中的方法返回值使用泛型,实现灵活的返回值类型

    痛点:      使用Mybatis框架的时候,想封装一个底层JDBC控制器,用于提供和Mybatis交互的增删改查接口(公用的接口),但由于公用的查询方法可能是用户自定义的任意一个和表对应的java ...

  8. 英文构词法 —— ant、ent 后缀

    1. -ant:--人 accountant:会计, account(ac+count):计数,账户: assistant:助手: assist:帮助 descendant:后裔: descend:下 ...

  9. Android官方教程翻译(6)——添加ActionBar

    The action bar allows you to add buttons for the most important action items relating to the app's c ...

  10. 重装huson遇到的一些错误及解决

    作者:朱金灿 来源:http://blog.csdn.net/clever101 服务器换了一块新硬盘,拷贝回原来的数据后结果发现Apache tomcat服务不能启动了,错误提示是:本地计算机上的A ...