Minimalist
Minimalist

Reputation: 975

Import Image to MATLAB from Screen Capture of Google Earth

In MATLAB:

I am applying screen capture to produce an image of the US using

Google Earth. However, when I read the image into MATLAB to plot

data over it the image becomes all white -- no red,green, or blue.

Note: it does display correctly without plotting any additional data

and using imshow.

My code is:

I = double(imread('USA.png'));
img = flipdim(I,1)
B = IMPRESIZE(img,[500,500],'nearest')
colormap HSV;
hold on;
....Plot Data....

Is there a way to import the image and plot scatter data over it?

Upvotes: 0

Views: 867

Answers (1)

klurie
klurie

Reputation: 1060

I believe your problem comes from casting your image as a double.

When your image is in uint8 format, MATLAB uses 0-255 as the range of the color scale. When your image is in double format, MATLAB uses 0-1 as the range for the color scale. As a result, when you cast your image to double, MATLAB uses this latter range which means any color with an R,G, or B value greater than 1, becomes 1 for display purposes (e.g. essentially all of the pixels are displayed as white)

In short, change your first line of code to (no casting)

I = imread('USA.png');

Or if you must cast your image as a double, you can use the following function to autoscale the color scale based on the range of your data

imagesc(img)

Upvotes: 1

Related Questions