Mathematics, or Blend what working as expected.

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Mathematics, or Blend what working as expected.

Post by anthony »

I was just looking through examples and found that the example showing that Blend and Mathematics with the same arguments, producing the same result.... is NOT producing the same result!

Double checked and they are indeed not producing the same result!

I do not know how long this has been the case or which operator is going wrong...

http://www.imagemagick.org/Usage/compose/#mathematics

And scroll down to the example generating a 'Blend' using 'Mathematics' composition.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Mathematics, or Blend what working as expected.

Post by anthony »

Hmmm.... OKAY... it may be a result of 'colorspace'. Images now using non-linear sRGB, by mathematics being applied without regard to that.

Not certian how to 'fix' the example if that is the case... can't spend that much time on it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mathematics, or Blend what working as expected.

Post by snibgo »

RGB/sRGB isn't the problem, because in your examples you use fully saturated colours, and these have the same values in both colorspaces.

The Blend operation doesn't currently follow the description on your web page, that the colour channels and alpha from the two images are multipled by the percentages and added.

I'm not sure that Blend ever did work like that.

For example, with IM v6.9.5-3, blend_25x75, look at the upper-most red pixels with Gimp or similar. They have values RGBA(100%,0,0,75%).

If they followed your description, the red channel would be: 0.75*100% + 0.25*0% = 75%. (Because the source image compose_plus_GB.png has values RGBA(0,0,0,0) at those pixels.)
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Mathematics, or Blend what working as expected.

Post by anthony »

Yes I see... for pixels that are not overlapping you get the full color with a partial transparency, and not a darker color at partial transparency
In other words the mathematical operator would only apply correctly to overlapping pixels where you have no transparency, just a 'blend' of color.

Stupid.. Example is invalid... removing it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply