Bitmap contrast issue

When I use the imread function to open a grayscale .bmp image, the contrast displayed is far darker than the original image, which causes problems for image processing. Converting the image to .jpeg eliminates the contrast issue, but I have several thousand images to read and I don't want to have to convert them all. Is there a way to get MATLAB to read .bmp files correctly?

 Respuesta aceptada

Sean de Wolski
Sean de Wolski el 24 de Jun. de 2011

0 votos

Are you sure it's not reading them correctly but you're just viewing a small range?
try:
imshow(imread('example.bmp'),[]); %whole range
Edition:
What class is the bitmap file?
I = imread('example.bmp');
class(I)
and then what class is the corresponding JPG file?
I = imread('sameexample.jpg');
class(I)

2 comentarios

Wesley
Wesley el 24 de Jun. de 2011
That helps, although it's not quite the same as the contrast on the original image. It should be workable, though-- thank you!
Wesley
Wesley el 24 de Jun. de 2011
Bitmap: uint8
JPEG: uint8

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 24 de Jun. de 2011

2 votos

BMP files can have color palettes stored, and indeed must use such palettes when they are less than 8 bits deep. A color palette corresponds to MATLAB's colormap.
[YourImage, YourColormap] = imread('example.bmp');
image(YourImage);
if ~isempty(YourColorMap); colormap(YourColorMap); end

Preguntada:

el 24 de Jun. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by