Win8Metro(C#)数字图像处理--2.34直方图规定化
原文:Win8Metro(C#)数字图像处理--2.34直方图规定化
[函数名称]
WriteableBitmap HistogramSpecificateProcess(WriteableBitmap src, WriteableBitmap dst)
[算法说明]
[函数代码]
/// <summary>
/// Histogram specification process.
/// </summary>
/// <param name="src">The source image.</param>
/// <param name="dst">The image to get histogram to use.</param>
/// <returns></returns>
public static WriteableBitmap HistogramSpecificateProcess(WriteableBitmap src, WriteableBitmap dst)////38图像直方图规定化
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
byte[]histMap=HistogramMap(dst);
WriteableBitmap histImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
for (int i = 0; i < temp.Length; i += 4)
{
temp[i] = (byte)(255 * histMap[temp[i]]);
temp[i + 1] = (byte)(255 * histMap[temp[i+1]]);
temp[i + 2] = (byte)(255 * histMap[temp[i+2]]);
}
Stream sTemp = histImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return histImage;
}
else
{
return null;
}
}
public static byte[] HistogramMap(WriteableBitmap src)
{
if (src != null)
{
byte[] temp = src.PixelBuffer.ToArray();
byte gray;
int[] tempArray = new int[256];
int[] countPixel = new int[256];
byte[] pixelMap = new byte[256];
for (int i = 0; i < temp.Length; i += 4)
{
gray = (byte)(temp[i] * 0.114 + temp[i + 1] * 0.587 + temp[i + 2] * 0.299);
countPixel[gray]++;
}
for (int i = 0; i < 256; i++)
{
if (i != 0)
{
tempArray[i] = tempArray[i - 1] + countPixel[i];
}
else
{
tempArray[0] = countPixel[0];
}
pixelMap[i] = (byte)(255 * tempArray[i] * 4 / temp.Length + 0.5);
}
return pixelMap;
}
else
return null;
}
[图像效果]
<img src="http://img.blog.csdn.net/20150412104816739?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvVHJlbnQxOTg1/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
Win8Metro(C#)数字图像处理--2.34直方图规定化的更多相关文章
- Win8Metro(C#)数字图像处理--2.30直方图均衡化
原文:Win8Metro(C#)数字图像处理--2.30直方图均衡化 [函数名称] 直方图均衡化函数HistogramEqualProcess(WriteableBitmap src) [算法说明] ...
- Win8Metro(C#)数字图像处理--2.31灰度拉伸算法
原文:Win8Metro(C#)数字图像处理--2.31灰度拉伸算法 [函数名称] 灰度拉伸函数GrayStretchProcess(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.25二值图像距离变换
原文:Win8Metro(C#)数字图像处理--2.25二值图像距离变换 [函数名称] 二值图像距离变换函数DistanceTransformProcess(WriteableBitmap sr ...
随机推荐
- [CSS] Specify grid columns, rows, and areas at once with the grid-template shorthand
We can specify grid columns, rows, and areas in one property using the grid-template shorthand. .con ...
- erlang一些参考资源
1. erlang非业余研究 http://blog.yufeng.info/ 2.code.wang http://www.cnblogs.com/codew/ 3.码农生涯 http://www. ...
- style.height、offsetHeight、clientHeight、scrollHeight的差别
style.height 包含元素的滚动栏,不包含边框 clientHeight 不包含元素的滚动栏和边框 offsetHeight 包含元素的滚动栏和边框 scrollHeight offsetHe ...
- 【codeforces 546E】Soldier and Traveling
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- [Python] 字典推导 PEP 274 -- Dict Comprehensions
之前自己也遇到过一次,这段时间在群里也遇到过几次的一个问题 用python2.7写的一段程序.里面用到了字典推导式,可是server版本号是python2.6,无法执行. 今天查了下关于Dict Co ...
- T-SQL部分函数(转)
函数类别 作用 聚合函数 执行的操作是将多个值合并为一个值.例如 COUNT.SUM.MIN 和 MAX. 配置函数 是一种标量函数,可返回有关配置设置的信息. 转换函数 将值从一种数据类型转换为另一 ...
- TensorFlow 学习(十)—— 工具函数
1. 基本 tf.clip_by_value() 截断,常和对数函数结合使用 # 计算交叉熵 crose_ent = -tf.reduce_mean(tf.log(y_*tf.clip_by_valu ...
- 通过一次SpringBoot打成war包部署到tomcat启动总结一般jar包冲突的解决方法
启动时,报错信息如下: 28-Sep-2018 16:55:41.567 严重 [localhost-startStop-1] org.apache.catalina.core.StandardCon ...
- Cordova app 检查更新 ----创建项目、添加插件、修改插件(一)
原文:Cordova app 检查更新 ----创建项目.添加插件.修改插件(一) 使用Cordova 进行跨平台应用程序的开发 1.创建Cordova项目 $ cordova create hell ...
- React Native细节记录
1.环境搭建部分 安装完node后建议设置npm镜像以加速后面的过程(或使用***工具).注意:不要使用cnpm!cnpm安装的模块路径比较奇怪,packager不能正常识别! npm config ...