Code: Select all
convert original.tif -evaluate and 255 -depth 8 lower.png
convert original.tif -evaluate RightShift 8 -evaluate and 255 -depth 8 upper.png
Code: Select all
convert original.tif -evaluate and 255 -depth 8 lower.png
convert original.tif -evaluate RightShift 8 -evaluate and 255 -depth 8 upper.png
Yes.Can I use convert to write only the upper (or lower) 8 bits of a 16-bit grayscale TIF?
No.That is, will the following work?
I give up. How do you get #99 from the top bits of #9ABC?16-bit=>8-bit(#9ABC) = #99, not #9A
Code: Select all
convert x.tif -evaluate And 255 -evaluate Multiply 256 ( +clone -evaluate Divide 256 ) -compose Add -composite -depth 8 lower.png
convert x.tif -evaluate RightShift 8 -evaluate LeftShift 8 ( +clone -evaluate Divide 256 ) -compose Add -composite -depth 8 upper.png
Code: Select all
-fx "(u & #ff00) | (u >> 8)" -depth 8 upper.png
-fx "(u & #00ff) | (u << 8)" -depth 8 lower.png
Upper and lower depends on the endianess of your machine.convert gray.tiff -depth 16 GRAY:- | convert -size 2*WxH -depth 8 GRAY:- -define sample:offset=25x50 -sample 50%x100%\! upper.png
convert gray.tiff -depth 16 GRAY:- | convert -size 2*WxH -depth 8 GRAY:- -define sample:offset=75x50 -sample 50%x100%\! lower.png