How to handle tiff with 2 channels only

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
alosca
Posts: 52
Joined: 2010-03-04T17:54:57-07:00
Authentication code: 8675308
Location: Pasadena, California

How to handle tiff with 2 channels only

Post by alosca »

I would like to use IM to work on some tiff images that were extracted from a multipage microscopy file (.lsm, Zeiss format, tiff based). The problem I think I am having is that there are 2 channels only on the tiff files (see below) and IM can't quite work with that. For example,

% convert -separate -channel R image.tif foo.pgm
convert: Sorry, can not handle RGB image with Color channels=2. `image.tif' @ tiff.c/TIFFErrors/493.

generates 'foo.pgm' with correct bit depth and size but it doesn't really copy pixel values (foo.pgm is a total black image).

Is there a proper way of extracting each channel of such images with IM ? I don't like the fact that image.tif is tagged as a RGB color image but only comes with 2 samples per pixel, but that's what I have to deal with.

- Alex.


alex [208] : tiffinfo image.tif
TIFF Directory at offset 0x441008 (4460552)
Subfile Type: (0 = 0x0)
Image Width: 1056 Image Length: 1056
Bits/Sample: 16
Compression Scheme: LZW
Photometric Interpretation: RGB color
Samples/Pixel: 2
Planar Configuration: separate image planes
Predictor: horizontal differencing 2 (0x2)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to handle tiff with 2 channels only

Post by fmw42 »

post a link to one of these images, so we can see if IM can even read it and if so then figure out how to help you.
alosca
Posts: 52
Joined: 2010-03-04T17:54:57-07:00
Authentication code: 8675308
Location: Pasadena, California

Re: How to handle tiff with 2 channels only

Post by alosca »

Thanks for replying and willingness to take a look at the problem and apologies for not posting an example image sooner.
You can find the image.tif file mentioned in my previous post here: http://www.imagenoir.com/magick/
Hopefully there is a way IM can handle such images.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to handle tiff with 2 channels only

Post by fmw42 »

IM sees only one channel (gray) which is totally black.

identify -verbose image.tif
Image: image.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 1056x1056+0+0
Resolution: 72x72
Print size: 14.6667x14.6667
Units: PixelsPerInch
Type: Bilevel
Base type: Bilevel
Endianess: MSB
Colorspace: RGB
Depth: 16/1-bit
Channel depth:
gray: 1-bit
Channel statistics:
Gray:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
kurtosis: 0
skewness: 0

Histogram:
1115136: ( 0, 0, 0) #000000000000 black
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 1056x1056+0+0
Dispose: Undefined
Iterations: 0
Compression: LZW
Orientation: TopLeft
Properties:
date:create: 2010-08-23T10:13:16-07:00
date:modify: 2010-08-22T23:05:42-07:00
signature: 5f8ca2371c3a1943f73bad086b56d89102c570c5e7bd6fbde7a191aebc7609fe
tiff:endian: lsb
tiff:photometric: RGB
Artifacts:
verbose: true
Tainted: False
Filesize: 4.461MB
Number pixels: 1.115M
Pixels per second: 2.104M
User time: 0.170u
Elapsed time: 0:01.529
Version: ImageMagick 6.6.3-8 2010-08-20 Q16 http://www.imagemagick.org
identify: Sorry, can not handle RGB image with Color channels=2. `image.tif' @ error/tiff.c/TIFFErrors/494.


Sorry I did not notice this earlier:
convert -separate -channel R image.tif foo.pgm
This syntax is backwards.

convert image -channel R -separate result

see http://www.imagemagick.org/Usage/basics/#cmdline

However, even correcting that does not help.


convert image.tif -channel R -separate tmp.png
convert: Sorry, can not handle RGB image with Color channels=2. `image.tif' @ error/tiff.c/TIFFErrors/494.
Last edited by fmw42 on 2010-08-23T11:06:57-07:00, edited 1 time in total.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: How to handle tiff with 2 channels only

Post by Drarakel »

fmw42 wrote:IM sees only one channel (gray) which is totally black.
That's because ImageMagick (libtiff) can't handle images with two channels. :wink:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to handle tiff with 2 channels only

Post by fmw42 »

Drarakel wrote:
fmw42 wrote:IM sees only one channel (gray) which is totally black.
That's because ImageMagick (libtiff) can't handle images with two channels. :wink:
Right, so neither IM nor libtiff will be able to help him!

Using exiftool:


exiftool -s -ee -g1 -u -n -D image.tif
---- ExifTool ----
- ExifToolVersion : 8.24
---- System ----
- FileName : image.tif
- Directory : .
- FileSize : 4460706
- FileModifyDate : 2010:08:22 23:05:42-07:00
- FilePermissions : 644
---- File ----
- FileType : TIFF
- MIMEType : image/tiff
- ExifByteOrder : II
---- IFD0 ----
254 SubfileType : 0
256 ImageWidth : 1056
257 ImageHeight : 1056
258 BitsPerSample : 16 16
259 Compression : 5
262 PhotometricInterpretation : 2
273 StripOffsets : 8 2230280
277 SamplesPerPixel : 2
279 StripByteCounts : 2230272 2230272
284 PlanarConfiguration : 2
317 Predictor : 2
---- Composite ----
- ImageSize : 1056x1056


I presume

258 BitsPerSample : 16 16

This means two channels?

I would suggest you explore libtiff and see if there are any options to deal with the two channel input format and change it using libtiff.

try one of the libtiff user groups. The main libtiff page is at http://www.libtiff.org/
Post Reply