Save bitmap with BitDepth = 9

Hello,
I have a bitmap with the usual 24bit BitDepth. Which is 8bit x 8bit x 8bit colors.
Now I converted the colors to a total of 8 different colors, so I could create a bitmap with a colorrange from 0 to 3bit (or 7) (instead of the usual 8bit (or 255)) to compress the image.
But how do I save that new bitmap file with a different BitDepth?
I tried
Aq = uint8(reshape(Xq, size(A)));
imwrite(Aq, '3-bit-color-bitmap.bmp');
Where A is the original 383x600x3 uint8 bitmap and Xq is the edited one in 2D, which is reshaped back to a 3D array.
But my filesize stays the same, because it's probably still in the same old colorrange from 0-255.
I can't create an uint3 array with
Aq = uint3(reshape(Xq, size(A)));
imwrite(Aq, '3-bit-color-bitmap.bmp');
because uint3() does not work.
So how do I save the compressed bitmap with a different BitDepth?

Answers (0)

Categories

Asked:

on 16 Jun 2020

Edited:

on 16 Jun 2020

Community Treasure Hunt

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

Start Hunting!