Histogram to image

Hi, I'm a Matlab newbie and I desperately need your help. I need to enhance image by performing operations on its histogram. But how can I apply that changes to the image? It's easy to extract histogram form the image but how to transform histogram back into image after performing e.g. histogram smoothing?

답변 (2개)

Image Analyst
Image Analyst 2011년 12월 24일

0 개 추천

I suppose you could maybe use the intlut() function. But why don't you tell us what you want to do and we can tell you the best way to achieve it? You can upload your image to tinypic.com.
M W
M W 2011년 12월 24일

0 개 추천

Thanks for the answer.
I need to implement a Generalized Histogram Equalization algorithm. The method is described in the following article (click to open/download a PDF file)
I'm stuck at the point where I have to remove the noise from histogram. I can do it e.g. with the medfilt1() method. It works fine for the histogram but what about the image? I need to change the image too. Is there any way to recreate the image based on the new histogram?

댓글 수: 6

Image Analyst
Image Analyst 2011년 12월 24일
Who said anything about removing noise from the image? I don't think you need to. Just follow their algorithm. After smoothing you just continue on and you'll get the expected image.
M W
M W 2011년 12월 25일
Oh, well, that make sense. I'm really grateful from your help.
But still, in step 8, I need to equalize the histogram piecewise, e.g. from 0 to 100, 101 to 180 and 181 to 255 (those are pixel intensities). And there probably isn't any built-in function to do it, so I'm stuck again with a very similar problem. I can modify the histogram but this alone won't have any impact on the image.
Image Analyst
Image Analyst 2011년 12월 25일
It seems like they want to perform a histogram equalization on grayscale regions between those specific ranges rather than the full 0-255. The way to do this is to do it just like you'd do it for the full 0-255 range but just in that range. The "dumb" but standard way is to compute the cumulative distribution function of the histogram, but just within that small range, and then use intlut to redistribute the gray levels, but again JUST WITHIN THAT RANGE, not over the whole 0-255. (If you did it piecewise over the whole 0-255 I'm sure it would look bizarre with many false edges popping up.) To me it seems like this piecewise method would produce a subtle effect but maybe that's what they're after since they seem to say that the standard way of doing it produces images that are too harsh (which is true and is why global histogram equalization is almost never used in practice and is usually just to illustrate concepts for beginners in image processing).
If you want a more sophisticated and better way that produces a flatter, more evenly distributed output distribution, at the expense of a more complicated algorithm, then check out my histogram shaping File Exchange submission at http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 You could use this in the small ranges instead of the standard CDF way.
M W
M W 2011년 12월 25일
Thanks again, you are really helping me!
Your histogram shaping program seems to be an amazing piece of code. I figured out that the TransformImage() function is the key for equalization. I'm now able to equalize histogram for any image. It really is flat and the image's contrast is improved.
However I have a hard time modifying it so that it works only for specified piece of histogram (e.g bins form 90 to 150) and the rest of the bins should be left as they are.
Another approach could be to pass a matrix with specified points and desired heights of the bins between that points) to the function and perform the equalization based on this matrix.
Can I ask for a little help?
Image Analyst
Image Analyst 2011년 12월 25일
It may take you a while, as it would for me, but I think is something that you could handle.
M W
M W 2011년 12월 25일
Yea, I think I can do it. You provided a really good commentary.
I've spent some time looking through this code and I see that the desiredPixelsInEachBin vector may be the key.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기

질문:

M W
2011년 12월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by