Thread Subject: How to write a 24-bit BMP image?

Subject: How to write a 24-bit BMP image?

From: Elad Peer

Date: 22 Oct, 2009 10:12:19

Message: 1 of 3

Hi,

I use 'imwrite' and 'imread' methods to read/write a BMP file.
I need the file at 24-bit, but MATLAB uses (at the standard 'bmp' format) the windows 8-bit format.
Do you know how to change this feature into 24 bit?

Thanks,

Elad

Subject: How to write a 24-bit BMP image?

From: ImageAnalyst

Date: 22 Oct, 2009 10:37:01

Message: 2 of 3

On Oct 22, 6:12 am, "Elad Peer" <el...@tx.technion.ac.il> wrote:
> Hi,
>
> I use 'imwrite' and 'imread' methods to read/write a BMP file.
> I need the file at 24-bit, but MATLAB uses (at the standard 'bmp' format) the windows 8-bit format.
> Do you know how to change this feature into 24 bit?
>
> Thanks,
>
> Elad

----------------------------------------------------------------------
BMP does not support 24 bit monochrome images. It supports 24 bit
color images (three 8 bit color planes). Which are you trying to
achieve?

I suspect you have a monochrome image (a 2D array, whereas a color
image would be a nxmx3 3D array) and are writing it out as a BMP and
getting a monochrome BMP instead of the color BMP like you want.

If you want a color image and have only a 2D array instead of a 3D
array, then you can create a color image array with the ind2rgb()
function or the cat(3,...) function.

Subject: How to write a 24-bit BMP image?

From: Steve Eddins

Date: 22 Oct, 2009 12:21:03

Message: 3 of 3

Elad Peer wrote:
> Hi,
>
> I use 'imwrite' and 'imread' methods to read/write a BMP file.
> I need the file at 24-bit, but MATLAB uses (at the standard 'bmp' format) the windows 8-bit format.
> Do you know how to change this feature into 24 bit?
>
> Thanks,
>
> Elad

If you pass an M-by-N-by-3 array to imwrite, it will create a 24-bit BMP
file.

---
Steve Eddins
http://blogs.mathworks.com/steve/

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
image Elad Peer 22 Oct, 2009 06:14:20
bitmp Elad Peer 22 Oct, 2009 06:14:20
bmp Elad Peer 22 Oct, 2009 06:14:20
rssFeed for this Thread

Contact us at files@mathworks.com