In my quest for better performance I am looking into calling the ImageMagick command line utilities directly instead of loading images into the Ruby memory space.
I've perused and perused the doc but I can't quite figure out how I would examine individual pixels. For example, let's say I have a 1xn image, b&w. I would like to walk through all the pixels and identify the black to white transitions and white to black.
In other words, if the image looks like this:
w w w b b w b b w
I would like to generate 5 pairs of numbers, as follows:
[0, 2] (white section goes from pixel 0 to 2)
[3, 4] (black section goes from pixel 3 to 4)
[5, 5] (and so on)
[6, 7]
[8, 8]
I've puzzeled around the -format and -fx switches but it seems to get very hairy very quickly.
Can anyone help me understand, or point me to some examples?
Thanks a lot!
Pito
Working on individual pixels in ImageMagick
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Working on individual pixels in ImageMagick
you can list out all the pixels by converting the image to txt: output format. see http://www.imagemagick.org/Usage/files/#txt. from there you would be on your own to group pixels.