Hello,
How can I write a 1-bit bmp image in Matlab using imwrite or any other function. the default of imwrite for bmp is 8-bit.
Thanks a lot :)
Hello,
How can I write a 1-bit bmp image in Matlab using imwrite or any other function. the default of imwrite for bmp is 8-bit.
Thanks a lot :)
You have to convert the image to logical (i.e. 1-bit) before the call to imwrite.
%# assuming the image is stored in a variable 'img'
imwrite(logical(img),'test.bmp','bmp')
According to the IMWRITE documentation:
If the input array is of class
logical
,imwrite
assumes the data is a binary image and writes it to the file with a bit depth of 1, if the format allows it. BMP, PNG, or TIFF formats accept binary images as input arrays.
Therefore, if you convert your image data to a logical matrix before giving it to IMWRITE, you should be able to create a 1-bit BMP image:
imwrite(logical(imageData),'image.bmp');