Hello, how to read a BMP image in MATLAB?

I am trying to read the BMP image(160 x 120 x 24 BPP) produced by FLIR Lepton Sensor in MATLAB. I have also attached the BMP image here.I'm using MATLAB R2016a...I used the following command.
Background=imread('...\LeptonTest\current.BMP');
I got the following error:
Error using imbmpinfo>readBMPInfo (line 106)
Header size was 56 bytes. Only values of 12, 40, 64, 108, or 124 are supported.
Error in imbmpinfo (line 23)
metadata = readBMPInfo(fid, metadata);
Error in readbmp (line 14)
info = imbmpinfo(filename);
Error in imread (line 415)
[X, map] = feval(fmt_s.read, filename, extraArgs{:});
Please some body help me to fix this problem.

Antworten (3)

Dinesh Iyer
Dinesh Iyer am 5 Jul. 2016

1 Stimme

This appears to be a bug with IMREAD. The BMP file appears to use a BI_BITFIELD compression to store the image data which appears to be be tripping up IMREAD.
Sorry about this. Will update once a patch is ready.
Dinesh Iyer
Dinesh Iyer am 19 Jul. 2016

1 Stimme

The patch with the fix for this issue can be found at:

4 Kommentare

Image Analyst
Image Analyst am 19 Jul. 2016
Dinesh Iyer
Dinesh Iyer am 19 Jul. 2016
I am not sure I understand your comment. Does the patch still not resolve this issue?
Image Analyst
Image Analyst am 19 Jul. 2016
Sorry, I just thought it was a cute graphic. Actually I haven't tried the patch since I think it's for a fairly rare type of image that I don't use. Anyway, is this fix going to make it into the R2016b version? If not, I guess it would also have to be applied after installing R2016b.
Dinesh Iyer
Dinesh Iyer am 19 Jul. 2016
This will not be making it to 16b but the patch in the link should work for 16b as well.

Melden Sie sich an, um zu kommentieren.

Geoff Hayes
Geoff Hayes am 30 Jun. 2016

0 Stimmen

Bal - I get the same error when using R2014a. However, I was able to load this image into MATLAB as follows
>> open('current.BMP');
which would launch the Import Wizard. Pressing the Finish button created a variable called current which is a 120x160x3 array which I could display using the image command.
I'm not sure why there is a difference between using open and imread (i.e. why does open seem to support the 56 byte header but imread does not). Perhaps this should be logged as a bug.

3 Kommentare

Bal Poudel
Bal Poudel am 30 Jun. 2016
Bearbeitet: Bal Poudel am 30 Jun. 2016
Hi Geoff,
Thanks for your prompt response. I did try the 'open' command and it did not show any errors , however, once I executed this command it automatically opened a new tab in my MATLAB editor showing garbage contents with 'current.BMP' file name( Please see the screenshot). Also, the command returns an empty array. As you have mentioned about import wizard, it does not launch in my computer. Do you have any ideas regarding this problem? Thanks in advance.
Hi Bal - I'm not sure why the import wizard would not launch on your computer. What happens if you try to open by right-clicking on the file name in the MATLAB file browser. Or try,
uiimport('current.bmp')
Image Analyst
Image Analyst am 5 Jul. 2016
open() on my computer also opens the binary data into a text editor window, like for bal. uiimport() did bring up a wizard, but I don't know what to do with it:

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 30 Jun. 2016

Kommentiert:

am 19 Jul. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by