原文:Win8Metro(C#)数字图像处理--2.16图像浮雕效果



[函数名称]

图像浮雕效果函数ReliefProcess(WriteableBitmap
src)

[函数代码]

       ///<summary>

       ///
Relief process.

       ///</summary>

       ///<param
name="src">The source image.</param>

       ///<param
name="reliefValue">A value to adjust the relief processing, from 0 to 255.</param>

       ///<returns></returns>

       publicstaticWriteableBitmap
ReliefProcess(WriteableBitmap src,int
reliefValue)////16浮雕处理

       {

           if(src!=null
)

           {

           int
w = src.PixelWidth;

           int
h = src.PixelHeight;

           WriteableBitmap
reliefImage =newWriteableBitmap(w,h);

           byte[]
temp = src.PixelBuffer.ToArray();

           byte[]
tempMask = (byte[])temp.Clone();

           int
b = 0, g = 0, r = 0;

           for
(int j = 1; j < h - 1; j++)

           {

               for
(int i = 4; i < w * 4 - 4; i += 4)

               {

                   b =Math.Abs(tempMask[i
+ j * w * 4] - tempMask[i + 4 + j * w * 4] + reliefValue);

                   g =Math.Abs(tempMask[i
+ 1 + j * w * 4] - tempMask[i + 1 + 4 + j * w * 4] + reliefValue);

                   r =Math.Abs(tempMask[i
+ 2 + j * w * 4] - tempMask[i + 2 + 4 + j * w * 4] + reliefValue);

                 temp[i + j * w * 4] = (byte)(b
> 0 ? (b < 255 ? b : 255) : 0);

                 temp[i + 1 + j * w * 4] = (byte)(g
> 0 ? (g < 255 ? g : 255) : 0);

                 temp[i + 2 + j * w * 4] = (byte)(r
> 0 ? (r < 255 ? r : 255) : 0);

                 b = 0; g = 0; r = 0;

               }

           }

           Stream
sTemp = reliefImage.PixelBuffer.AsStream();

           sTemp.Seek(0,SeekOrigin.Begin);

           sTemp.Write(temp, 0, w * 4 * h);

           return
reliefImage;

           }

           else

           {

               returnnull;

           }  

       }

 [图像效果]

Win8Metro(C#)数字图像处理--2.16图像浮雕效果的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.3图像反色

    原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明]     反色公式如下: ...

  2. Win8Metro(C#)数字图像处理--2.33图像非线性变换

    原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换  [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...

  3. Win8Metro(C#)数字图像处理--2.32图像曝光算法

    原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法  [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...

  4. Win8Metro(C#)数字图像处理--2.27图像加法运算

    原文:Win8Metro(C#)数字图像处理--2.27图像加法运算  [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...

  5. Win8Metro(C#)数字图像处理--2.28图像乘法运算

    原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算  [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...

  6. Win8Metro(C#)数字图像处理--2.29图像除法运算

    原文:Win8Metro(C#)数字图像处理--2.29图像除法运算  [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...

  7. Win8Metro(C#)数字图像处理--2.26图像减法

    原文:Win8Metro(C#)数字图像处理--2.26图像减法  [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...

  8. Win8Metro(C#)数字图像处理--2.19图像水平镜像

    原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像  [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码]      ...

  9. Win8Metro(C#)数字图像处理--2.20图像垂直镜像

    原文:Win8Metro(C#)数字图像处理--2.20图像垂直镜像  [函数名称] 图像垂直镜像函数MirrorYProcess(WriteableBitmap src) [函数代码]      ...

随机推荐

  1. 使用JSONP解决跨域问题-代码示例

    前段时间用JSONP解决了跨域问题,现在不用了,把代码思路记下来,今后说不定还用得上. JS代码 //查询公告数据 function recentpost(){ $.getJSON(cmsUrl+&q ...

  2. [Ramda] R.project -- Select a Subset of Properties from a Collection of Objects in Ramda

    In this lesson we'll take an array of objects and map it to a new array where each object is a subse ...

  3. Android学习Scroller(三)——控件平移划过屏幕 (Scroller简单使用)

    MainActivity例如以下: package cc.cn; import android.os.Bundle; import android.view.View; import android. ...

  4. 解析字典包含关键字比如ID,description等,MJExtension 框架 不能直接设置变量与其同名。

    @property (nonatomic,strong) NSString *descrip;  //设置变量名 _DataReceived=(NSMutableArray *)[HZnewsmess ...

  5. 复杂json解析(json里面嵌套json)

    调用第三方接口,返回一堆json,我只想取得里面的某一个属性,但是返回的比较复杂,无法直接拿到属性,格式类似于这样: {"video":{"id":" ...

  6. 利用WPF建立自己的3d gis软件(非axhost方式)(十)SDK中一些自带的展示面板应用

    原文:利用WPF建立自己的3d gis软件(非axhost方式)(十)SDK中一些自带的展示面板应用 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV ...

  7. WPF 开发自动开机启动程序

    原文:WPF 开发自动开机启动程序 本文告诉大家如何在 WPF 开发一个可以自动启动的程序 本文使用的自动开机启动方法是通过快捷方式放在启动文件夹的方式. 创建快捷方式 /// <summary ...

  8. base64编码转图片

    protected void Button1_Click(object sender, EventArgs e) { //strImg为base64编码的图片字符串 string strImg = & ...

  9. layer的使用笔记

    $('#calendar').fullCalendar({ lang:"zh-cn", buttonText:{ today: '今天' }, eventLimit: true, ...

  10. Information Centric Networking Based Service Centric Networking

    A method implemented by a network device residing in a service domain, wherein the network device co ...