Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Unable to display or convert 16-bit TIFF

Help
Alex G
2012-03-21
2013-03-27
  • Alex G
    Alex G
    2012-03-21

    I'm trying to put together a batch process to convert these TIFFs into JPGs.  Many graphics programs (including GM apparently) can't display them properly, though a piece of software called ImageJ can.  Here is the TIFF info from a sample file:

    TIFF Directory at offset 0x99d948 (10082632)
      Image Width: 2452 Image Length: 2056
      Resolution: 300, 300 pixels/inch
      Bits/Sample: 16
      Sample Format: unsigned integer
      Compression Scheme: None
      Photometric Interpretation: min-is-black
      Orientation: row 0 top, col 0 lhs
      Samples/Pixel: 1
      Rows/Strip: 1
      Planar Configuration: single image plane

    gm display shows this as a correctly-sized, but totally blank image.  I've tried rebuilding with the -with-quantum-depth=16 and 32 options, but still get the same results.

     
  • Alex G
    Alex G
    2012-03-21

    Also - graphicsmagick seems to be (incorrectly?) identifying the TIFF as 8-bit - could this be the problem?

    $ gm identify test.tif
    test.tif TIFF 2452x2056+0+0 DirectClass 8-bit 9.6M 0.000u 0:01

     
  • Alex G
    Alex G
    2012-03-21

    More detailed (and contradictory) info from graphicsmagick:

    $ gm identify -verbose test.tif
    Image: test.tif
      Format: TIFF (Tagged Image File Format)
      Geometry: 2452x2056
      Class: DirectClass
      Type: grayscale
      Depth: 1 bits-per-pixel component
      Channel Depths:
        Gray:     1 bits
      Channel Statistics:
        Gray:
          Minimum:                     0.00 (0.0000)
          Maximum:                     0.00 (0.0000)
          Mean:                        0.00 (0.0000)
          Standard Deviation:          0.00 (0.0000)
      Resolution: 300x300 pixels/inch
      Filesize: 9.6M
      Interlace: No
      Orientation: TopLeft
      Background Color: white
      Border Color: #DFDFDF
      Matte Color: #BDBDBD
      Compose: Over
      Dispose: Undefined
      Iterations: 0
      Compression: No
      Timestamp: 0000:75:00 00:127:20

     
  • I suggest trying with a GM configured with -with-quantum-depth=16.  Then try the -normalize option to see if it makes the image look like you see with ImageJ.  If using -normalize "fixes" the problem, then the issue is that the image is 16-bit TIFF but the data is only encoded with very small values such as a range of 0 - 255.  This causes the image to appear as totally black when really there is data present.

    I have seen these sort of images before and they usually come from scientific CCD cameras.

    If you have libtiff's 'tiffinfo' available, then please provide the output of 'tiffinfo filename'.

     
  • Alex G
    Alex G
    2012-03-22

    BFriesen - that's exactly the situation - we're using scientific CCD cams, and the converted images appear solid black.  The tiffinfo output is in my first comment.  I tried using -with-quantum-depth=32 and that did *not* have any effect, but I haven't tried the -normalize switch.  Thanks for your advice.

    Will the -normalize switch also help in converting the images to JPG format, or just in displaying them natively?

     
  • I thought so. I have heard before that ImageJ tries to be helpful by automatically scaling the image so that you are not really seeing the real image.

    You should be able to do

      gm convert infile.tiff -nomalize outfile.jpg

    You can also do more precise linear scaling using something like

      gm convert infile.tiff -operator all Multiply 256 outfile.jpg

    The exact multiplication factor needed is likely image dependent.

    Bob

     
  • Alex G
    Alex G
    2012-03-22

    Thank you very much for the help and advise here!  Everything is working exactly as you say it should, and the multiply operator should help us very much to optimize the quality of the images we're producing.  Much obliged!