原文:Win8 Metro(C#)数字图像处理--2.46图像RGB分量增强效果



[函数名称]

RGB分量调整         RGBAdjustProcess(WriteableBitmap src, int value,int threshould)

[算法说明]

  RGB分量调整实际上是分别对每个像素的RGB三个分量进行调整,公式如下:

[函数代码]

        /// <summary>
/// R,G,B value adjusting.
/// </summary>
/// <param name="src">The source image.</param>
/// <param name="value">To judge which one to adjust, R is 3, G is 2, B is 1.</param>
/// <param name="threshould">It is a value to adjust the result image.</param>
/// <returns></returns>
public static WriteableBitmap RGBAdjustProcess(WriteableBitmap src, int value,int threshould)////41 RGB分量调整
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap srcImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
if (value == 1)
{
for (int i = 0; i < temp.Length; i += 4)
{
temp[i] = (byte)(Math.Max(0, Math.Min((temp[i] + threshould), 255)));
}
}
if (value == 2)
{
for (int i = 0; i < temp.Length; i += 4)
{
temp[i + 1] = (byte)(Math.Max(0, Math.Min((temp[i + 1] + threshould), 255)));
}
}
if (value == 3)
{
for (int i = 0; i < temp.Length; i += 4)
{
temp[i + 2] = (byte)(Math.Max(0, Math.Min((temp[i + 2] + threshould), 255)));
}
}
Stream sTemp = srcImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return srcImage;
}
else
{
return null;
}
}

最新文章

  1. 如何围绕企业战略,建设BI驾驶舱?
  2. http
  3. Linux下数据恢复软件extundelete
  4. web app响应式字体设置!rem之我见
  5. 洛谷P3379 【模板】最近公共祖先(LCA)
  6. MySQL Workbench返回所有的记录
  7. chrome shortcutkey
  8. Microsoft Language and Locale Codes(微软语言和地区代码汇总)
  9. Android:使用ViewPager实现左右滑动切换图片(图上有点点)
  10. &lt;string&gt; &lt;string.h&gt;
  11. UIActivityIndicatorView-初识IOS
  12. 使用fragment,Pad手机共用一套代码
  13. nopcommerce插件使用
  14. Jedis使用示例
  15. 刨根究底字符编码之五——简体汉字编码方案(GB2312、GBK、GB18030、GB13000)以及全角、半角、CJK
  16. JavaScript 系列博客(六)
  17. ELK 环境搭建1-Elasticsearch
  18. jupyter notebook不能选择虚拟环境的解决方法
  19. 管理菜单 结贴回复 来自 202.112.36.253 的回复: TTL 传输中过期
  20. android精品开源项目整理

热门文章

  1. mui列表跳转到详情页优化方案
  2. wait()、notify()、notifyAll()与线程通信方式总结
  3. 小强的HTML5移动开发之路(30)—— JavaScript回顾5
  4. [搜索]Trie树的实现
  5. NOIP模拟 - 树
  6. radio选择事件 onchange事件 onclick事件
  7. java 保存和读取本地json文件
  8. Vue.JS学习基础
  9. WPF动态加载3D 放大-旋转-平移
  10. CUDA中block和thread的合理划分配置