Win8Metro(C#)数字图像处理--2.8图像线性变换
原文:Win8Metro(C#)数字图像处理--2.8图像线性变换
2.8图像线性变换
[函数名称]
图像线性变换函数LinearTransformProcess(WriteableBitmap
src, double k,int
v)
[函数代码]
///<summary>
///
Linear transform process(f=kf+v).
///</summary>
///<param
name="src">Source image.</param>
///<param
name="k">Parameter,from 0 to 5.</param>
///<param
name="v">Parameter,from -128 to 128.</param>
///<returns></returns>
publicstaticWriteableBitmap
LinearTransformProcess(WriteableBitmap src,double
k,int v)////8线性变换处理
{
if(src!=null
)
{
int
w = src.PixelWidth;
int
h = src.PixelHeight;
WriteableBitmap
linearImage =newWriteableBitmap(w,h);
byte[]
temp = src.PixelBuffer.ToArray();
for
(int i = 0; i < temp.Length; i +=4)
{
temp[i] = (byte)(((k
* temp[i] + v + 0.5) > 255 ? 255 : (k * temp[i] + v + 0.5)) < 0 ? 0 : ((k * temp[i] + v + 0.5) > 255 ? 255 : (k * temp[i] + v + 0.5)));
temp[i+1] = (byte)(((k
* temp[i+1] + v + 0.5) > 255 ? 255 : (k * temp[i+1] + v + 0.5)) < 0 ? 0 : ((k * temp[i+1] + v + 0.5) > 255 ? 255 : (k * temp[i+1] + v + 0.5)));
temp[i+2] = (byte)(((k
* temp[i+2] + v + 0.5) > 255 ? 255 : (k * temp[i+2] + v + 0.5)) < 0 ? 0 : ((k * temp[i+2] + v + 0.5) > 255 ? 255 : (k * temp[i+2] + v + 0.5)));
}
Stream
sTemp = linearImage.PixelBuffer.AsStream();
sTemp.Seek(0,SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return
linearImage;
}
else
{
returnnull;
}
}
[图像效果]
Win8Metro(C#)数字图像处理--2.8图像线性变换的更多相关文章
- 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) [函数代码] ...
随机推荐
- source insight 添加自定义macro
打开C:\Documents and Settings\xxxx\My Documents\Source Insight\Projects\Base文件夹下的em文件,可以看到都是由macro定义的一 ...
- [NPM] Run npm scripts when files change with onchange
In this lesson we will look at how we can setup our npm scripts to execute when the file system has ...
- Hierarchical Tree Traversal in Graphics Pipeline Stages
BACKGROUND Many algorithms on a graphics processing unit (GPU) may benefit from doing a query in a h ...
- Effective C++ 条款14
在资源管理器中小心copying行为 上节是对资源的管理说明.有时候我们不能依赖于shared_ptr或者auto_ptr,所以我们须要自己建立一个资源管理类来管理自己的资源. 比如建立一个类来管理M ...
- Oracle 自己主动内存參数依赖性
图例:在该图中使用了下面參数名称缩写: MT = MEMORY_TARGET MMT = MEMORY_MAX_TARGET ST = SGA_TARGET PAT = PGA_AGGREGATE_T ...
- WPF随笔(九)--使用路径动画模拟管道流体流向
原文:WPF随笔(九)--使用路径动画模拟管道流体流向 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/lordwish/article/detail ...
- tomcat 去除端口和项目名/使用域名访问/修改超链接为IP地址
1.打开tomcat/conf/server.xml 在host标签中加入 <Context docBase="项目名" path="" reloada ...
- 小强的HTML5移动开发之路(24)—— PhoneGap Android开发环境搭建
有关JDK及Android开发环境的搭建请看我前面的博文:http://blog.csdn.net/dawanganban/article/details/9748497 一.下载PhoneGap 下 ...
- WindowsService - 开发遇到的问题
1.Windows服务安装 通过cmd运行指令安装Windows服务: 安装方法:运行cmd,以InstallUtil.exe 来运行 Windows服务程序. 如果是Release模式的话,直接在c ...
- WinForm - 窗体淡入效果界面的简单实现方法
WinForm窗体淡入效果主要使用到控件的Opacity属性 首先在WinForm窗体中拖入一个Timer控件,然后再Timer控件的Tick事件添加如下代码: private void timer1 ...