Page 1 of 1

[RESOLVED] Possible bug using mpc vs either clones or mpr

Posted: 2018-01-19T16:04:59-07:00
by fmw42
.
I am using IM 7.0.7.21 Q16 Mac OSX Sierra. I am trying to do a particular computation that requires HDRI to permit negative values. I get one result saving separate steps to mpc and another result when trying to make it into one command line using either mpr: or clones. Reference: https://stackoverflow.com/questions/483 ... ize-in-ima

Code: Select all

T="65000"
sigma=5
magick logo: I.mpc
magick I.mpc -blur 0x$sigma G.mpc
magick I.mpc G.mpc +swap -define compose:clamp=off -compose minus -composite \
G.mpc +swap -define compose:clamp=off -compose divide -composite D.mpc
M=`magick D.mpc D.mpc -define compose:clamp=off -compose multiply -composite \
-evaluate pow 0.5 -evaluate multiply $T -format "%[fx:maxima]" info:`
M2=`magick xc: -format "%[fx:2*$M]" info:`
magick D.mpc -evaluate add $M -evaluate divide $M2 -evaluate multiply $T output.png
Image



But when doing either:

Code: Select all

T="65000"
sigma=5
magick \
\( logo: -write mpr:imgI +delete \) \
\( mpr:imgI -blur 0x$sigma -write mpr:imgG +delete \) \
\( mpr:imgI mpr:imgG +swap -define compose:clamp=off -compose minus -composite \
mpr:imgG +swap -define compose:clamp=off -compose divide -composite -write mpr:imgD +delete \) \
\( mpr:imgD mpr:imgD -define compose:clamp=off -compose multiply -composite \
-evaluate pow 0.5 -evaluate multiply $T \) \
\( mpr:imgD -evaluate add "%[fx:v.maxima]" -evaluate divide "%[fx:2*v.maxima]" \
-evaluate multiply $T \) -delete 0 output2.png
or

Code: Select all

T="65000"
sigma=5
magick \
logo: \
\( -clone 0 -blur 0x$sigma \) \
\( -clone 0,1 +swap -define compose:clamp=off -compose minus -composite \
-clone 1 +swap -define compose:clamp=off -compose divide -composite \) \
-delete 0,1 \
\( -clone 0 -clone 0 -define compose:clamp=off -compose multiply -composite \
-evaluate pow 0.5 -evaluate multiply $T \) \
\( -clone 0 -evaluate add "%[fx:v.maxima]" -evaluate divide "%[fx:2*v.maxima]" \
-evaluate multiply $T \) -delete 0,1 output2.png
I get a different result:

Image


Am I doing something wrong. I suspect the first is correct, but am not sure. It looks like there is clamping somewhere in the latter two results. Or is there a bug here.

Re: Possible bug using mpc vs either clones or mpr

Posted: 2018-01-19T18:38:53-07:00
by magick
Given our limited time availability, we need you to reduce the complexity of your command-line to localize any bug before we can offer a solution. Introduce -write into your command-line to debug and discover under what circumstances your command-lines diverge. Once you have a minimal command-line that shows a divergence of results, post it here and we will investigate further.

Re: Possible bug using mpc vs either clones or mpr

Posted: 2018-01-19T20:12:03-07:00
by fmw42
OK. All the images until the last seem to be the same. The issue seems to be when creating the % escape inside a parenthesis for one image and trying to use it for another image.

Nevertheless, I found a better method that works using -set option as follows:

Code: Select all

T="65000"
sigma=5
im7 magick \
\( logo: -write mpr:imgI +delete \) \
\( mpr:imgI -blur 0x$sigma -write mpr:imgG +delete \) \
\( mpr:imgI mpr:imgG +swap -define compose:clamp=off -compose minus -composite \
mpr:imgG +swap -define compose:clamp=off -compose divide -composite -write mpr:imgD +delete \) \
\( mpr:imgD mpr:imgD -define compose:clamp=off -compose multiply -composite \
-evaluate pow 0.5 -evaluate multiply $T -write mpr:imgT +delete \) \
mpr:imgT -set option:mm "%[fx:maxima]" \
-set option:nn "%[fx:2*maxima]" +delete \
mpr:imgD -evaluate add "%[mm]" -evaluate divide "%[nn]" \
-evaluate multiply $T output3.png
Image