From: Leon on 17 Mar 2010 03:38 I am running into two issues trying to read and write bmp images. My images are grayscale 24bit BMPs exported from photoshop. first I read the file [I,map] = imread(filename,'bmp'); it runs without error but map is an empty matrix. This creates an error with imwrite if I use imwrite(I, map, newfilename,'bmp'); I can circumvent the error by map = gray(256); But than I cannot find how to make the new file be a 24bit and not 8bit BMP. As far as I could see in the help files, there is no 'bitdepth' paramater for bmp files. Thanks, Leon
From: Walter Roberson on 17 Mar 2010 03:59 Leon wrote: > I am running into two issues trying to read and write bmp images. > My images are grayscale 24bit BMPs exported from photoshop. > > first I read the file > > [I,map] = imread(filename,'bmp'); > > it runs without error but map is an empty matrix. That tells you that as far as imread() is concerned, the file is a truecolor image rather than a pseudo-color image; 'I' will be M x N x 3; if it is truly grayscale then the R, G, and B components will all be equal. >This creates an error > with imwrite if I use > imwrite(I, map, newfilename,'bmp'); > > I can circumvent the error by map = gray(256); > > But than I cannot find how to make the new file be a 24bit and not 8bit > BMP. As far as I could see in the help files, there is no 'bitdepth' > paramater for bmp files. If I remember correctly (and it is nearly 3 AM here, so I might be wrong), the bit depth that will be used will depend upon the data class of the image and upon whether it is a truecolor image or a pseudo-color image. For 24 bit grayscale, you may need to use data of class uint32 .
|
Pages: 1 Prev: relation b/w bits per pixel(bpp) and compression ratio Next: using QccPack |