10

enter image description here

I have this extremely distorted and stained image

Is it possible to remove this stain ? Could image inpainting help ?

Please help

EDIT : Another image

enter image description here

After applying anisotropic diffusion and representing image with imagesc(MATLAB)

enter image description here

I tried inpainting however the result isn't good enough

enter image description here

Is there anyway i could improve this output?

vini
  • 2,182
  • 4
  • 21
  • 37
  • Well thats what image processing is about making a computer to do it for me – vini Mar 16 '12 at 17:26
  • 3
    In your image the stains are obviously on a separate plane of focus. Therefore, I would think about how to decompose the image by focus planes. Throw in a little inpainting and you should you be done :) – Emre Mar 16 '12 at 17:49
  • By focus planes what exactly do you mean? – vini Mar 16 '12 at 17:58
  • This image is formed by the superposition of a defocused foreground plane and a focused background plane. Furthermore, the foreground plane appears to be roughly perpendicular to the sensor, simplifying calculations. I would initially assume the blur is uniform. – Emre Mar 16 '12 at 18:03
  • See if this paper gives you any ideas. – Emre Mar 16 '12 at 18:15
  • This looks like an excellent source of inspiration too. Take a stab at it! – Emre Mar 16 '12 at 19:15
  • Inpainting doesnt work for me as mostly all of the methods need a mask producing a mask for this is difficult could you suggest something? – vini Mar 17 '12 at 08:23
  • http://www.theinpaint.com/tutorials.html i found this software it works wonders for me however i cannot find out which technique is it based on – vini Mar 17 '12 at 08:52
  • 2
    @vini Do you have several images or just this one? I can get "good" results by creating a mask manually and inpainting. Is that a solution you'd be interested in? – Lorem Ipsum Mar 17 '12 at 16:17
  • I did apply inpainting and got a good enough result ! I have several images for which i intend to do segmentation afterwards – vini Mar 17 '12 at 16:26
  • 3
    You can't just clean the windows? – endolith Mar 19 '12 at 19:53
  • @endolith take for example it is something which impairs visibility for us what then we would require an efficient algorithm for the same that's my motto – vini Mar 21 '12 at 02:34
  • What algorithm do you use for inpainting? – Challenger Mar 26 '12 at 11:26
  • I have used total variation inpainting – vini Mar 27 '12 at 01:48
  • 2
    The images seem to be double exposed as well as stained. Is this the case? – Charna Mar 30 '12 at 20:11
  • Yes it has unwanted reflections as well that i would want to remove – vini Mar 31 '12 at 02:33

1 Answers1

8

This is not a complete and crisp answer however, i am leaving you with at least some approach for you to fight with. (I would be very glad to know if you have results).

Take a look at these questions:

Removing Glare from Image
How to remove the glare and brightness in an image (Image preprocessing)?

They are essentially trying to solve the same problem.

There are two parts of the problem,

a. Identifying the spot/stain b. Replacing the stain with what would have been in the place of occlusion.

The nature of the question is trying to solve exact problem (in some sense).

This is not trivial thing. However, in both questions there are some unique pattern that you can exploit.

  1. In all cases, the superimposing element which is required to be removed called here as (stain, glare, bright spot), overlay has a unique and distinct hue/color which distinguishes itself from regular objects/scene.

  2. In most cases, this hue/color of the overlay fades away into the regular scene. The actual resultant color does change - however, it is better to model overlay as single intensity and color with successively reducing transperency Hence you can say resultant pixel $$P[x,y] = (1-\alpha[x,y])*S[x,y] + \alpha[x,y] * OverlayHue $$ $$\tilde S[x,y] = (P[x,y] - OverlayHue * \tilde \alpha[x,y])/(1-\tilde \alpha[x,y]) $$ where $P[x,y]$ is observed image, and $S[x,y]$ is desired occlusion free image. Note, that alpha can be arbitrarily varied over pixels, but $OverlayHue$ of overlay is considered almost constant. $\tilde S[x,y]$ and $\tilde \alpha[x,y]$ are estimated values by your algorithm for the respective quantities.

  3. The OverlayHue value can be independently estimated by manually segmenting pixel regions where Stain or Flash is clearly dominating.

  4. You can assume that \alpha[x,y] is consistent across all channels (i.e. R,G,B) . Hence you can identify individual components as follows: $$\tilde S_R[x,y] = (P_R[x,y] - OverlayHue_R * \tilde \alpha[x,y])/(1-\tilde \alpha[x,y]) $$ $$\tilde S_G[x,y] = (P_G[x,y] - OverlayHue_G * \tilde \alpha[x,y])/(1-\tilde \alpha[x,y]) $$ $$\tilde S_B[x,y] = (P_B[x,y] - OverlayHue_B * \tilde \alpha[x,y])/(1-\tilde \alpha[x,y]) $$

  5. You can see that when $\alpha$ is close to 1 implies that overlay is completely occluding the scene and hence no estimate of $\tilde S$ can be good, you should avoid that and keep some reference value to iterate it over time.

  6. You still have more variables than equation unfortunately, and that is due to the physical nature of pixels. A given color could have resulted either due to the pixel's own property or due to stain/glare. Best bet is that you start with identified pixels where you know that $\alpha$ is 1 and then gradually decay down guess for $\alpha$ reducing successively. Over some iteration you can find the patterns.

  7. Also, in order to finally estimate pure black spots, You can also apply smoothing constraint over neighborhood pixels (i.e. $\tilde S[x,y]$ as well as $\tilde \alpha[x,y]$).

This may not be perfect solution, but may be better than most obvious than pixel level clipping or playing around with saturation etc. I sincerely request you do try this in your end and show us results (my workbench is currently in a mess so i couldn't do it!)

Hope this helps.

Dipan Mehta
  • 5,587
  • 2
  • 30
  • 53