stretching histogram of an image

I have an image attached with this message and its histogram is also attached. I want to stretch its histogram from 0-255 to 0-65535 and keeping the shape as it is. Please help in this regard.
Thanks in advance.
<<
>>

Antworten (1)

Image Analyst
Image Analyst am 26 Jun. 2016

0 Stimmen

Simply multiplying the image by 256 will stretch the histogram.
image16 = uint16(image8) * uint16(256);
However, it will leave gaps of 256 between the bins. Is that what you want? If not, then you must cast to double and add noise in the range of 0-255 before scaling:
noiseImage = randsize(image8) - 0.5
image16 = uint16((double(image8) + noiseImage) * 256);
This would give a "solid" histogram with no gaps. The code is untested but I believe it should work.

4 Kommentare

try analyst
try analyst am 27 Jun. 2016
Bearbeitet: try analyst am 27 Jun. 2016
Thanks Image Analyst, It is working and I am getting full stretched histogram. But question I want to ask that even the gray levels have been stretched to 16 bit but there is no significant difference in display. In fact, the pixels after stretching must show a more detailed information. How can I do that, if possible?
Of course not. Why should there be? It maps the image range to the display range for each. If you want them to be compared on the same scale, you'll have to specify the scale, like
imshow(image8, [0, 65535]);
imshow(image16, [0, 65535]);
Thorsten
Thorsten am 27 Jun. 2016
You cannot get additional information by stretching the histogram. It's just a different way to store the same data. Like if you have values 1 2 3, you cannot get any more detailed information from 10 20 30. And if you have a true 16 bit image, you need a monitor that can display 16 bit images without truncating them to 8 bit, to see a difference.
try analyst
try analyst am 15 Jul. 2016
Verschoben: DGM am 7 Mai 2023
Is the displaying monitor only thing that can improve the quality? I read hist stretching can improve contrast and it results in visualizing more information....any comment?

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 26 Jun. 2016

Verschoben:

DGM
am 7 Mai 2023

Community Treasure Hunt

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

Start Hunting!

Translated by