[RESOLVED] possible bug -evaluate-sequece sum IM 6.8.8.0
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
[RESOLVED] possible bug -evaluate-sequece sum IM 6.8.8.0
convert -version
Version: ImageMagick 6.8.8-0 Q16 x86_64 2013-12-26 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib
I am not sure if this is a bug or some limitation, but I cannot get -evaluate-sequence sum or add to produce a "correct" result when there is an alpha channel in each image.
I even tried adding -alpha on -channel rgba or -alpha on -channel rgba,sync but neither helped.
Here is what I tried:
Input:
This does not work correctly:
convert tmpR.png tmpG.png tmpB.png -evaluate-sequence sum tmpRGB1.png
This does not work correctly:
convert tmpR.png tmpG.png tmpB.png -evaluate-sequence add tmpRGB2.png
However, this alternate command works fine:
convert tmpR.png tmpG.png -compose plus -composite tmpB.png -compose plus -composite tmpRGB3.png
Is this a bug or some limitation of -evaluate-sequence sum or add?
Or am I not using the right argument?
Version: ImageMagick 6.8.8-0 Q16 x86_64 2013-12-26 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib
I am not sure if this is a bug or some limitation, but I cannot get -evaluate-sequence sum or add to produce a "correct" result when there is an alpha channel in each image.
I even tried adding -alpha on -channel rgba or -alpha on -channel rgba,sync but neither helped.
Here is what I tried:
Input:
This does not work correctly:
convert tmpR.png tmpG.png tmpB.png -evaluate-sequence sum tmpRGB1.png
This does not work correctly:
convert tmpR.png tmpG.png tmpB.png -evaluate-sequence add tmpRGB2.png
However, this alternate command works fine:
convert tmpR.png tmpG.png -compose plus -composite tmpB.png -compose plus -composite tmpRGB3.png
Is this a bug or some limitation of -evaluate-sequence sum or add?
Or am I not using the right argument?
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
The 'add' and 'sum' operators, adds the three images together then clamps. So its
If you feel the algorithm should behave differently, let us know.
- clamp(R1+R2+R3)
clamp(G1+G2+G3)
...
If you feel the algorithm should behave differently, let us know.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
Part of the issue was that the transparent parts were transparent white. So by changing the transparent areas to none (transparent black), I get closer. But I do not understand why the fully opaque areas (where red, green and blue overlap) in the combined image turns transparent rather than white and transparent parts turn opaque black. This is very odd. Perhaps it has to do with how transparency is handled or not handled.
convert tmpR.png tmpG.png tmpB.png -background none -alpha background -evaluate-sequence sum tmpRGB_none.png
It is not urgent, since I have a workaround. So I am just trying to understand and make sure it is working properly when all 3 images have transparent regions.
So how is the alpha channel included in -evaluate-sequence results?
convert tmpR.png tmpG.png tmpB.png -background none -alpha background -evaluate-sequence sum tmpRGB_none.png
It is not urgent, since I have a workaround. So I am just trying to understand and make sure it is working properly when all 3 images have transparent regions.
So how is the alpha channel included in -evaluate-sequence results?
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.8-1 Beta, available by sometime tomorrow. Thanks.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
I do not think we are getting the right results still in IM 6.8.8.1 Q16 Mac OSX. It is missing the opaque red and yellow areas. I am not sure if this is still a bug or just the way -evaluate-sequence algorithm differs from using two -compose plus -composite operations as in my first post.
Here is my test using the same input images as above.
convert tmpR.png tmpG.png tmpB.png -background none -alpha background -evaluate-sequence sum tmpRGB_none2.png
The expected results should look as follows:
Here is my test using the same input images as above.
convert tmpR.png tmpG.png tmpB.png -background none -alpha background -evaluate-sequence sum tmpRGB_none2.png
The expected results should look as follows:
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
The add op of the -evaluate-sequence is purely mathematical. Take location 102,101, for example. The R image is 255,0,0. Whereas the G and B images are 255,255,255 at that location. Adding these together as clamp(R1+R2+R3), clamp(G1+G2+G3), etc., returns 255,255,255, or white, not red as you would expect. The -composite Plus op scales by the alpha channel to get the desired result (transparent white is mathematically 0), the -evaluate-sequence treats the channels independently.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
The white part is fine. I am more concerned about the red and yellow parts.
I believe you may have overlooked the -background black (or none) -alpha background in the command so that where there is only red and the other two images are transparent, the underlying values should be r=255,g=0,b=0 which should produce red. Likewise where there is red and green and blue is transparent, r=255,g=255,b=0 and the result should be yellow.
convert tmpR.png tmpG.png tmpB.png -background black -alpha background -evaluate-sequence sum tmpRGB_none3.png
What I am not sure about is how the alpha channel affects the addition process. If one or two images are transparent and the other is opaque as in the red area of the correct result, will -evaluate-sequence make it transparent or opaque. What I may be incorrectly expecting is that the only transparent part should be where all 3 images are transparent. That would be the case if the alpha channels were simply added together or used the largest value.
I believe you may have overlooked the -background black (or none) -alpha background in the command so that where there is only red and the other two images are transparent, the underlying values should be r=255,g=0,b=0 which should produce red. Likewise where there is red and green and blue is transparent, r=255,g=255,b=0 and the result should be yellow.
convert tmpR.png tmpG.png tmpB.png -background black -alpha background -evaluate-sequence sum tmpRGB_none3.png
What I am not sure about is how the alpha channel affects the addition process. If one or two images are transparent and the other is opaque as in the red area of the correct result, will -evaluate-sequence make it transparent or opaque. What I may be incorrectly expecting is that the only transparent part should be where all 3 images are transparent. That would be the case if the alpha channels were simply added together or used the largest value.
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
Ok, got it. The problem is that we must treat the channel as alpha rather than opacity. With the latest patch, it returns the expected results.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
OK, not urgent, but let me know when it is in the 6.8.8.2 beta. I just tried and it does not seem to be there or gives the same results as before. Thanks
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
Try now. It take a few minutes to build a new release.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug -evaluate-sequece sum IM 6.8.8.0 Q16 Mac OS
Works fine now in the latest 6.8.8.2 beta. Thanks