Why does -normalize burn pixels?

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
rling
Posts: 7
Joined: 2007-10-07T16:21:15-07:00

Why does -normalize burn pixels?

Post by rling »

Should this command line burn pixels?

Code: Select all

convert img.jpg -normalize img-normalized.jpg
If so, what are the formulas it uses, and are these formulas listed in the documentation?

If not, there appears to be a bug in normalize....

img.jpg:
Image

img-normalized.jpg:
Image

Version: ImageMagick 6.3.6 10/01/07 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC

Cheers
rling
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Why does -normalize burn pixels?

Post by anthony »

-normalize is a simple command that fails in your case.

It findes the highest and lowest values in the image, takes off 1% more, then scales all the channels so those values are the maximum/minimum for each channel.
It is rather brain dead.

The problem for you is that 1% Instead you will need to use -contrast-stretch 0%, which works in exactly the same way but lets you specify the about of extra inward color to take off.

That will remove the extra 'burn' you see.

When I have finished work on image distortions I will be looking at the color methods developed by Fred Weinhaus in his IM scripts for auto-levels and other image enhancement. See http://www.fmwconcepts.com/fmw/fmw.html

In the mean time you may like to use his scripts for your images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rling
Posts: 7
Joined: 2007-10-07T16:21:15-07:00

Re: Why does -normalize burn pixels?

Post by rling »

Thanks anthony.
I thought this was a bug in normalize but later worked out that it seemed to be equivalent to -contrast-stretch 1%, and often it looks good. I began to use -contrast-stretch 0 instead. It looks like a lot more than 1% of pixels get burned by normalize but I guess when the dynamic range is small that is what has to happen.

Can the percentage use a decimal point? Seems to not work on Windows, I'm wondering if the command shell is doing something to it since % has special meaning on Windows.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Why does -normalize burn pixels?

Post by anthony »

It probably can. most arguments are floats. though if your IM is only a Q8 you may have quantization issues. If a percentage is not specified the value is the quality dependant value.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply