How to read a RGB 14 bit per channel image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

How to read a RGB 14 bit per channel image

Post by markmarques »

Recently I have found the following problem:
I have a scanner that "suposelly" give 14 bits per channel depth but the only "image format"
I get to output / work with that depth is a RAW RGB file with the plain RGB data ...

Problem 1: I do not have always the same width nor height ... :(
I am using the IrfanView program but despite the image being shown if I "quit" I get asked to insert the correct size ( which I do not know ...)

So I am having several raw images that I can not read ... :(

IM convert reports that does does not have a decode delegate ...

If I try the identify util I also get the same "error" ...
how can I bypass the delegate and or force the file to be interpreted by IM ?

Is it possible to call convert with something like "convert -depth 14 image.raw JPG:output.jpg" without specifing sizes ?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to read a RGB 14 bit per channel image

Post by anthony »

Without knowing exactly what they mean by 14 bits per pixel it is hard to say. Is it 2 bytes per value (16 bits) containign a 14 bit integer? Or do they mungle the bits together without regard for byte boundaries. Or perhaps 4 channels making it 4*14 or 56 bits and 7 bytes per pixel?

The "stream" utility may be able to to that latter, generating raw 16bit RGBA values taht normal Imagemagick commands can read.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: How to read a RGB 14 bit per channel image

Post by markmarques »

hi, after some more fidling I have found that the RAW image is read correclty with Irfanview ( the original program that made the image ... )
with the following options :
24 BPP ( 3bytes per pixel ) ; Color order: RGB ( 32bit RGBA) ; Interleaved (RGB) ...
But I have to "feed" the correct size first !!!

Nonetheless with the help of another uitl I have found that
by the size of the file 4106907 bytes I get something like 987x1387 ...
AFter finding those values I "feed" them to irfanview and got the correct image ...

How can i read this raw image with IM knowing this kind of info ?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to read a RGB 14 bit per channel image

Post by anthony »

Assuming 24 bit oer pixel. 8 bit depth, RGB order and a size of 987x1387...

Code: Select all

  convert  -depth 8 -size 987x1387 rgb:raw_data   image.png
See Raw RGB data
http://www.imagemagick.org/Usage/formats/#rgb

Note when 16bits per color value is use you may also need a -endian setting to determine byte order (LSB is default)
I have made use of these settings for generating raw data output for gnuplot graphing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply