separate modifies channel values!

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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: separate modifies channel values!

Post by snibgo »

"+channel" makes no difference for me:

D:\web\im>%IMG68610%convert rgb_no_alpha.png -channel a -separate +channel -format "%[fx:minima]" info:
0.999893
snibgo's IM pages: im.snibgo.com
User avatar
shadowhand
Posts: 14
Joined: 2013-09-20T17:57:29-07:00
Authentication code: 6789

Re: separate modifies channel values!

Post by shadowhand »

fmw42 wrote:On my Mac OSX IM 6.8.6.10 Q16 it works fine. But try adding +channel after the -separate and see if that makes a difference
It's ImageMagick on Linux that displays the bug, not OSX, but your suggestion did not work:

Code: Select all

# convert rgb-no-alpha.png -channel a -separate +channel -format "%[fx:minima]" info: 
0
Same (incorrect) result as before, still on 6.8.6-9.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

try -channel o, perhaps there was a swapped missed and you are getting the inverse

convert rgb-no-alpha.png -channel o -separate +channel -format "%[fx:minima]" info:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

what do you get from

convert rgb-no-alpha.png -channel a -separate -format "%[min]" info:

or from

convert rgb-no-alpha.png -format "%[fx:minima.a]" info:
User avatar
shadowhand
Posts: 14
Joined: 2013-09-20T17:57:29-07:00
Authentication code: 6789

Re: separate modifies channel values!

Post by shadowhand »

Code: Select all

# convert rgb-no-alpha.png -channel a -separate -format "%[min]" info:
3.4e+38
# convert rgb-no-alpha.png -format "%[fx:minima.a]" info:
1.33333e+36
# convert rgb-no-alpha.png -format "%[fx:minima.a] %[fx:maxima.a]" info:
1.33333e+36 -1.33333e+36
And here's output for an image with an alpha channel:

Code: Select all

# convert rgb-alpha.png -format "%[fx:minima.a] %[fx:maxima.a]" info:
0 1
# convert rgb-alpha-partial.png -format "%[fx:minima.a] %[fx:maxima.a]" info:
0 0.498039
This last result is really interesting, because the image in question should have a minima.a of 0.49 and a maxima of 1, as the image in question is only partially transparent. There isn't a single pixel that is fully transparent, so the minima cannot possibly be zero.
User avatar
shadowhand
Posts: 14
Joined: 2013-09-20T17:57:29-07:00
Authentication code: 6789

Re: separate modifies channel values!

Post by shadowhand »

It seems that using the "o" channel (whatever that is) seems to work better:

Code: Select all

# convert rgb-alpha-partial.png -channel o -separate +channel -format "%[fx:minima] %[fx:maxima]" info:
0.501961 1
This is the correct result for this partially transparent image. But it doesn't work properly for an image with no alpha channel:

Code: Select all

# convert rgb-no-alpha.png -channel o -separate +channel -format "%[fx:minima] %[fx:maxima]" info: 
0 1
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

You must be on a Q32 compile if you get values in scientific notation e+38.

What is your exact IM version and compile Q level on both your systems?
User avatar
shadowhand
Posts: 14
Joined: 2013-09-20T17:57:29-07:00
Authentication code: 6789

Re: separate modifies channel values!

Post by shadowhand »

On Mac OS X 10.8.5:

Code: Select all

% convert --version
Version: ImageMagick 6.8.6-3 2013-07-06 Q16 http://www.imagemagick.org
On Debian Linux (Wheezy):

Code: Select all

# convert --version
Version: ImageMagick 6.8.6-9 2013-09-13 Q8 http://www.imagemagick.org
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

# convert rgb-no-alpha.png -channel a -separate -format "%[min]" info:
3.4e+38
# convert rgb-no-alpha.png -format "%[fx:minima.a]" info:
1.33333e+36
# convert rgb-no-alpha.png -format "%[fx:minima.a] %[fx:maxima.a]" info:
1.33333e+36 -1.33333e+36
These values make no sense for either Q16 or Q8. Looks like your system may be corrupted or has some bad bugs in that version. Seems like no one else is getting that on current versions of IM.

Have you tried re-installing IM?

Have you checked to see that you do not have multiple versions of IM on your systems? Typically /usr/bin or /usr/local/bin? Perhaps you are using an old version of IM different from what you report or there are conflicts.

try

type -a convert


or

/usr/bin/convert -version

and

/usr/local/bin/convert -version
Last edited by fmw42 on 2013-09-23T12:27:20-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

convert -version

should be giving more information, such as whether OpenMP is enabled, whether HDRI is enable and all your delegates.


convert -version
Version: ImageMagick 6.8.6-10 2013-09-23 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps png tiff x xml zlib
User avatar
shadowhand
Posts: 14
Joined: 2013-09-20T17:57:29-07:00
Authentication code: 6789

Re: separate modifies channel values!

Post by shadowhand »

fmw42 wrote:
# convert rgb-no-alpha.png -format "%[fx:minima.a] %[fx:maxima.a]" info:
1.33333e+36 -1.33333e+36
These values make no sense for either Q16 or Q8. Looks like your system may be corrupted or has some bad bugs in that version.
I get this same result on both Mac and Linux. There is very little chance my system is corrupted, as we do lots of complex ImageMagick operations and this is the only one with issues.
Have you tried re-installing IM?
I can, but this seems like a red herring. We have the same version/package of ImageMagick installed on tens, if not hundreds, of VMs.
Have you checked to see that you do not have multiple versions of IM on your systems?

Code: Select all

mac % type -a convert
convert is /usr/local/bin/convert

linux # type -a convert
convert is /usr/bin/convert
So no, there are no duplicates. Longer version info:

Code: Select all

mac % convert -version
Version: ImageMagick 6.8.6-3 2013-07-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg png xml zlib

linux # convert -version
Version: ImageMagick 6.8.6-9 2013-09-13 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jbig jng jp2 jpeg lcms ltdl lzma png png tiff xml zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: separate modifies channel values!

Post by snibgo »

Shadowhand's results for rgb-no-alpha.png, eg 1.33333e+36, remind me of results from my C-language programs when I have forgotten to initialize a variable.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

On IM 6.8.6.9 and 6.8.6.10 Q16 Mac OSX I get


convert rgb-no-alpha.png -channel a -separate -format "%[fx:minima]" info:
1

convert rgb-no-alpha.png -channel a -separate -format "%[fx:maxima]" info:
1


convert rgb-no-alpha.png -channel a -separate -format "%[fx:minima] %[fx:maxima]" info:
1 1


But using channel indices does give bad results

convert rgb-no-alpha.png -format "%[fx:minima.a] %[fx:maxima.a]" info:
5.18807e+33 -5.18807e+33

So I would have to say there is a bug in this respect.
User avatar
shadowhand
Posts: 14
Joined: 2013-09-20T17:57:29-07:00
Authentication code: 6789

Re: separate modifies channel values!

Post by shadowhand »

Looks like it has been fixed by something else in some later version:

Code: Select all

mac % % convert -version                                                                                                                                                          1 ↵
Version: ImageMagick 6.8.6-10 2013-09-23 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib freetype jng jpeg ltdl png png xml zlib

mac % for file in alpha false-alpha no-alpha alpha-partial; do; echo $file; convert "rgb-$file.png" -channel a -separate -format "%[fx:minima] %[fx:maxima]\n" info:; done         
alpha
0 1
false-alpha
1 1
no-alpha
1 1
alpha-partial
0.501961 1
Even the false-alpha file (opaque PNG with alpha channel forced on) registers correctly here. I'm not sure exactly what version fixed it, but 6.8.6-10 is certainly fixed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: separate modifies channel values!

Post by fmw42 »

I still get


convert rgb-no-alpha.png -format "%[fx:minima.a] %[fx:maxima.a]\n" info:
5.18807e+33 -5.18807e+33

convert -version
Version: ImageMagick 6.8.6-10 2013-09-23 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps png tiff x xml zlib

Mac OSX Snow Leopard


It works fine as I had above with -channel a -separate same as you (see above). But it does not work with %[fx:minima.a] selecting the channel that way.


It seems to work for r,g,b but not a

convert rgb-no-alpha.png -format "%[fx:maxima.r] %[fx:maxima.g] %[fx:maxima.b] %[fx:maxima.a]\n" info:
1 1 1 -5.18807e+33
Post Reply