possible bug -mask IM 6.7.8.8 Q16

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
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug -mask IM 6.7.8.8 Q16

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -mask IM 6.7.8.8 Q16

Post by magick »

Read masks are not supported in ImageMagick 6 series. They might be supported in ImageMagick 7.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -mask IM 6.7.8.8 Q16

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -mask IM 6.7.8.8 Q16

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -mask IM 6.7.8.8 Q16

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -mask IM 6.7.8.8 Q16

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -mask IM 6.7.8.8 Q16

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug -mask IM 6.7.8.8 Q16

Post 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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply