Page 1 of 1

masked compose plus vs compose multiply, then plus

Posted: 2011-04-19T12:35:53-07:00
by hwttdz
I tried two different ways of getting what I expect to be the same output, the first is:

C = A * mask;
output = C + B;

or in nearer IM syntax

composite -compose multiply mask A C
composite -compose plus C B output

and the second is

convert B A mask -compose plus -composite output

which should give B + A * mask, which is the same as above. However the images produced (while similar) are different. compare -metric rmsd gives 807.5 (0.012), or if I view the images in sequence in a slide show there is a clear difference.

Re: masked compose plus vs compose multiply, then plus

Posted: 2011-04-19T12:42:19-07:00
by fmw42
hwttdz wrote:I tried two different ways of getting what I expect to be the same output, the first is:

C = A * mask;
output = C + B;

or in nearer IM syntax

composite -compose multiply mask A C
composite -compose plus C B output

and the second is

compose B A mask -compose plus -composite

which should give B + A * mask, which is the same as above. However the images produced (while similar) are different. compare -metric rmsd gives 807.5 (0.012), or if I view the images in sequence in a slide show there is a clear difference.

I believe your syntax (composite -compose multiply mask A C) is flawed. see http://www.imagemagick.org/Usage/compose/#compose

composite {overlay} {background} [{mask}] [-compose {method}] {result}

Personally, I prefer to use convert ... -compose ... -composite , since you can do all steps in one command.

Re: masked compose plus vs compose multiply, then plus

Posted: 2011-04-19T13:07:18-07:00
by hwttdz
Sorry, I'm actually using convert -compose -composite (as suggested) and mangled it up in my attempt to post a minimum working example. So the ordering is correct. I'll try to update in original post.

I've switched to ppm from jpg and my error has gone down from 807.5 (0.012) to 667.7 (0.010). The difference between these two images is still very visible however.

Extending the above suggestion of using convert -compose -composite and combining commands (and using ppm for intermediate steps) I have continued to reduce the error. There is now no visibly apparent difference between the images. Thanks.

Re: masked compose plus vs compose multiply, then plus

Posted: 2011-04-19T14:40:50-07:00
by fmw42
best to post your actual commands in a new reply rather than change what you have above or the other replies will confuse people

You can edit your original post and put a link to see the correction below