Page 1 of 1

Convert contrast stretch option

Posted: 2015-07-06T20:28:28-07:00
by diaadi
Hi all,
Is there a difference between "normalize" and
"contrast-stretch" option?
What does the % value mean in contrast-stretch?
For e.g. If I say convert -contrast-stretch 5% inp.tiff output.tiff , what does 5 mean here??

Re: Convert contrast stretch option

Posted: 2015-07-06T21:01:33-07:00
by fmw42
Normalize is contrast-stretch with specific arguments. In contrast-stretch the values are either % counts from either side of the histogram or without the %, actual count values.

So normalize is contrast-stretch 2%x1%, which means clip the bottom 2% of the histogram (at the black side) and clip 1% of the histogram (at the white side). This means count from each end of the histogram that % of counts and get the bin (gray level) at that value and stretch the histogram such that the bottom value goes to black and the top value goes to white.

Re: Convert contrast stretch option

Posted: 2015-07-07T04:57:21-07:00
by diaadi
fmw42,
Could you elaborate a litte more ?
What is getting "bin" ? Also if I simple give single number like just 5% (and not 5%x1% or 5%x2%) what would be the default value for 2nd number ?

Re: Convert contrast stretch option

Posted: 2015-07-07T09:52:00-07:00
by fmw42
A histogram is divided into bins that may contain more than one graylevel. So a bin is a group of 1 or more consecutive graylevels for which all the counts are combined. Lets say your image has 1024 graylevels (colors), then for a 256 bin histogram, each bin would accumulate counts from 4 successive graylevels. Please read up on histograms.

If you only provide one value, it is used for both the low and high ends of the histogram. So if you provide 2% only, then it is like 2%x2%.

Re: Convert contrast stretch option

Posted: 2015-07-09T04:28:08-07:00
by diaadi
Thanks for the reply fmw42.