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??
Convert contrast stretch option
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert contrast stretch option
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.
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
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 ?
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 ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert contrast stretch option
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%.
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
Thanks for the reply fmw42.