Win8Metro(C#)数字图像处理--2.6图像对比度调整
原文:Win8Metro(C#)数字图像处理--2.6图像对比度调整
2.6图像对比度调整函数
[函数名称]
图像对比度调整函数ContrastAdjustProcess(WriteableBitmap
src, doublecontrastValue)
[函数代码]
///<summary>
///
Contrast adjust process.
///</summary>
///<param
name="src">Source image.</param>
///<param
name="contrastValue">Contrast value, from -1 to 1.</param>
///<returns></returns>
publicstaticWriteableBitmap
ContrastAdjustProcess(WriteableBitmap src,double
contrastValue)////6对比度调整
{
if(src!=null
)
{
int
w = src.PixelWidth;
int
h = src.PixelHeight;
WriteableBitmap
contrastImage =newWriteableBitmap(w,h);
byte[]
temp = src.PixelBuffer.ToArray();
for
(int i = 0; i < temp.Length; i += 4)
{
temp[i] =Convert.ToByte((((temp[i]
- 127.5) * contrastValue + temp[i]) > 255 ? 255 : ((temp[i] - 127.5) * contrastValue + temp[i])) < 0 ? 0 : (((temp[i] - 127.5) * contrastValue + temp[i]) > 255 ? 255 : ((temp[i] - 127.5) * contrastValue + temp[i])));
temp[i + 1] =Convert.ToByte((((temp[i
+ 1] - 127.5) * contrastValue + temp[i + 1]) > 255 ? 255 : ((temp[i + 1] - 127.5) * contrastValue + temp[i + 1])) < 0 ? 0 : (((temp[i + 1] - 127.5) * contrastValue + temp[i + 1]) > 255 ? 255 : ((temp[i + 1] - 127.5) * contrastValue + temp[i + 1])));
temp[i + 2] =Convert.ToByte((((temp[i
+ 2] - 127.5) * contrastValue + temp[i + 2]) > 255 ? 255 : ((temp[i + 2] - 127.5) * contrastValue + temp[i + 2])) < 0 ? 0 : (((temp[i + 2] - 127.5) * contrastValue + temp[i + 2]) > 255 ? 255 : ((temp[i + 2] - 127.5) * contrastValue + temp[i + 2])));
}
Stream
sTemp = contrastImage.PixelBuffer.AsStream();
sTemp.Seek(0,SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return
contrastImage;
}
else
{
returnnull;
}
}
Win8Metro(C#)数字图像处理--2.6图像对比度调整的更多相关文章
- Win8Metro(C#)数字图像处理--2.3图像反色
原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明] 反色公式如下: ...
- Win8Metro(C#)数字图像处理--2.33图像非线性变换
原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换 [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...
- Win8Metro(C#)数字图像处理--2.32图像曝光算法
原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法 [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...
- Win8Metro(C#)数字图像处理--2.27图像加法运算
原文:Win8Metro(C#)数字图像处理--2.27图像加法运算 [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...
- Win8Metro(C#)数字图像处理--2.28图像乘法运算
原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算 [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...
- Win8Metro(C#)数字图像处理--2.29图像除法运算
原文:Win8Metro(C#)数字图像处理--2.29图像除法运算 [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...
- Win8Metro(C#)数字图像处理--2.26图像减法
原文:Win8Metro(C#)数字图像处理--2.26图像减法 [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...
- Win8Metro(C#)数字图像处理--2.19图像水平镜像
原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像 [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码] ...
- Win8Metro(C#)数字图像处理--2.20图像垂直镜像
原文:Win8Metro(C#)数字图像处理--2.20图像垂直镜像 [函数名称] 图像垂直镜像函数MirrorYProcess(WriteableBitmap src) [函数代码] ...
随机推荐
- winfrom RichTextBox每行字体的颜色
public static void AppendTextColorful(this RichTextBox rtBox, string text, Color color, bool addNewL ...
- [NPM] Create a node script to replace a complex npm script
In this lesson we will look at pulling out complex npm script logic into an external JavaScript file ...
- Android自定义控件View(三)组合控件
不少人应该见过小米手机系统音量控制UI,一个圆形带动画效果的音量加减UI,效果很好看.它是怎么实现的呢?这篇博客来揭开它的神秘面纱.先上效果图 相信很多人都知道Android自定义控件的三种方式,An ...
- Thrift写RPC接口
Thrift总结(二)创建RPC服务 前面介绍了thrift 基础的东西,怎么写thrift 语法规范编写脚本,如何生成相关的语言的接口.不清楚的可以看这个<Thrift总结(一)介绍>. ...
- [Clojure] A Room-Escape game, playing with telnet and pure-text commands - Part 3
Code Path: https://github.com/bluesilence/Lisp/blob/master/clojure/projects/room-escape/src/room_esc ...
- drawText文字绘制知识
drawText(String text, float x, float y, Paint paint) x,y是基于文字基本线的,而不是android坐标系的左上角. 使用staticLayout进 ...
- CodeBlocks环境搭建及创建第一个C++程序
某业界大牛推荐最佳的途径是从raytracing入门,所以本屌开始学习<Ray Tracing In One Weekend>. 该书是基于C++的.本屌从未学过C++.感觉告诉我,要先搭 ...
- 神经网络的 Delta 学习规则(learning rule)
1. δ 学习规则 1986 年,由认知心理学家 McClelland 和 Rumellhart 在神经网络训练中引入了 Δ 学习规则,该规则亦可称为连续感知器学习规则(与离散感知器学习规则相并行). ...
- Swift过程控制和功能
流量控制(Control Flow) For周期 for骑自行车和C语言,OC用法很相似,平时for()和 for in两种. 遍历可以使用下划线"_"略对值的訪问等. Switc ...
- Project Euler:Problem 28 Number spiral diagonals
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is forme ...