Win8 Metro(C#)数字图像处理--2.46图像RGB分量增强效果
2024-10-02 01:52:11
原文: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;
}
}
最新文章
- 如何围绕企业战略,建设BI驾驶舱?
- http
- Linux下数据恢复软件extundelete
- web app响应式字体设置!rem之我见
- 洛谷P3379 【模板】最近公共祖先(LCA)
- MySQL Workbench返回所有的记录
- chrome shortcutkey
- Microsoft Language and Locale Codes(微软语言和地区代码汇总)
- Android:使用ViewPager实现左右滑动切换图片(图上有点点)
- <;string>; <;string.h>;
- UIActivityIndicatorView-初识IOS
- 使用fragment,Pad手机共用一套代码
- nopcommerce插件使用
- Jedis使用示例
- 刨根究底字符编码之五——简体汉字编码方案(GB2312、GBK、GB18030、GB13000)以及全角、半角、CJK
- JavaScript 系列博客(六)
- ELK 环境搭建1-Elasticsearch
- jupyter notebook不能选择虚拟环境的解决方法
- 管理菜单 结贴回复 来自 202.112.36.253 的回复: TTL 传输中过期
- android精品开源项目整理