imread distorts a BMP

  • Follow


Hi
I am using imread() in order to read a BMP. when I use imshow() it shows a dark image (of the bmps). how can I read BMP and leave the image as is.
this is the code:

clc
path='C:/Documents and Settings/Ariel/Desktop/exp_brk_scrm/2.1/group1/exp_up/exp_up/4python/stims/stim1'
filename=strcat(path,'/stim1.BMP');
a=imread(filename,'BMP');
imshow(a);

thanks for any help
0
Reply didi 1/25/2010 2:57:04 PM

didi mimi:
First set a break point and look at the values of "a" before it's
displayed.  Does it show values in the 0-255 range?  Or are they all
small, like less than 10 or 20?

Try
imshow(a, []);
to scale whatever you have to the range of 0-255 so you can see it
better.

Finally, open up stim1.bmp in a text editor.  Are the first two bytes
of the file "BM"?  If not, it's not a bmp file.

-ImageAnalyst
0
Reply ImageAnalyst 1/25/2010 3:50:54 PM


didi mimi wrote:
> Hi
> I am using imread() in order to read a BMP. when I use imshow() it shows 
> a dark image (of the bmps). how can I read BMP and leave the image as is.
> this is the code:
> 
> clc
> path='C:/Documents and 
> Settings/Ariel/Desktop/exp_brk_scrm/2.1/group1/exp_up/exp_up/4python/stims/stim1' 
> 
> filename=strcat(path,'/stim1.BMP');
> a=imread(filename,'BMP');
> imshow(a);
> 
> thanks for any help

Maybe the image file contains a colormap that you are not reading.  Try:

[a,map] = imread(filename);
imshow(a,map)

---
Steve Eddins
http://blogs.mathworks.com/steve/
0
Reply Steve 1/25/2010 4:58:52 PM

Hi all,

I have the same problem as Didi. I tried the solutions written in the messages of this discussion but it does not help.

Have you fixed the problem meantime?

Thanks,

Reb

"Steve Eddins" wrote in message <hjkikc$k73$1@fred.mathworks.com>...
> didi mimi wrote:
> > Hi
> > I am using imread() in order to read a BMP. when I use imshow() it shows 
> > a dark image (of the bmps). how can I read BMP and leave the image as is.
> > this is the code:
> > 
> > clc
> > path='C:/Documents and 
> > Settings/Ariel/Desktop/exp_brk_scrm/2.1/group1/exp_up/exp_up/4python/stims/stim1' 
> > 
> > filename=strcat(path,'/stim1.BMP');
> > a=imread(filename,'BMP');
> > imshow(a);
> > 
> > thanks for any help
> 
> Maybe the image file contains a colormap that you are not reading.  Try:
> 
> [a,map] = imread(filename);
> imshow(a,map)
> 
> ---
> Steve Eddins
> http://blogs.mathworks.com/steve/
0
Reply RebUsesMatlab (1) 10/3/2011 2:01:31 PM

>
> "Steve Eddins" wrote in message <hjkikc$k73$1@fred.mathworks.com>...
>> didi mimi wrote:
>> > Hi
>> > I am using imread() in order to read a BMP. when I use imshow() it
>> shows > a dark image (of the bmps). how can I read BMP and leave the
>> image as is.
>> > this is the code:
>> > > clc
>> > path='C:/Documents and >
>> Settings/Ariel/Desktop/exp_brk_scrm/2.1/group1/exp_up/exp_up/4python/stims/stim1'
>> > > filename=strcat(path,'/stim1.BMP');
>> > a=imread(filename,'BMP');
>> > imshow(a);
>> > > thanks for any help
>>
>> Maybe the image file contains a colormap that you are not reading. Try:
>>
>> [a,map] = imread(filename);
>> imshow(a,map)
>>
>> ---
>> Steve Eddins
>> http://blogs.mathworks.com/steve/

On 10/3/2011 10:01 AM, Reb wrote:
 > Hi all,
 >
 > I have the same problem as Didi. I tried the solutions written in the
 > messages of this discussion but it does not help.
 >
 > Have you fixed the problem meantime?
 >
 > Thanks,
 >
 > Reb

Reb,

We are not aware of a problem with imread and BMP files. I suggest that 
you post your BMP file online somewhere so that we can try it. If you 
can't do that, then post the output of imfinfo here.

-- 
Steve Eddins
http://blogs.mathworks.com/steve/
0
Reply steve.eddins (783) 10/3/2011 2:39:43 PM

4 Replies
318 Views

(page loaded in 0.248 seconds)


Reply: