I'd like an automatic method to clean images. I've been looking at the GIMP, and its command line (cli) interface, in scheme / lisp. It looks very promising, but I'm a complete novice, so I'd be grateful for advice.

I'm, essentially, wanting to remove all man-made artefacts from a large number of photos - which is why I need to automate it, it's easy enough with just the one.

I'd like to remove anything with a hard-edge (square, rectangle, or part of one), or with a smooth curve (circle, ellipse, or part of one), but not remove naturally curved things, like leaves, or fronds. Actually, since there may be bits of vaguely straight edge, or approximate arcs in the 'natural' figures, I can go further, and say that no straight edge, or arc, will be longer than .5 cm in the original - I hope that helps!

What's special about the areas removed is one of: There is a straight edged border (at least one). There is a border that is the arc of a circle - an interior or exterior border. The items left have irregular borders, with no straight edges and no arcs.

I've attached a before and after photo. In a perfect world, I'd like a script that takes the image on the left, and leaves the image on the right.

Any suggestions of the best way to go?

It'd be nice if the method could be one that can use a GPU.

Showing ideal case: an image before cleaning on the left, and after cleaning on the right. The 'man-made', square or round, artefacts have been removed

  • $\begingroup$ Do we have a migration path to DSP? (If so, Peter can avoid re-posting his question there.) $\endgroup$
    – GeoMatt22
    Sep 10, 2016 at 22:04
  • $\begingroup$ This sounds like an extremely difficult problem, the kind that you could write a PhD thesis on and graduate without actually solving it. $\endgroup$
    – Kodiologist
    Sep 11, 2016 at 6:14

1 Answer 1


I think the best way to get rid of those artifact shapes, is to implement an Shape Detection. Then, when you had coordinates of the unwanted shape, you can cut it out of your image. Then must fill its place with interpolating (through using background intensity values at the edges of the removed patch).

Now, there are various methods for shape detection and even OpenCV OpenCV Implementation and Aforge Aforge Implementation support some of them. First you must get image edges, then using Hough transforms for lines and circles, detect shapes.


Finally as I said, cut out the image and fill out the removed patch through interpolation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.