图像直方图(灰度) [英] histogram of image (grayscale)

查看:84
本文介绍了图像直方图(灰度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让源代码查看图像的直方图,单击一个按钮以下载图像,然后单击另一个按钮以显示该图像的直方图.

I want source code to view the image histogram ,click a button to download the image and then click another button to display the histogram of this image

推荐答案

灰色对于不相信的人来说,与彩色直方图相比,比例尺直方图几乎是微不足道的(由于色度的取舍在某种程度上是一个哲学问题,因此这一点都不是微不足道的::-) http://en.wikipedia.org/wiki/HSL_color_space">http://en.wikipedia.org/wiki/HSL_color_space [
Gray-scale histogram is nearly trivial compared to color histogram (which is not trivial at all due to the fact that what to take for Luminosity is somewhat philosophical question, :-) for those who do not believe: see this: http://en.wikipedia.org/wiki/HSL_color_space[^]).

However, a even a gray-scale histogram is a bit less trivial then appears in the Answer by Albin. To start with, 255 is not a word constant like a speed of light. Usually, real bits per pixel vary from 8 to 16, but in practice a raw picture from a standard CMOS or CCD it''s somewhere between 8 (8-bit mode) and 12 (16-bit mode). If remaining four bits are used in the output file really depends on in-camera processing: the dynamic range can be modified; the ultimate transformation use to use full range is called normalization.

As a result, the number of color bins can reach 212=4096 or 216=65536 which is bit to much to show directly. Number of bins should be arbitrarily selected based on the presentation and re-calculated into required number of bins grouping close colors together; the array should be of floating-point type and re-normalized to maintain consistent vertical scale.

Zinssame, please sort out your buttons and loading yourself and next time think of some better UI design (gosh, why everyone is asking about these buttons?). Access to the separate pixels fully depends on the library you want to use: System.Drawing or WPF (or anything else); you could have asked about the particular library you want to use. It is done in totally different ways. The techniques are well documented and sample codes are provided in MSDN, so it should not be a problem. You can ask a separate question if you face any problem.

—SA


具有索引为0到255的数组.循环遍历图像的像素,然后递增数组索引中的值.例如,如果像素值为50,则FreqArray[50]= freqArray[50]+1;.读取所有像素后,然后针对色区(0到255)绘制频率.多数民众赞成在直方图.真的很难编码吗?
Have an array indexed 0 to 255. Loop through the pixels of the image then increment the values in the array index. For example if the pixel value is 50 then FreqArray[50]= freqArray[50]+1;. Once you read all the pixels then plot the frequencies against the color bins (0 to 255). Thats the histogram. Is it really tough to code?


这篇关于图像直方图(灰度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆