Loaded Image Doesn't Retain Separate Colors

4 views (last 30 days)
I have an image of a map loaded in MATLAB.
BEFORE the map is loaded into MATLAB the appearance is:
US Continent: Green
Ocean: Blue
Canada: Yellow
AFTER I load the map it is displaying:
Canada and the US as one color BUT I need to separate them by colors.
My code is:
im = double(imread('US.png'))
figure;
colormap summer;
...
Thanks,
Amanda

Accepted Answer

Walter Roberson
Walter Roberson on 30 Aug 2012
Try
fig = figure;
ax = axes('Parent', fig);
[im, cmap] = imread('US.png');
if isempty(cmap)
im = im2double(im);
cmap = summer;
end
image(im, 'Parent', ax);
colormap(cmap);
  3 Comments
Amanda
Amanda on 30 Aug 2012
Edited: Amanda on 30 Aug 2012
Walter -- I really appreciate it. Only a few people are plotting and imaging experts.
Image Analyst
Image Analyst on 31 Aug 2012
You're right, though it is the most used toolbox, according to the list at the left.

Sign in to comment.

More Answers (0)

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!