contrast-stretch questions

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
jbrandon5

contrast-stretch questions

Post by jbrandon5 »

I have some error-difference images with very small errors, so they show up as just black. I want to stretch the low-end range so that the errors become visible.

The -normalize option works for this, and makes the largest error value show up as white. However, I want to adjust all the images by the same value, so I was trying to do this with -contrast-stretch.

The documentation is a bit confusing for the option - can anyone help explain what the values mean for -contrast-stretch? Also, what is the difference from -linear-stretch?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: contrast-stretch questions

Post by anthony »

-contrast-stretch and -normalize are the same function.
By defalt normalize find the highest and lowest color value in any RGB channel
then moves inward by 1% of the color range (to account for JPEG 'ringing' color distortions) At this point all three color channels are then stretched.
The contrast-stretch does the same thing but you can specify the amount of inward movement. often it is used with a '0' argument to prevent color 'clipping'.

For exact controls, you can either use -linear-stretch which you provide a percentage to move the black and white point inward by. Or -level which directly defines the color levels.

Of course you can also use your own histogram adjsutment function via -fx

See IM Examples, Color Modifications.

Note... Fred Weinhaus, is currently working on a new set of general histogram handling methods, as a series of shell scripts. These will eventually be built into IM to revolutionize general color controls within IM.

This includes... linear stretching and de-contrast handling, auto-leveling using various methods to select the black and white points which is more like the photoshop/gimp auto-leveling methods. LUT histogram color replacements and 'curves' using various methods of fitting the functions to control points. and probably lots more.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply