Re: bitmap with bit depth 1
- To: mathgroup at smc.vnet.net
- Subject: [mg104441] Re: [mg104399] bitmap with bit depth 1
- From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
- Date: Sat, 31 Oct 2009 01:55:24 -0500 (EST)
- References: <200910300719.CAA27777@smc.vnet.net>
Hi,
has it to be a bmp? If not then
Image[Reverse@
Table[If[(x^2 + y^2 - 1)^3 - x^2 y^3 > 0.0, 0, 1], {y, -2, 2,
4/255.}, {x, -2, 2, 4/255.}], "Bit"]
Export["~/tmp/binimg.pbm", %]
{ImageType[#], ImageChannels[#], ImageDimensions[#]} &@Import[%]
should help.
Cheers
Patrick
On Fri, 2009-10-30 at 02:19 -0500, van der Burgt, Maarten wrote:
> Hallo,
>
>
>
> Using Mathematica 7.0.1 for Windows, I want to create binary bitmap
> (Windows BMP format) images with a bit depth of 1 (generally grey scale
> or color bitmap images have a bit depth of 8 or 24)
>
>
>
> Here is my data:
>
>
>
> dat =RandomInteger[{0,1},{200,200}]
>
>
>
> The image generated from it looks ok:
>
>
>
> im = Image[dat,"Bit"]
>
>
>
> The right mouse click on the image and selecting Image Mode indeed tells
> me the image is binary with a bit depth of 1 bit/Channel. As does:
>
>
>
> {ImageChannels[im], BinaryImageQ[im],ImageType[im]}
>
> {1,True,Bit}
>
>
>
> But all the images exported:
>
> Export["test1.bmp",im];
>
> Export["test2.bmp",im, "ColorDepth"=AE1];
>
> Export["test3.bmp",im, "BitDepth"=AE1];
>
> Export["test4.bmp",im, "BitDepth"=AE1,"ColorDepth"=AE1];
>
>
>
> are 8 bit greyscale images.
>
> Saving the image via the right mouse click on the image and choosing
> =93Save Image As..=94 saves a 24 bit image.
>
>
>
> I current solution is the use of another package to reduce the bit
> depth, but this is not satisfactory.
>
>
>
> Am I doing something wrong here or is Mathematica failing here?
>
>
>
> On top of this, I cannot import these image back into mathematica:
>
>
>
> Import["test4.bmp" ]
>
> Import::fmterr: Cannot import data as \[NoBreak]BMP\[NoBreak] format.
> =87 =
> <http://reference.wolfram.com/mathematica/ref/message/Import/fmterr.html>
>
> $Failed
>
>
>
> Any help is appreciated.
>
>
>
> regards
>
>
>
> Maarten
>
>
>
- References:
- bitmap with bit depth 1
- From: "van der Burgt, Maarten" <Maarten.VanDerBurgt@icos.be>
- bitmap with bit depth 1