Seemingly random negative images.

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
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Seemingly random negative images.

Post by RQuadling »

Hi.

I'm processing multipage TIFF faxes.

The processing involves splitting the document into single pages (Cygwin's TIFFSPLIT.EXE) and adding a banner to the top and bottom of the page (Image Magick's CONVERT.EXE).

The problem I'm getting is that the ColorMap in the resulting TIF files is inconsistent.

Below are 2 consecutive files. Both operated on in the same way.

Code: Select all

Image: 2009-09-29__08-19__Page-0025__67S9M0B.tif
  Format: TIFF (Tagged Image File Format)
  Class: PseudoClass
  Geometry: 1728x2408+0+0
  Resolution: 204x196
  Print size: 8.47059x12.2857
  Units: PixelsPerInch
  Type: Bilevel
  Base type: Bilevel
  Endianess: MSB
  Colorspace: RGB
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.865593 (0.865593)
      standard deviation: 0.341089 (0.341089)
      kurtosis: 2.59538
      skewness: -2.14368
  Histogram:
    559270: (  0,  0,  0) #000000 black
   3601754: (255,255,255) #FFFFFF white
  Colormap: 2
         0: (  0,  0,  0) #000000 black
         1: (255,255,255) #FFFFFF white
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 1728x2408+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Group4
  Orientation: TopLeft
  Properties:
    date:create: 2009-09-29T08:19:41+01:00
    date:modify: 2009-09-29T08:19:48+01:00
    signature: bf69ed91682961201d6c4bf112814eee2b066312f364cd1580f64a376f3be010
    tiff:document: Z:\Faxes\Received\2009\09\29\2009-09-29__08-19__Page-0025__67S9M0B.tif
    tiff:photometric: palette
    tiff:rows-per-strip: 2408
    tiff:software: ImageMagick 6.5.6-5 2009-09-25 Q8 OpenMP http://www.imagemagick.org
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 93.2kb
  Number pixels: 3.968mb
  Pixels per second: 50.88mb
  User time: 0.031u
  Elapsed time: 0:01
  Version: ImageMagick 6.5.6-5 2009-09-25 Q8 OpenMP http://www.imagemagick.org
and

Code: Select all

Image: 2009-09-29__08-15__Page-0024__5YWMILJ.tif
  Format: TIFF (Tagged Image File Format)
  Class: PseudoClass
  Geometry: 1728x2508+0+0
  Resolution: 204x196
  Print size: 8.47059x12.7959
  Units: PixelsPerInch
  Type: Bilevel
  Base type: Bilevel
  Endianess: MSB
  Colorspace: RGB
  Depth: 1-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    gray:
      min: 0 (0)
      max: 1 (1)
      mean: 0.898321 (0.898321)
      standard deviation: 0.302226 (0.302226)
      kurtosis: 4.94801
      skewness: -2.63591
  Histogram:
    440661: (  0,  0,  0) #000000 black
   3893163: (255,255,255) #FFFFFF white
  Colormap: 2
         0: (255,255,255) #FFFFFF white
         1: (  0,  0,  0) #000000 black
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 1728x2508+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Group4
  Orientation: TopLeft
  Properties:
    date:create: 2009-09-29T08:16:29+01:00
    date:modify: 2009-09-29T08:17:08+01:00
    signature: beb7404299155673335d71255e4e5294bf033321a0531e681a613893cb3ff97d
    tiff:document: Z:\Faxes\Received\2009\09\29\2009-09-29__08-15__Page-0024__5YWMILJ.tif
    tiff:photometric: palette
    tiff:rows-per-strip: 2508
    tiff:software: ImageMagick 6.5.6-5 2009-09-25 Q8 OpenMP http://www.imagemagick.org
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 39.1kb
  Number pixels: 4.133mb
  Pixels per second: 65.6mb
  User time: 0.047u
  Elapsed time: 0:01
  Version: ImageMagick 6.5.6-5 2009-09-25 Q8 OpenMP http://www.imagemagick.org
I now have several hundred negative images. Strangely though, Paint Shop Pro doesn't see the negative, but Microsoft Windows Picture and Fax Viewer does.

The faxes go to an external business and they are complaining.

How can I set the ColorMap appropriately?

The command I'm using to process the tiff file is

Code: Select all

CONVERT "Z:\Faxes\received\2009\09\29\2009-09-29__15-24__Page-0828__5O9MTJU1.tif" -resize 1728 -bordercolor black -fill black -border 0x100 -draw "fill white  stroke black  stroke-width 1  rectangle 0,0 1727,99  fill black  rectangle 0,0 339,99  rectangle 1420,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '2009/09/29'  text 88,94 '15:24'  font-size 140  text 1422,94 '0828'  fill white  font-size 110  stroke black  text 430,76 '5 O 9 M T J U 1'" -rotate 180 -draw "fill white  stroke black  stroke-width 1  rectangle 0,0 1727,99  fill black  rectangle 0,0 339,99  rectangle 1420,0 1727,99  fill black  font Consolas  font-size 60  stroke white  stroke-width 4  text 5,44 '2009/09/29'  text 88,94 '15:24'  font-size 140  text 1422,94 '0828'  fill white  font-size 110  stroke black  text 430,76 '5 O 9 M T J U 1'" -rotate 180 -units PixelsPerInch -density 204x196 -define quantum:polarity=min-is-black -monochrome -type Bilevel -compress Group4 "Z:\Faxes\Received\2009\09\29\2009-09-29__15-24__Page-0828__5O9MTJU1.tif"
An upgrade was done recently and no one knows what the previous version was.

The important parts of the command are

Code: Select all

-define quantum:polarity=min-is-black -monochrome -type Bilevel -compress Group4
.

I'm wondering if the order is important here.

Should -define be in a different position to the other settings?

Any help would be appreciated.

Regards,

Richard Quadling.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Seemingly random negative images.

Post by magick »

Post a URL to two different TIFF images that when using the same command produce two different results (one positive and one negative). We need to reproduce the problem before we can offer a solution.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Seemingly random negative images.

Post by RQuadling »

Hi.

I've created a RAR archive containing the following files.

Original images provided by GFI FaxMaker.
2009_09_30_08_12_tg4C5C60.tif (ends up as the normal files)
2009_09_30_08_14_tg4DDC20.tif (ends up as the reversed files)

Single page per image files.
normal_aaa.tif
normal_aab.tif
normal_aac.tif
normal_aad.tif
normal_aae.tif
reversed_aaa.tif
reversed_aab.tif
reversed_aac.tif
reversed_aad.tif

Files after processing.
normal_BN4BLXO.tif
normal_BVZYM6R.tif
normal_C4VLMF7.tif
normal_CDR8MOI.tif
reversed_CMMVOHS.tif
reversed_CVIIOR7.tif
reversed_D4E5OZN.tif
reversed_DD9SP8Y.tif

Batch file to go through all the steps.
MakeProblem.bat


The final tif files are fed into a work queue where the data entry operators get the next image in the queue to process. Currently they are having some issues - as you can imagine.

The file is 820K and is available at http://ee-stuff.com/Problem20090930084506.rar.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Seemingly random negative images.

Post by RQuadling »

If I change the -compress option to LZW, the image is correct (and the colormap is in the same order).

At this stage, I don't know if this would have an impact on anything else.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Seemingly random negative images.

Post by magick »

Do you need the colormap? If not, change
  • -monochrome -type Bilevel
to
  • -type Bilevel -type truecolor -type grayscale
With a colormap the images appear to meet the TIFF specification. If a particular viewer displays them in reverse video, the bug with be with that viewer and not ImageMagick.

If a colormap is required it seems that you are asking for an option that will sort the colormap by intensity so you get the black-white colormap rather than the current white-black.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Seemingly random negative images.

Post by RQuadling »

I don't know if I need the colour map.

The viewer is Microsoft Windows Picture and Fax Viewer (WPFV). So, not the cutting edge in technology.

But this has been working fine for years.

It is the recent upgrade which is making the difference.

The ordering of the colour map seems to indicate the problem.


What I'm confused by is why is the colour map seemingly the wrong way the round for images which are shown as negative.

Can you tell me what determines the order of the colour map?

Also, before I use ImageMagick on these images, they are fine. And not all the images are negative, just some.

Having said that, why does Paint Shop Pro not show them as negative, but Explorer's thumbnail view and WPFV show them negative?


I'll try the new options tomorrow (at home at the moment) and come back with my results.

As I have to fix all the images I've already got, can you suggest any technique (other than visual inspection of over 3000 images) I can use to determine the negative images?


Regards,

Richard.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Seemingly random negative images.

Post by fmw42 »

Look in the verbose info: to see what might be different in the input images. Perhaps some flag about MSB or LSB or about background black or white or some tiff flag that tells whether white or black. Compare the verbose info of one input that works to another input that does not and look for differences.

From your verbose info above, I see that one has a colormap with white as entry 0 and the other has a colormap with black as entry 0. That may be the cause of the problem.

identify -verbose input

With regard to telling which ones need to be negated, if these are text, then one might expect there to be more white than black. So the histogram should identify whether white is predominant or black is predominant. You can use that then to tell which need to be negated.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Seemingly random negative images.

Post by RQuadling »

Hello fmw42.

The original images seem to be identical with regard to identity -verbose (ignoring dimensions and stats related data).

Output of identity -verbose of the original file which generates normal images
Output of identity -verbose of the original file which generates negated images


The first image from each split also seem to be identical.

Output of identity -verbose of the first of the split normal image
Output of identity -verbose of the first of the split negated image


For the sake of testing, I'm going to build the list of images with the following types to see if the order is important.

Code: Select all

[no type]
-type bilevel
-type bilevel -type truecolor
-type bilevel -type grayscale
-type bilevel -type optimize
-type bilevel -type truecolor -type grayscale
-type bilevel -type truecolor -type optimize
-type bilevel -type grayscale -type truecolor
-type bilevel -type grayscale -type optimize
-type bilevel -type optimize -type grayscale
-type bilevel -type optimize -type truecolor
-type bilevel -type truecolor -type grayscale -type optimize
-type bilevel -type truecolor -type optimize -type grayscale
-type bilevel -type grayscale -type truecolor -type optimize
-type bilevel -type grayscale -type optimize -type truecolor
-type bilevel -type optimize -type grayscale -type truecolor
-type bilevel -type optimize -type truecolor -type grayscale
-type grayscale
-type grayscale -type bilevel
-type grayscale -type truecolor
-type grayscale -type optimize
-type grayscale -type bilevel -type truecolor
-type grayscale -type bilevel -type optimize
-type grayscale -type truecolor -type bilevel
-type grayscale -type truecolor -type optimize
-type grayscale -type optimize -type bilevel
-type grayscale -type optimize -type truecolor
-type grayscale -type bilevel -type truecolor -type optimize
-type grayscale -type bilevel -type optimize -type truecolor
-type grayscale -type truecolor -type bilevel -type optimize
-type grayscale -type truecolor -type optimize -type bilevel
-type grayscale -type optimize -type bilevel -type truecolor
-type grayscale -type optimize -type truecolor -type bilevel
-type optimize
-type optimize -type bilevel
-type optimize -type grayscale
-type optimize -type truecolor
-type optimize -type bilevel -type truecolor
-type optimize -type bilevel -type grayscale
-type optimize -type truecolor -type bilevel
-type optimize -type truecolor -type grayscale
-type optimize -type grayscale -type bilevel
-type optimize -type grayscale -type truecolor
-type optimize -type bilevel -type truecolor -type grayscale
-type optimize -type bilevel -type grayscale -type truecolor
-type optimize -type truecolor -type bilevel -type grayscale
-type optimize -type truecolor -type grayscale -type bilevel
-type optimize -type grayscale -type bilevel -type truecolor
-type optimize -type grayscale -type truecolor -type bilevel
-type truecolor
-type truecolor -type bilevel
-type truecolor -type grayscale
-type truecolor -type optimize
-type truecolor -type bilevel -type grayscale
-type truecolor -type bilevel -type optimize
-type truecolor -type grayscale -type bilevel
-type truecolor -type grayscale -type optimize
-type truecolor -type optimize -type bilevel
-type truecolor -type optimize -type grayscale
-type truecolor -type bilevel -type grayscale -type optimize
-type truecolor -type bilevel -type optimize -type grayscale
-type truecolor -type grayscale -type bilevel -type optimize
-type truecolor -type grayscale -type optimize -type bilevel
-type truecolor -type optimize -type bilevel -type grayscale
-type truecolor -type optimize -type grayscale -type bilevel
Sure, overkill, but with identity not providing any differences, it seems to be related to a type.

Back in a while.
RQuadling
Posts: 38
Joined: 2006-12-04T02:48:33-07:00
Location: Plymouth, Devon, UK
Contact:

Re: Seemingly random negative images.

Post by RQuadling »

After generating 594 images I think I've found another bug.

Taking a TIF image and using convert with the last type set as

Code: Select all

convert normal_aaa.tif -type truecolor normal_aaa_duff.tif
(that is with no other parameters) results in a corrupt image.

So,

Code: Select all

convert input.tif -type a -type b -type c -type truecolor output.tif
results in a corrupt image.


And it seems that using

Code: Select all

convert -type truecolor -type bilevel
results in normal images and the smallest filesize (as compared against all 594 images) and no reversed images. Maybe by only a few bytes, but consistently so.

None of the images which are produced using

Code: Select all

convert -type truecolor -type bilevel
have a colormap entry when using identify.

So, thank you for your help.

I'm really not sure what is going on, but I've got things working.

If anyone does find the reason for the reversal of the colormap, then I'd appreciate a call.

Thank you.

Richard.
shawn123

Re: Seemingly random negative images.

Post by shawn123 »

hi RQuadling,..
its very great informative link shared here useful one for many others who needs this kind of stuff,…
i appreciate this effort,..
thanks,..
Post Reply