Page 1 of 1

ImageMagick convert TIF to b&w - result blank image

Posted: 2011-02-05T05:13:00-07:00
by olos
Hello,

I have two tif-s that are scans from Zeutschel Omniscan 12 and saved via Adobe Photoshop CS5 Windows. This 2 files (links below) are very similar (the same process of scanning and saving) but one s1001.tif converts to black and white with no problems using -type bilevel option. The second one s1002.tif always became blank after conversion

I tried converting this file using XnView and there is no problem. Converting image to png using convert exe and then converting to b&w using -type bilevel give the same results - blank image.

I found script in one of the thread which is combination of options like
-type bilevel -type grayscale -type optimize etc. (63 combinations) but only grayscale conversion is ok.

Can you give me a hint what is the difference between this two images that cause this behavior ?

ImageMagick versions tested

Windows XP 6.3.3 Q16 - image s1002 after conversion is all black
Windows 7 6.6.6-10 Q16 - image s1002 after conversion is all white

Tested images (about 20MB each)
http://www.webdysk.net/s1001.tif
http://www.webdysk.net/s1002.tif


test script
http://www.webdysk.net/convert.txt

Thanks in advance for help
Regards
Tom

Re: ImageMagick convert TIF to b&w - result blank image

Posted: 2011-02-05T11:10:39-07:00
by fmw42
I get an error message on IM 6.6.7.4 Q16 Mac OSX Tiger

convert s1002.tif -type bilevel s1002_bl.tif
convert: s1002.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/706.

Looks like your tiffs are corrupt in some way.

The result is all white but the type is bilevel

identify -verbose s1002_bl.tif
Image: s1002_bl.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 2405x2947+0+0
Resolution: 300x300
Print size: 8.01667x9.82333
Units: PixelsPerInch
Type: Bilevel
Base type: Bilevel
Endianess: MSB
Colorspace: RGB
Depth: 1-bit
Channel depth:
gray: 1-bit
Channel statistics:
Gray:
min: 1 (1)
max: 1 (1)
mean: 1 (1)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
Histogram:
7087535: (255,255,255) #FFFFFF white

Re: ImageMagick convert TIF to b&w - result blank image

Posted: 2011-02-06T04:15:12-07:00
by olos
Hello,

Thanks for replay.
fmw42 wrote:I get an error message on IM 6.6.7.4 Q16 Mac OSX Tiger

convert: s1002.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/706.
This error is well known exception which is thrown by the libTIFF. IPTC profile generated by Photoshop CS4 or CS5 software is not processed well by libTIFF. The question is if this have influence on conversion to b&v. Evan if I save this image via XnView to "proper" tif or png result after convert will be the same (white page). Strangeā€¦

I've generated (using identify tool) report for both files and compared them and the main difference is in Channel statistics section. Maybe this is the source of problem. But i have no such a deep knowledge of image processing to find the solution...

Thanks for help

Regards
Tom

PS. below identify results for both files

Code: Select all

identify.exe -verbose s1001.tif
Image: s1001.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 2220x2947+0+0
  Type: TrueColor
  Endianess: MSB
  Colorspace: RGB
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Red:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 204.21 (0.800822)
      Standard deviation: 45.9655 (0.180257)
    Green:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 185.63 (0.727961)
      Standard deviation: 44.9793 (0.176389)
    Blue:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 161.644 (0.633897)
      Standard deviation: 40.5163 (0.158887)
  Colors: 459023
  Rendering intent: Undefined
  Resolution: 300x300
  Units: PixelsPerInch
  Filesize: 19.3765mb
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 2220x2947+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: TopLeft
  Artist: Zeutschel Omniscan 12
  Signature: d04021f1c7cc9a09231fd0b9cedfdb8d4b447abacf9641699c630c0dd22b01fd
  Software: Adobe Photoshop CS5 Windows
  Timestamp: 2011:01:28 12:42:40
  Profile-8bim: 6984 bytes

Code: Select all

identify.exe -verbose s1002.tif
Image: s1002.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 2405x2947+0+0
  Type: TrueColor
  Endianess: MSB
  Colorspace: RGB
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Red:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 201.86 (0.791608)
      Standard deviation: 42.8434 (0.168014)
    Green:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 179.257 (0.702969)
      Standard deviation: 42.5225 (0.166755)
    Blue:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 152.466 (0.597906)
      Standard deviation: 36.8363 (0.144456)
  Colors: 469110
  Rendering intent: Undefined
  Resolution: 300x300
  Units: PixelsPerInch
  Filesize: 20.9372mb
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 2405x2947+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: TopLeft
  Artist: Zeutschel Omniscan 12
  Signature: 3f0b6a4f48cec9cc4507a4e1fb2cbd13bc43bbd64204328f390f09a541144eed
  Software: Adobe Photoshop CS5 Windows
  Timestamp: 2011:01:28 12:48:43
  Profile-8bim: 7844 bytes

Re: ImageMagick convert TIF to b&w - result blank image

Posted: 2011-02-06T11:49:54-07:00
by fmw42
My result was type bilevel but the resulting image was all white. I think your image statistics are such that you need to specify a unique threshold level. Try

convert s1002.tif -threshold 50% s1002_t50.tif

The results in showing most of the text as black on white background and is type bilevel.

Alternately, try using -lat (local area thresholding)

Re: ImageMagick convert TIF to b&w - result blank image

Posted: 2011-02-14T01:51:38-07:00
by olos
Thank you very much for help

This combination

Code: Select all

convert s1002.tif -threshold 50% s1002_t50.tif
is the solution. I tested more than 1000 tiff-s (about 30GB) with different threshold value and there is no problem (threshold set to 56 - 60% give best results for my images).

Once again thanks for help.

Regards
Tom