MATLAB: 16 BitDepth vs 24 BitDepth BMP image

bitdepthbmp imageimage processing

I have some BMP images from an optical CT scan that I need to process in matlab. Using the function imfinfo I know that my image before being read by matlab is at 16 BitDepth and is transformed to a 24 BitDepth after.
Before
FileSize: 1572918
Format: 'bmp'
FormatVersion: 'Version 3 (Microsoft Windows 3.x)'
Width: 1024
Height: 768
BitDepth: 16
ColorType: 'truecolor'
FormatSignature: 'BM'
NumColormapEntries: 0
Colormap: []
RedMask: []
GreenMask: []
BlueMask: []
ImageDataOffset: 54
BitmapHeaderSize: 40
NumPlanes: 1
CompressionType: 'none'
BitmapSize: 1572864
HorzResolution: 0
VertResolution: 0
NumColorsUsed: 0
NumImportantColors: 0
After
FileSize: 2359350
Format: 'bmp'
FormatVersion: 'Version 3 (Microsoft Windows 3.x)'
Width: 1024
Height: 768
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: 'BM'
NumColormapEntries: 0
Colormap: []
RedMask: []
GreenMask: []
BlueMask: []
ImageDataOffset: 54
BitmapHeaderSize: 40
NumPlanes: 1
CompressionType: 'none'
BitmapSize: 2359296
HorzResolution: 0
VertResolution: 0
NumColorsUsed: 0
NumImportantColors: 0
I need the image to be a 16 BitDepth BMP when I save it to use it in a reconstruction software. Cheers Pierre

Best Answer

imwrite() in MATLAB cannot write 16 bits per pixel for BMP files.
Note: 16 bits per pixel for BMP files is 4 bits each for R, G, B, and Alpha (possibly not in that order.)
imwrite() for BMP can use logical (total 1 bit per pixel) or uint8 grayscale (total 8 bits per pixel) or uint8 RGB (total 24 bits per pixel.)