MATLAB: How to create AVI files with a bitdepth of 8-Bit per pixel instead of 24-Bit per pixel in MATLAB 7.7 (R2008b)

MATLAB

I am trying to create an 8-Bit AVI-file from RGB frames. My script converts the RGB frames to 8-bit before putting them in the AVI object. However, the AVI file still appears to be tagged as 24-Bit.

Best Answer

This behavior is observed possibly because the RGB image data in the MATLAB workspace is of data type DOUBLE or UINT8 and dimension m by n by 3. RGB image data means there are three color channels (Red, Green, Blue) each channel using 8-bits per pixel. As a consequence the resulting AVI-File will have a have bitdepth of 24-bit.
To create an 8-bit AVI-File you will need to convert your image data to either indexed or grayscale (both using 8-bits per pixel). This conversion can be done with RGB2IND or RGB2GRAY. For further details refer to the documentation:
Convert RGB image to indexed image - MATLAB
Convert RGB image or colormap to grayscale - MATLAB
You may also be interested in the section "More About" of the documentation of the IMAGE command:
Display image object - MATLAB
Related Question