Page 1 of 1

Channel bitwise operations does not work.

Posted: 2016-12-08T23:56:23-07:00
by willyvmmm
Hi.
I'm not sure if it is a bug or Its me to try use incorrect that feature:

Code: Select all

C:\devel\ImageMAgick>convert rose: -crop 1x1+1+1 -depth 8  txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (12336,12079,11565)  #302F2D  srgb(48,47,45)

C:\devel\ImageMAgick>convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8  txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (12593,10537,10537)  #312929  srgb(49,41,41)

C:\devel\ImageMAgick>convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8 -channel red -fx "r" txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (12593,10537,10537)  #312929  srgb(49,41,41)

C:\devel\ImageMAgick>convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8 -channel red -fx "r<<1" txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (0,10537,10537)  #002929  srgb(0,41,41)

C:\devel\ImageMAgick>convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8 -channel red -fx "r >> 1" txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (0,10537,10537)  #002929  srgb(0,41,41)

C:\devel\ImageMAgick>convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8 -channel red -fx "r>>1" txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (0,10537,10537)  #002929  srgb(0,41,41)

C:\devel\ImageMAgick>convert -version
Version: ImageMagick 7.0.3-9 Q16 x64 2016-12-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

C:\devel\ImageMAgick>ver

Microsoft Windows [Version 6.1.7601]

C:\devel\ImageMAgick>
Any attempt to use bitshift operator (<<, >> an dpossibly others) produces 0 or sometimes $ff

Best Regards
Willy.

Re: Channel bitwise operations does not work.

Posted: 2016-12-09T18:12:39-07:00
by willyvmmm
I've found a workaround:

Code: Select all

$ convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8  txt:                    
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (12593,11565,10537)  #312D29  srgb(49,45,41)

$ convert rose: -crop 1x1+1+1 -ordered-dither threshold,32,64,32 -depth 8 -channel red -fx "((int(r*255)<<1)&254)/255" txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (25186,11565,10537)  #622D29  srgb(98,45,41)
It seems that channel variables are real numbers not fx. byte as i can assume when i use -depth 8.
As I can remember it is not mentioned in the docs. So anyway, You can not use bitwise operators directly on channel data.

W.