Question about image processing

4 visualizzazioni (ultimi 30 giorni)
captainmariah
captainmariah il 26 Apr 2018
Risposto: Walter Roberson il 26 Apr 2018
Hi, I been saving a grayscale image, that has maximal possible intensity around 4000 (12 format), but the image is saved as 16-bit in png format.
I have plotted the image with imagesc(im).
What I don't understand is why Index is 0,06884 and not the intensity value I can see in the image program I captured the image with?
Also why does MATLAB display [R,G,B]: [0.06.... etc] if this is a gray scale image?

Risposte (2)

Florian Morsch
Florian Morsch il 26 Apr 2018
A 16 bit intensity image is ranged from [0 65535], if you convert it to double format you have to divide your intensity by 65535. With a image of around 4000 you get 4000/65536 = 0.061036.
On your last Question: A grayscale image is still a RGB image of some sort, just the RGB values have been adjusted. The description of the MATLAB algorythm for grayscale is this:
Algorithms
rgb2gray converts RGB values to grayscale values by forming a weighted sum of the R, G, and B components:
0.2989 * R + 0.5870 * G + 0.1140 * B
These are the same weights used by the rgb2ntsc function to compute the Y component.
The coefficients used to calculate grayscale values in rgb2gray are identical to those used to calculate luminance (E'y) in Rec.ITU-R BT.601-7 after rounding to 3 decimal places.
Rec.ITU-R BT.601-7 calculates E'y using the following formula:
0.299 * R + 0.587 * G + 0.114 * B
This means your R, G and B-values are rescaled and displayed, thats why matlab still can show their values.

Walter Roberson
Walter Roberson il 26 Apr 2018
For the last question:
MATLAB does not have any way to display in true grayscale. All 2d arrays displayed are treated as pseudocolor images. If you happen to want to display the pseudocolor as gray then you use an rgb colormap that has only gray tones.
If you have displayed a 2d array as gray and you decided that you wanted to see it in copper instead then you would just tell MATLAB to activate the copper colormap. This would not change anything in the data structure of the image object, just change the lookup table between linear and color. If images could be true grayscale instead of pseudocolor then it would be necessary to change the image properties to switch between "this 2d array is true gray" and "this 2d array is pseudocolor"... but MATLAB does not work that way.

Categorie

Scopri di più su Images in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by