Scale a grayscale image to a height map (max and min values (height values in meters) of a RGB topography image)

16 views (last 30 days)
Dear all, I am wondering if someone can please help me with the following question: how can I scale a grayscale image to reflect the height dimension in meters from the original RGB image?
For example:
RGB = imread('topography_AFM.png');
II = im2double(RGB);
I2 = rgb2gray(II); %image in gray scale between 0 & 1
However, here I2 doesn't reflect the real dimensions of the original image. How can I get the max and min values for the RGB image to scale I2?
Thanking you in advance, Sandra

Answers (1)

Walter Roberson
Walter Roberson on 13 Feb 2021
Edited: Walter Roberson on 13 Feb 2021
png files do not have real-world vertical dimensions encoded in them anywhere, except possibly through a Comment block or private binary block.
png files sometimes have useful x and y resolution information stored in them that would allow you to deduce the horizontal and vertical distances. Unfortunately, most of the time that kind of data exists at all in PNG files, it is useless data that says that the real-world resolution is either 72 pixels per inch or 100 pixels per inch.
Sometimes images have colorbars drawn in them that permit you to interpret distances from the colors.
Sometimes images are colored according to some standard or consistent elevation key that is not necessarily drawn in the image itself; you would need to know more about how the image was produced to interpret those.
TIFF images, on the other hand, there are standards such as GeoTiff to represent physical information. DICOM images as well, but DICOM does not typically represent more than about 20 cm or so.

Community Treasure Hunt

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

Start Hunting!