Win8Metro(C#)数字图像处理--2.33图像非线性变换
生活随笔
收集整理的這篇文章主要介紹了
Win8Metro(C#)数字图像处理--2.33图像非线性变换
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原文:Win8Metro(C#)數(shù)字圖像處理--2.33圖像非線性變換
[函數(shù)名稱]
圖像非線性變換函數(shù)NonlinearTransformProcess(WriteableBitmap?src,int?k?)?
[函數(shù)代碼]/// <summary>/// Nonlinear transform process./// </summary>/// <param name="src">The source image.</param>/// <param name="k">Param to adjust nonlinear transform, from 0 to 255.</param>/// <returns></returns>public static WriteableBitmap NonlinearTransformProcess(WriteableBitmap src,int k )37{if (src != null){int w = src.PixelWidth;int h = src.PixelHeight;WriteableBitmap linearImage = new WriteableBitmap(w, h);byte[] temp = src.PixelBuffer.ToArray();int r = 0, g = 0, b = 0;for (int i = 0; i < temp.Length; i += 4){b = (int)(k * Math.Log10(1 + temp[i]));g = (int)(k * Math.Log10(1 + temp[i + 1]));r = (int)(k * Math.Log10(1 + temp[i + 2]));temp[i] = (byte)(b > 0 ? (b < 255 ? b : 255) : 0);temp[i + 1] = (byte)(g > 0 ? (g < 255 ? g : 255) : 0);temp[i + 2] = (byte)(r > 0 ? (r < 255 ? r : 255) : 0); }Stream sTemp = linearImage.PixelBuffer.AsStream();sTemp.Seek(0, SeekOrigin.Begin);sTemp.Write(temp, 0, w * 4 * h);return linearImage;}else{return null;} }
總結(jié)
以上是生活随笔為你收集整理的Win8Metro(C#)数字图像处理--2.33图像非线性变换的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SBC应用
- 下一篇: c# char unsigned_dll