Problem with -normalize in 7.6.8 for gray scale images

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
rluchin
Posts: 2
Joined: 2012-07-13T06:38:50-07:00
Authentication code: 15

Problem with -normalize in 7.6.8 for gray scale images

Post by rluchin »

Dear all,

I have a script which converts raw date (unsigned 16bit integer) from an MRI maschin to png etc.
I use the command:
convert -endian LSB -size 256x256 -depth 16 -normalize +adjoin gray:$file $outfilename\_%03d.png

Till 6.7.6 (including) I got multiple images all nice scaled.

I upgraded on Windows to 6.7.8.2 and suddendly only the first image was fine, but all the other once were nearly binary. Bright areas white, and lower intensity were black.

An bugfix for my scripts was to switch to
convert -endian LSB -size 256x256 -depth 16 -auto-levl +adjoin gray:$file $outfilename\_%03d.png

But I think, there went something wrong during one of the the latest improvments.

Thanks for your help.

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

Re: Problem with -normalize in 7.6.8 for gray scale images

Post by fmw42 »

Don't know about the normalize issue?

But you have a typo?
convert -endian LSB -size 256x256 -depth 16 -auto-levl +adjoin gray:$file $outfilename\_%03d.png
It should be -auto-level not -auto-levl

-normalize is a subset of -contrast-stretch, so you may want to check that. See

http://www.imagemagick.org/script/comma ... st-stretch
http://www.imagemagick.org/script/comma ... #normalize

Note that as of ImageMagick 6.4.7-0, -normalize is equivalent to -contrast-stretch 2%x1%. (Before this version, it was equivalent to -contrast-stretch 2%x99%).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem with -normalize in 7.6.8 for gray scale images

Post by anthony »

Also actually read in the image BEFORE using -auto-level

+adjoin being an output option should be just before the output (not that it should matter a lot).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rluchin
Posts: 2
Joined: 2012-07-13T06:38:50-07:00
Authentication code: 15

Re: Problem with -normalize in 7.6.8 for gray scale images

Post by rluchin »

Thanks for the replys.
auto-level was a typo sorry.

Anyway even after moving +adjoin further to the end and with using -contrast-stretch 0 there is still a error in my opinion.

To illustrate I put the data and the converted images to my webpage:

OK is the command with the old Image magick 6.7.6:
"C:\Program Files (x86)\ImageMagick-6.7.6-Q16\convert.exe" -endian LSB -size 256x256 -depth 16 -normalize gray:test.rec +adjoin test_%03d.png
Images: http://www.mr.ethz.ch/~rluchin/image_ma ... ize/6_7_6/

With the newest version 6.7.8 it does not work (first image OK, rest have bad dynamic range)
"C:\Program Files (x86)\ImageMagick-6.7.6-Q16\convert.exe" -endian LSB -size 256x256 -depth 16 -normalize gray:test.rec +adjoin test_%03d.png
Images: http://www.mr.ethz.ch/~rluchin/image_ma ... ize/6_7_8/

Bad images also with -contrast-stretch
"C:\Program Files (x86)\ImageMagick-6.7.8-Q16\convert.exe" -endian LSB -size 256x256 -depth 16 -contrast-stretch 0 gray:test.rec +adjoin test_%03d.png
Images: http://www.mr.ethz.ch/~rluchin/image_ma ... t_stretch/

OK if I switch to auto-level
"C:\Program Files (x86)\ImageMagick-6.7.8-Q16\convert.exe" -endian LSB -size 256x256 -depth 16 -auto-level gray:test.rec +adjoin test_%03d.png
Images: http://www.mr.ethz.ch/~rluchin/image_ma ... uto_level/

The raw data to test and the commands:
http://www.mr.ethz.ch/~rluchin/image_ma ... /raw_data/

For me the problem is solve by switching to autolevel, but I still think there is a bug in the software, which may be a problem to others in future.

To the used versions:
6.7.8-2
"c:\Program Files (x86)\ImageMagick-6.7.8-Q16\convert.exe" -version
Version: ImageMagick 6.7.8-2 2012-07-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

6.7.6-5
"c:\Program Files (x86)\ImageMagick-6.7.6-Q16\convert.exe" -version
Version: ImageMagick 6.7.6-5 2012-04-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Kind regards
Roger
RobertSharp
Posts: 2
Joined: 2012-09-12T00:39:13-07:00
Authentication code: 67789

Re: Problem with -normalize in 7.6.8 for gray scale images

Post by RobertSharp »

Hi

I have this problem too. Just regressed from 6.7.8.7 to 6.7.6.4 and everything works as expected.

I use normalize while creating a simple button:

Code: Select all

/usr/bin/convert /tmp/tile.png -fill gray45 -colorize 100% -raise 4 -normalize -blur 0x4 grey_norm.png
with 6.7.6.4 the button has a mid-grey field, goes to white in top left and black in bottom right.
with 6.7.8 the button has a white field and goes to black in bottom right.

Using -contrast-stretch 2%x99% instead of -normalize had no effect (same as if I had not used the option at all).

Hope this helps?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Problem with -normalize in 7.6.8 for gray scale images

Post by magick »

We can reproduce the problem and have a patch in ImageMagick 6.7.9-5 Beta available by sometime tomorrow. In the mean-time add '-colorspace RGB' just before the -normalize option. The -colorspace GRAY option may work as well.
RobertSharp
Posts: 2
Joined: 2012-09-12T00:39:13-07:00
Authentication code: 67789

Re: Problem with -normalize in 7.6.8 for gray scale images

Post by RobertSharp »

Thanks very much.
Post Reply