Page 1 of 1

[RESOLVED]possible bug MPC with -fill -opaque IM 6.8.7.9 Q16

Posted: 2013-12-09T12:40:01-07:00
by fmw42
I am trying to reduce colors in an image and then select one color and convert the image for that color to white on black. It works fine with PNG, MIFF, but not MPC (unless I add a non-zero fuzz value).

Works:
convert logo: -depth 8 +dither -colors 24 1tmp1.png
colorArr=(`convert 1tmp1.png -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.png \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:

Works:
convert logo: -depth 8 +dither -colors 24 1tmp1.miff
colorArr=(`convert 1tmp1.miff -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.miff \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:



Does not Work -- result is all black:
convert logo: -depth 8 +dither -colors 24 1tmp1.mpc
colorArr=(`convert 1tmp1.mpc -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.mpc \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:

Works, but only with -fuzz not zero:
convert logo: -depth 8 +dither -colors 24 1tmp1.mpc
colorArr=(`convert 1tmp1.mpc -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.mpc -fuzz 1% \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:

Re: possible bug MPC with -fill -opaque IM 6.8.7.9 Q16 Mac O

Posted: 2013-12-09T19:24:39-07:00
by magick
Use
  • convert logo: +dither -colors 24 -depth 8 1tmp1.mpc
Setting -depth 8 right after logo: reduces the image depth to 8, however color reduction uses 16-bits of precision. The MIFF and PNG formats respect the 8-bit depth setting, but MPC does not. It serializes the pixel data directly from memory at 16-bits of precision to disk and when read, 16-bits of precision is read back in. The result is a slightly different set of pixels than when read from a PNG or MIFF image due to differences in precision (PNG / MIFF @ 8-bits, MPC @ 16-bits). Moving the -depth to the end of the command line ensures the pixel data is 8 bits for each of the PNG, MIFF, and MPC image formats.

Re: possible bug MPC with -fill -opaque IM 6.8.7.9 Q16 Mac O

Posted: 2013-12-09T19:28:57-07:00
by fmw42
thanks