Win8Metro(C#)数字图像处理--2.18图像平移变换
[函数名称]
图像平移变换函数TranslationProcess(WriteableBitmap src,int x,int y)
[函数代码]
///<summary>
/// Translation process.
///</summary>
///<param name="src">Source image.</param>
///<param name="x">Translate value of x.</param>
///<param name="y">Translate value of y.</param>
///<returns></returns>
publicstaticWriteableBitmap TranslationProcess(WriteableBitmap src,int x,int y)18平移变换
{
if(src!=null )
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap translateImage =newWriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
byte[] tempMask =newbyte[w * h * 4];
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i ++)
{
if (i + x < 0 || i + x >= w || j + y < 0 || j + y >= h)
{
tempMask[i * 4 + j * w * 4] = (byte)0;
tempMask[i * 4 + 1 + j * w * 4] = (byte)0;
tempMask[i * 4 + 2 + j * w * 4] = (byte)0;
}
else
{
tempMask[i * 4 + j * w * 4] = (byte)(temp[(i + x) * 4 + (j + y) * w * 4]);
tempMask[i * 4 + 1 + j * w * 4] = (byte)(temp[(i + x) * 4 + 1 + (j + y) * w * 4]);
tempMask[i * 4 + 2 + j * w * 4] = (byte)(temp[(i + x) * 4 + 2 + (j + y) * w * 4]);
tempMask[i * 4 + 3 + j * w * 4] = (byte)(temp[(i + x) * 4 + 3 + (j + y) * w * 4]);
}
}
}
Stream sTemp = translateImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(tempMask, 0, w * 4 * h);
return translateImage;
}
else
{
returnnull;
}
}
[图像效果]
Win8Metro(C#)数字图像处理--2.18图像平移变换相关推荐
- Win8Metro(C#)数字图像处理--2.3图像反色
原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明] 反色公式如下: ...
- Win8Metro(C#)数字图像处理--2.7图像伪彩色
Win8Metro(C#)数字图像处理--2.7图像伪彩色 原文:Win8Metro(C#)数字图像处理--2.7图像伪彩色 2.7图像伪彩色函数 [函数名称] 图像伪彩色函数PseudoCol ...
- Win8Metro(C#)数字图像处理--2.33图像非线性变换
原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换 [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...
- Win8Metro(C#)数字图像处理--2.26图像减法
[函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBitmap subSrc) [算法说明] 图像减法就是将两幅图像对应 ...
- C语言数字图像处理进阶---18 图像形变滤镜
图像形变滤镜 图像形变滤镜代表的是一类滤镜,这类滤镜的特点就是像素位置发生了形变,通过位置形变来达到某种特效,比如哈哈镜,鱼眼镜头特效等等. 本文给大家介绍四款形变滤镜:波浪形变滤镜(WaveFilt ...
- Win8Metro(C#)数字图像处理--2.32图像曝光算法
[函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureValue) [函数代码] /// <summary> // ...
- Win8Metro(C#)数字图像处理--2.17图像木刻效果
[函数名称] 图像木刻效果函数WoodCutProcess(WriteableBitmap src) [函数代码] ///<summary> /// Wood cut process ...
- Win8Metro(C#)数字图像处理--2.14Prewitt 边缘检测
原文:Win8Metro(C#)数字图像处理--2.14Prewitt 边缘检测 [函数名称] 图像Prewitt边缘检测函数PrewittEdgeProcess(WriteableBitmap ...
- Win8Metro(C#)数字图像处理--2.24二值图像闭运算
原文:Win8Metro(C#)数字图像处理--2.24二值图像闭运算 [函数名称] 二值图像闭运算函数CloseOperateProcess(WriteableBitmap src) [算法说 ...
最新文章
- python 读取grib \grib2
- python3 函数签名简介 验证函数参数
- 差分能量分析介绍(四)
- 理解MySQL——复制(Replication)
- 即时通讯音视频开发(八):常见的实时语音通讯编码标准
- ITK:创建派生内核DerivativeKernel
- [leetcode]160.相交链表
- 如何使用命令行拿到SAP Kyma的Lambda Function明细
- 大话领域驱动设计——简介
- hibernate正向生成数据库表以及配置——Teacher.java
- Hadoop64位版本安装后遇到的警告处理
- 阿里女员工遭遇「杀猪盘」背后的思考
- Exchange日常管理之四:简化OWA的登录
- Linux设备开机卡主
- 小甲鱼python笔记_小甲鱼Python笔记(类)
- No package python27 available
- Win7电脑蓝屏代码大全
- 飞机大战(源码+素材)
- 计算机网络的高可用性和分布式处理
- 技术经理成长复盘-我是什么样的人