Using -fx on a bilevel image
Posted: 2017-08-29T16:21:40-07:00
I am trying to turn white those black pixels of a bilevel image
that have less than 3 black neighbours. The original image is
predominantly white. At least two things do not work as expected.
(1)
`convert file1.bmp -fx "p[0,0]&&((p[-1,0]+...+p[-1,-1])>2.7)" file2.bmp'
works long and turns several white pixels black.
`convert file1.bmp -fx "p[0,0]||((p[-1,0]+...+p[-1,-1])>2.7)" file2.bmp'
takes much less time and does not.
(2)
The latter gets rid of (thin) lines and keeps the (fatter) polygons.
However, the polygons lose some "fat", at neat "step" boundaries too.
Even more surprisingly, replacing `2.7' with `1.7' makes the loss
greater while replacing `2.7' with `3.7' makes it smaller.
It seems I have got some notation wrong. Black is 1.0 and white 0.0,
are they not? && is AND and || OR, are they not?
The ImageMagic is 7.0.6-0 Q16 x86; not that it is likely to matter.
that have less than 3 black neighbours. The original image is
predominantly white. At least two things do not work as expected.
(1)
`convert file1.bmp -fx "p[0,0]&&((p[-1,0]+...+p[-1,-1])>2.7)" file2.bmp'
works long and turns several white pixels black.
`convert file1.bmp -fx "p[0,0]||((p[-1,0]+...+p[-1,-1])>2.7)" file2.bmp'
takes much less time and does not.
(2)
The latter gets rid of (thin) lines and keeps the (fatter) polygons.
However, the polygons lose some "fat", at neat "step" boundaries too.
Even more surprisingly, replacing `2.7' with `1.7' makes the loss
greater while replacing `2.7' with `3.7' makes it smaller.
It seems I have got some notation wrong. Black is 1.0 and white 0.0,
are they not? && is AND and || OR, are they not?
The ImageMagic is 7.0.6-0 Q16 x86; not that it is likely to matter.