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) [函数代码] ...
随机推荐
- [Angular] Angular CLI
Create an app with routing config: ng new mynewapp --routing If you want to generate a new module wi ...
- 【a703】求逆序对(线段树的解法)
Time Limit: 10 second Memory Limit: 2 MB 问题描述 给定一个序列a1,a2...an.如果存在i小于j 并且ai大于aj,那么我们称之为逆序对,求给定序列中逆序 ...
- ie7span标签float换行悬浮
项目中,ie8以上都是好好的,就是ie7的布局有问题,span换行漂浮了 <div style="height:20px"> <span style=" ...
- 控制器管理UINavigationController、UINavigationBar
控制器管理 掌握 控制器以及view的多种创建方式 UINavigationController的简单使用:添加\移除子控制器 UINavigationBar内容的设置 控制器的生命周期方法 Segu ...
- 验证redis的快照和AOF
http://blog.csdn.net/lichangzai/article/details/8692103 redis持久化简介: redis是一个支持持久化的内存数据库,也就是说redis需要经 ...
- 【t061】游览路线
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 话说LCINF信息组来到烟台参加夏令营.一天,大家提议出去游玩,来到了烟台最繁华的地方.由于他们对烟台 ...
- sparksql parquet 分区推断Partition Discovery
网上找的大部分资料都很旧,最后翻了下文档只找到了说明 大概意思是1.6之后如果想要使用分区推断就要设置数据源的basePath,因此代码如下 java public class ParitionInf ...
- 高性能分布式应用开发中间件ICE介绍
作为一个技术人员,你是否在为不断增长的数据量和日益复杂的业务逻辑而头疼不已,杂乱堆砌在一起的庞大业务让系统越来越脆弱,于是你想到了网格,想到了利用分布式来重组一个健壮的系统架构. 随后,RMI,EJB ...
- 【23.33%】【hdu 5945】Fxx and game
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s ...
- Redmine迁移至华为软件开发云-项目管理
一.方案概述 要想将Redmine中某个项目的数据导入到华为软件开发云(以下简称开发云),如果说是按照Redmine中的数据一条一条的在开发云中新建出来,肯定不是一个明智的方案,下面就是给大家介绍一个 ...