displaying a 512 *512 8 bpp image

6 views (last 30 days)
tina jain
tina jain on 17 Apr 2015
Answered: DGM on 13 Nov 2022
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

Answers (1)

DGM
DGM on 13 Nov 2022
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.

Tags

Community Treasure Hunt

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

Start Hunting!