原文: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直方图规定化的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.30直方图均衡化

    原文:Win8Metro(C#)数字图像处理--2.30直方图均衡化 [函数名称] 直方图均衡化函数HistogramEqualProcess(WriteableBitmap src) [算法说明] ...

  2. Win8Metro(C#)数字图像处理--2.31灰度拉伸算法

    原文:Win8Metro(C#)数字图像处理--2.31灰度拉伸算法  [函数名称] 灰度拉伸函数GrayStretchProcess(WriteableBitmap src) [算法说明]    ...

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

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

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

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

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

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

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

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

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

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

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

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

  9. Win8Metro(C#)数字图像处理--2.25二值图像距离变换

    原文:Win8Metro(C#)数字图像处理--2.25二值图像距离变换  [函数名称] 二值图像距离变换函数DistanceTransformProcess(WriteableBitmap sr ...

随机推荐

  1. [tmux] Copy and paste text from a tmux session

    One non-obvious, but extremely useful, feature in tmux is copy-pasting text between panes. This also ...

  2. 【计算机视觉】OpenCV中直方图处理函数简述

    计算直方图calcHist 直方图是对数据集合的统计 ,并将统计结果分布于一系列提前定义的bins中.这里的数据不只指的是灰度值 ,统计数据可能是不论什么能有效描写叙述图像的特征. 如果有一个矩阵包括 ...

  3. 毕设一:python 爬取苏宁的商品评论

    毕设需要大量的商品评论,网上找的数据比较旧了,自己动手 代理池用的proxypool,github:https://github.com/jhao104/proxy_pool ua:fake_user ...

  4. prettytensor 的使用

    prettytensor 顾名思义,对原始的 tensorflow 下的 tensor 进行封装(prettytensor 以 tensorflow 为基础,二者搭配使用),使其成为一个更为接口友好的 ...

  5. UITextView的一些事1

    TextView如果只是作为展示文本时,要设置如下属性: //不可编辑(是否弹出键盘) TextView_label.editable=NO; //不可选择(长按不会出现复制.粘贴) TextView ...

  6. iOS中,MRC和ARC混编

    假设一个project为MRC,当中要加入ARC的文件: 选择target -> build phases -> compile sources -> 单击ARC的文件将compil ...

  7. CMake 添加头文件目录,链接动态、静态库(添加子文件夹)

    CMake支持大写.小写.混合大小写的命令. 当编译一个需要第三方库的项目时,需要知道: 去哪找头文件(.h),-I(GCC) INCLUDE_DIRECTORIES() 去哪找库文件(.so/.dl ...

  8. 对Java字符串的探究

    问题的出发点 在网上看到一道题: 1 String str = new String("abc"); 以上代码执行过程中生成了多少个 String 对象? 答案写的是两个.&quo ...

  9. css 单选框 样式 填充自定义背景 after

    input[type='radio'] //width 16px //height 16px display none //input[type='radio']:chcked // backgoun ...

  10. Net多线程编程

    Net多线程编程—使用Visual Studio 2012进行调试 1 相关概念 1)栈帧 C语言中,每个栈帧对应着一个未运行完的函数.栈帧中保存了该函数的返回地址和局部变量. 栈帧也叫过程活动记录, ...