Page 1 of 1

LinearStretch() works strange if compared with bin/convert

Posted: 2017-11-11T03:40:36-07:00
by tem
tested on:
ImageMagick7-nox11-7.0.7.4
ImageMagick-nox11-6.9.8.9_1,1

bin/convert manual:
-linear-stretch black-point{xwhite-point}{%}

in perl it would be:
$img->LinearStretch('levels' => AxB, 'black-point' => double, 'white-point' => double);

the results are different and i can't make any arguments for LinearStretch() for result to match to bin/convert's result.

diff page with images:
http://zznine.com/convert-linear-stretch/diff.html

Question:
what should be arguments for LinearStretch() to match:
1) bin/convert -linear-stretch AxB
2) bin/convert -linear-stretch AxB%

Re: LinearStretch() works strange if compared with bin/convert

Posted: 2017-11-11T04:32:26-07:00
by snibgo
I don't use Perl, but looking at Magick.xs, I think the first part ("rho") of the string argument is ignored. So if you have "levels=30%x70%", the 30% is ignored, and zero is used for the black point. It looks as if "black-point" and "white-point" should work, but they need to be the number of pixels, not a percentage.

Re: LinearStretch() works strange if compared with bin/convert

Posted: 2017-11-12T01:35:15-07:00
by tem
if bin/convert can calculate % for both black and white argument, it should be the same for perl.
So it would do "the same" image transformation as bin/convert.
Otherwise it is confusing.