Modification of image using custom histogram
14 views (last 30 days)
Show older comments
Hi Matlabers
I'm looking for some tips on custom histogram modification. Here's what I need to do: I am reducing the number of bins in an image to 48 or below, I need to modify the positions of image histogram bins _ without _ changing the levels of those bins.
Initially the effect would be to evenly space the histogram bins across the range (in this case 0 - 255, always having the first bin at 0 and the first at 255), while keeping the levels and order of those bins the same.I would also like to modify the histogram to resemble different distribution, such as normal or beta.
I then need to change the contrast levels of an image to match this new histogram.
I've been struggling with this for a while, so any help would be very much appreciated!
Thanks in advance!
Jay
0 Comments
Answers (2)
Sean de Wolski
on 30 Dec 2014
3 Comments
Image Analyst
on 30 Dec 2014
What does "without changing the levels" mean? If you move the bins, you've changed the levels over which that bin is looking at. If you have some arbitrary histogram shape and you want it to be some other shape just by changing what gray levels the bins collect, then it may not be possible. You'll actually have to change some of the gray levels of the image also, such that now some gray levels will fall into multiple bins instead of all into the same bin. For example if you have a bin at gray level 125 with a count of 1000 pixels in it, you might have to take 300 of them and put them into a bin at 110 gray levels, 400 of them and put them into a bin as 111 gray levels, and 300 of them and put them into a bin at 112 gray levels. But you have to be careful how you select the gray levels to reassign to other gray levels. You need to do it randomly or else you'll notice weird artifacts in your image. That's what I do in the app Sean referred to. If you post an image and post some curve that you want to make it into, then I might be able to code it up for you. A less sophisticated, less accurate version is in the function imhistmatch() of the Image Processing Toolbox.
Image Analyst
on 30 Dec 2014
You can precisely specify where each bin starts and stops if you use histc() instead of imhist(). histc() sounds like it will do what you want.
8 Comments
Image Analyst
on 31 Dec 2014
I don't think you need to equalize the image as an intermediate step. Just use imhistmatch() for an approximate transform. There are more accurate ways, but this quick and dirty method will probably do the trick for you.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!