Page 1 of 1

possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T11:37:33-07:00
by fmw42
IM 6.7.8.8 Q16 Q16

-mask works fine for actual pixel processing of an image (such as -modulate). But I cannot seem to use it to get statistics.

Image: (pure red, pure green1, pure blue)
Image

Mask:
Image

I am expecting mean values of: 0,1,0

convert rgb.gif -mask rgb_mask.gif -format "%[fx:mean.r],%[fx:mean.g],%[fx:mean.b]" info:
0.333333,0.333333,0.333333

Which is the same as using no mask and getting the full image mean values!

convert rgb.gif -format "%[fx:mean.r],%[fx:mean.g],%[fx:mean.b]" info:
0.333333,0.333333,0.333333


Am I doing something wrong or is there some bug here?

P.S. Same issue with -clip-mask

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T11:46:22-07:00
by magick
Read masks are not supported in ImageMagick 6 series. They might be supported in ImageMagick 7.

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T11:50:11-07:00
by fmw42
magick wrote:Read masks are not supported in ImageMagick 6 series. They might be supported in ImageMagick 7.
According to Anthony's page at http://www.imagemagick.org/Usage/masking/#write_mask, this is a write mask.

Are you saying that since it is not really processing pixels, only accessing them to get the image data, that it is then behaving as a read mask?

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T12:57:28-07:00
by magick
Read mask / write mask, its still not supported-- at least not this moment. We're looking at supporting masks for image statistics over the next few days.

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T13:04:51-07:00
by fmw42
magick wrote:Read mask / write mask, its still not supported-- at least not this moment. We're looking at supporting masks for image statistics over the next few days.

OK. Do it at your own pace. I have a work around that is slower, but still works. Thanks.

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T18:04:16-07:00
by magick
With the pending patch in ImageMagick 7.0.0, we get:
  • convert rgb.gif -mask rgb_mask.gif -format "%[fx:mean.r],%[fx:mean.g],%[fx:mean.b]" info:
    0,1,0

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-06T18:19:03-07:00
by fmw42
magick wrote:With the pending patch in ImageMagick 7.0.0, we get:
  • convert rgb.gif -mask rgb_mask.gif -format "%[fx:mean.r],%[fx:mean.g],%[fx:mean.b]" info:
    0,1,0

Great! Sorry, I did not mean to be argumentative. I was just trying to understand as that was the first time I had tried using -mask. I think I understand the difference now between read and write masks.

Re: possible bug -mask IM 6.7.8.8 Q16

Posted: 2012-08-08T19:03:39-07:00
by anthony
Be sure to understand that when read masks do get implemented. It is up to the individual operations to do the right thing when reading pixels. That is it may not be available on all operations..

Write mask just prevents writing. IMv7 will allow operators to skip processing of pixels that will not be written, but regardless the low level pixel routines in both Imv6 and Imv7, will stop those pixels being changed (or only partially changed during each operation for gray-level masks).

See masking
http://www.imagemagick.org/Usage/masking/#special_masks

The commond line interface to masking will likely change in IMv7 to allow better handling when read masks are added.
Specifically so you can set the 'last' image in the image list, to mask all the other images (and mask image removed from current list once set)