displaying a 512 *512 8 bpp image

3 次查看(过去 30 天)
tina jain
tina jain 2015-4-17
回答: DGM 2022-11-13
I am having two lena image
  1. lena256.bmp---> a 256 *256 image
close all;
clear all;
clc;
%--------Displaying Lena image which has 256*256 size
imData=imread('lena256.bmp');
imshow(imData);
figure(1);
title('Original image');
pause(2);
By using above code I am able to display the image.
2. lena_2.bmp----> 512 * 512 image
close all;
clear all;
clc;
%--------Displaying Lena image which has 256*256 size
imData=imread('lena_2.bmp');
imshow(imData);
figure(1);
title('Original image');
pause(2);
by using the above code, the image displaying is as follow
why is it so?? why second image is not correct

回答(1 个)

DGM
DGM 2022-11-13
The image is an indexed image. You need the corresponding color map in order to do anything with it.
[A map] = imread('lena.bmp'); % read the image and the map
imshow(A,map); % use the map to display or write the image
In this case, the copy of lena.bmp appears to be a color image with a relatively short color table and no dithering. Be aware that there are many versions of this image floating around. Some are I/RGB; some are indexed grayscale or color with varying map lengths and dithering methods. Just because you have a file called 'lena.bmp' doesn't mean it's the same as something you see described in a code example on a forum somewhere.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by