博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Win8 Metro(C#)数字图像处理--2.46图像RGB分量增强效果
阅读量:6938 次
发布时间:2019-06-27

本文共 1796 字,大约阅读时间需要 5 分钟。

原文:



[函数名称]

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

[算法说明]

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

[函数代码]

///         /// R,G,B value adjusting.        ///         /// The source image.        /// To judge which one to adjust, R is 3, G is 2, B is 1.        /// It is a value to adjust the result image.        /// 
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; } }
你可能感兴趣的文章
leetcode 349. Intersection of Two Arrays
查看>>
深研TCP/IP详解卷1开篇
查看>>
apollo实现c#与android消息推送(一)
查看>>
hbase自定义比较器
查看>>
接口与抽象类的区别?区别就是抽象类已经(渐渐地渐渐地)不用了.
查看>>
23种设计模式-享元模式
查看>>
5.29
查看>>
[BZOJ1597]土地购买
查看>>
Python目录常用操作
查看>>
Qt笔记——Event
查看>>
leetcode------Merge Two Sorted Lists
查看>>
leetcode------Binary Tree Preorder Traversal
查看>>
js文档碎片
查看>>
poj2823-Sliding Window
查看>>
LeetCode(7): Majority Element
查看>>
一个完整的大作业
查看>>
软考之操作系统
查看>>
【C015】Python数据类型 - 序列
查看>>
简单之美-软件开发实践者的思考 02
查看>>
关于QueryCache的一次打脸
查看>>