What image format (or, more specifically, how should I create, without writing a custom C program) should I use if I want to store a one channel 16-bit image in binary, with no header, just the values strung one after another? Kind of binary 16-bit PGM with no header.
(Will dig more: Maybe the answer is out there already.)
header-less binary image format
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: header-less binary image format
Code: Select all
convert x.png -depth 16 x.gray
snibgo's IM pages: im.snibgo.com
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: header-less binary image format
Thank you snibgo!
To convert it back to, say, png:
To convert it back to, say, png:
Code: Select all
convert -size WIDTHxHEIGHT -depth DEPTH input.gray output.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: header-less binary image format
That's it. When I write a program that writes such a file, I find it convenient to have the option to spit out the "-size WIDTHxHEIGHT -depth DEPTH" as appropriate.
See also http://www.imagemagick.org/Usage/formats/#rgb . That reference doesn't say (but it's probably obvious) that the image starts at top-left, working across the image, then down. For 3 or 4 channels, the order within each pixel is RGB or RGBA.
See also http://www.imagemagick.org/Usage/formats/#rgb . That reference doesn't say (but it's probably obvious) that the image starts at top-left, working across the image, then down. For 3 or 4 channels, the order within each pixel is RGB or RGBA.
snibgo's IM pages: im.snibgo.com
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: header-less binary image format
The PGM image file format (Ascii or Binary forms) is simple enough for most C programs and includes the size and depth information. Look at the manpage "pgm" for format details.
Ascii forms for scripts, Binary for compactness and low level programming.
This way you keep the minimum meta data with the image data, in such a way that most image programs understand the format.
See also IM Examples, PbmPlus/NetPBM
http://www.imagemagick.org/Usage/formats/#pbmplus
Ascii forms for scripts, Binary for compactness and low level programming.
This way you keep the minimum meta data with the image data, in such a way that most image programs understand the format.
See also IM Examples, PbmPlus/NetPBM
http://www.imagemagick.org/Usage/formats/#pbmplus
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/