One option for accessing the pixels which no-one has mentioned is simply to use substr and unpack. Convert the jpg to ppm, which is just a row-major sequence of pixels, 3 bytes (rgb) per pixel. Just slurp it in as a string. The arithmetic for converting from pixel coordinates to string offset is trivial. Substr 3 bytes and unpack. Two lines of code. It is quite "fast" (in perl, rather than C terms). I wouldn't suggest touching every pixel with it, but it's great for sampling. And to grab the hypothetical 16x16 pixel spot, one can just concatenate 16 substr's, slap "P6 16 16 255 " on the front, and you have the spot ppm image. And with Inline::C, it is not difficult to convert parts of this to C, should the need perhaps someday arise.
Perl is quite good at doing _simple_ things with images. It is only when you get slightly more complex that you can get bogged down in the zoo of partial solutions.
In reply to Re: image clean up and alignment
by Anonymous Monk
in thread image clean up and alignment
by glwtta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |