Others have pointed out that once you determine the slide's skew, you may be better off having the spot grabber compensate, rather than trying to rotate the entire image.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.