原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换



[函数名称]

图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src,int k ) 

[函数代码]
/// <summary>
/// Nonlinear transform process.
/// </summary>
/// <param name="src">The source image.</param>
/// <param name="k">Param to adjust nonlinear transform, from 0 to 255.</param>
/// <returns></returns>
public static WriteableBitmap NonlinearTransformProcess(WriteableBitmap src,int k )////37
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap linearImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
int r = 0, g = 0, b = 0;
for (int i = 0; i < temp.Length; i += 4)
{
b = (int)(k * Math.Log10(1 + temp[i]));
g = (int)(k * Math.Log10(1 + temp[i + 1]));
r = (int)(k * Math.Log10(1 + temp[i + 2]));
temp[i] = (byte)(b > 0 ? (b < 255 ? b : 255) : 0);
temp[i + 1] = (byte)(g > 0 ? (g < 255 ? g : 255) : 0);
temp[i + 2] = (byte)(r > 0 ? (r < 255 ? r : 255) : 0);
}
Stream sTemp = linearImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return linearImage;
}
else
{
return null;
}
}


最新文章

  1. 使用Ant部署应用程序系统
  2. centos 关闭不使用的服务
  3. rails bug
  4. 通过eclipse的DDMS连接bluestacks找不到设备的解决方法
  5. bzoj1632 [Usaco2007 Feb]Lilypad Pond
  6. 找呀志_通过开源框架引AsyncHttpClient上传文件
  7. python学习===判断两个日期的间距天数
  8. 长话短说 之 js的原型和闭包
  9. RDC去省赛玩前の日常训练 Chapter 1
  10. 连接慢的主要原因是DNS解析导致
  11. sqlloader 往数据库导数据提示数据文件的字段超出最大长度
  12. 快速入门node.js
  13. GDOI2018 滑稽子图 [斯特林数,树形DP]
  14. 解决 main(int argc, char** argv)这种情况下通过命令行传参,改为main函数里面给定参数。
  15. Git 安装 windows &amp;&amp; linux
  16. elk平台定制化查询规则
  17. Sklearn实现逻辑回归
  18. c# 终止线程
  19. [Objective-C语言教程]类和对象(24)
  20. http状态码汇总及问题经验总结

热门文章

  1. [tmux] Organize your terminal using tmux panes
  2. 百度echarts可以做什么
  3. SpringMVC3,使用RequestMappint的Param参数,实现一个url绑定多个方法
  4. UiwebView and html
  5. jsp页面遍历List&lt;Map&lt;String,Object&gt;&gt;
  6. java-线程-基础
  7. Enhancing network controls in mandatory access control computing environments
  8. 左右RAC CRS 自己主动启动
  9. Android 事件分发机制具体解释
  10. Android 测试 Appium、Robotium、monkey而其他的框架或工具控制