qkq4348 has asked for the wisdom of the Perl Monks concerning the following question:

Hai I have got an image taken during night time and some part of it is unclear cause by shaking of the camera. Did anyone here know how can we clear the shaking portion of the image? As what i understand that we need to clear the particular bits of the image? How we going to check the bits of the image and the most important is that what is the code for checking the particular bits? Thanks....

Replies are listed 'Best First'.
Re: Clearing image Bits
by BrowserUk (Patriarch) on Apr 20, 2006 at 04:22 UTC

    GD knows how to get & set pixels, and (once installed) is pretty easy to use, but the biggest problem you will face going by your description is deciding which pixels need changing. And once you've decided which portions of the image you are going to change, how you will convey that information into your program.

    Determining whether a part of an image is "shaky" programmically, is a complex process. You would need to inspect the whole image in small overlapping groups of pixels at a time and use some sort of edge detection algorithm. This is distinctly non-trivial, and that type of image processing is definitly not Perl's forte. Accessing each pixel via perl method call (repeatedly) is going to make for very slow processing, even if you come up with a suitable algorithm.

    If this is a one time, single image change then you'd be better off using one of the many image editors available. This will allow you to make the determination of what to change visually and then indicate the area(s) using a rubber-band selection process with the mouse.

    If you anticipate having to deal with this problem on a regular basis, investing in a tripod or a camera with an anti-shake device would be the simplest option :)


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Clearing image Bits
by davidrw (Prior) on Apr 20, 2006 at 03:52 UTC
    Both Image::Magick and Imager have methods to get/set specific pixels in an image. There are also methos for drawing primatives (e.g. set a whole rectangle to black).
Re: Clearing image Bits
by saintmike (Vicar) on Apr 20, 2006 at 04:22 UTC
    While it is possible to increase the contrast of certain parts of an image to increase the perceived "sharpness", there is no way to make a picture sharper which has been blurred by shaking the camera.

    If you find a way to put more information into a picture than the amount that was captured in the original shot, let us know, and we'll put a word in for you at the Nobel Prize committee.