Why do I get an image in grey scale after imread the gif image?

My original image is with colour. I read the image file and display it, then I got a grey scale image. Does anyone know how I can load the image without change the colour scale? My code is like this: clear; close all;
I = imread('abc.gif')
figure, imshow(I);

Answers (1)

Don't name it I - that's a bad name - hard to tell the difference between I (upper case i), and l (lower case L), and 1. Plus it's not very descriptive.
Try this
[indexedImage, colorMap] = imread('abc.gif');
imshow(indexedImage);
colormap(colorMap);
colorbar;

8 Comments

Thank you. It turns out in colour in the picture, but I don't understand why the colour (colour scale) changed. It looks very strange.
And I have the same problem when I imwrite the image after processing.
The color should not change. Attach your images. Show your code where you read it in and display it and then call imwrite() and then read in the saved image and display it where it demonstrates that the colors changed.
Here is my code and my result. My purpose is to segment and calculate the length of the edge.
You forgot to apply the colormap to the image you read back in. So you're seeing the indexes as a grayscale image, which is pretty much nonsense/gibberish.
But how about the colour changing ?
You have it displayed 3 times. Each figure is using a different colormap.
Do you still not understand and need more explanation?

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 10 Jul 2014

Commented:

on 11 Jul 2014

Community Treasure Hunt

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

Start Hunting!