Convert pixels within IM?
Posted: 2018-11-18T18:34:57-07:00
I'm working with single rows of pixels in binary images, so a bunch of white and black pixels. What I'd like to do is make sure that all the pixels between the first and the last black ones are also black. For example, if the row were:
It would become
Can I do this within IM without writing out to a file or variable? (I'm writing in bash.)
I was thinking about converting to pbm format, then using regex, but the line breaks inside the pbm file make that harder than anticipated and I think I have to store the file data while I process it.
On a Mac, High Sierra, ImageMagick 7.0.8-14 Q16 x86_64.
Code: Select all
0 0 0 1 0 0 1 0 0 0
Code: Select all
0 0 0 1 1 1 1 0 0 0
I was thinking about converting to pbm format, then using regex, but the line breaks inside the pbm file make that harder than anticipated and I think I have to store the file data while I process it.
On a Mac, High Sierra, ImageMagick 7.0.8-14 Q16 x86_64.