30

I've scanned an old photo with paper texture pattern and I would like to remove the texture as much as possible without lowering the image quality. Is there a way, probably using Image Processing toolbox in MATLAB?

I've tried to apply FFT transformation (using Photoshop plugin), but I couldn't find any clear white spots to be paint over. Probably the pattern is not so regular for this method?

You can see the sample below. If you need the full image I can upload it somewhere. photograph sample

yuk
  • 19,098
  • 13
  • 68
  • 99
  • +1 for an interesting question. can you put the original image up somewhere? just curious about how my approach would work on the entire image. – mpenkov Mar 29 '11 at 14:26
  • Thank you everyone for answering and upvoting this question. Sorry for the delay with replying. This is a photo of my mother-in-law and she passed away a few days ago. I uploaded the full image here: http://img811.imageshack.us/img811/5827/file0011m.jpg – yuk Mar 30 '11 at 19:56

4 Answers4

24

Unfortunately, you're pretty much stuck in the spatial domain, as the pattern isn't really repetitive enough for Fourier analysis to be of use.

As @Jonas and @michid have pointed out, filtering will help you with a problem like this. With filtering, you face a trade-off between the amount of detail you want to keep and the amount of noise (or unwanted image components) you want to remove. For example, the median filter used by @Jonas removes the paper texture completely (even the round scratch near the bottom edge of the image) but it also removes all texture within the eyes, hair, face and background (although we don't really care about the background so much, it's the foreground that matters). You'll also see a slight decrease in image contrast, which is usually undesirable. This gives the image an artificial look.

Here's how I would handle this problem:

  • Detect the paper texture pattern:
    • Apply Gaussian blur to the image (use a large kernel to make sure that all the paper texture information is destroyed
    • Calculate the image difference between the blurred and original images
    • EDIT 2 Apply Gaussian blur to the difference image (use a small 3x3 kernel)
  • Threshold the above pattern using an empirically-determined threshold. This yields a binary image that can be used as a mask.
  • Use median filtering (as mentioned by @Jonas) to replace only the parts of the image that correspond to the paper pattern.

Paper texture pattern (before thresholding):

enter image description here

You want as little actual image information to be present in the above image. You'll see that you can very faintly make out the edge of the face (this isn't good, but it's the best I have time for). You also want this paper texture image to be as even as possible (so that thresholding gives equal results across the image). Again, the right hand side of the image above is slightly darker, meaning that thresholding it well will be difficult.

Final image:

enter image description here

The result isn't perfect, but it has completely removed the highly-visible paper texture pattern while preserving more high-frequency content than the simpler filtering approaches.

EDIT

The filled-in areas are typically plain-colored and thus stand out a bit if you look at the image very closely. You could also try adding some low-strength zero-mean Gaussian noise to the filled-in areas to make them look more realistic. You'd have to pick the noise variance to match the background. Determining it empirically may be good enough.

Here's the processed image with the noise added:

enter image description here

Note that the parts where the paper pattern was removed are more difficult to see because the added Gaussian noise is masking them. I used the same Gaussian distribution for the entire image but if you want to be more sophisticated you can use different distributions for the face, background, etc.

Community
  • 1
  • 1
mpenkov
  • 21,621
  • 10
  • 84
  • 126
  • Thanks a lot. Interesting approach and the result looks very good. Did you do it in MATLAB, or something like Photoshop? If MATLAB, would you share the code please? Please check the full image, the link is in my comment to the question. – yuk Mar 30 '11 at 20:00
  • @yuk: I used GIMP for the first step (detect paper texture) and Python/OpenCV to do the rest. I think it should be definitely be possible to do everything in MATLAB -- I just don't have access to it at my home computer. If you want to see my Python source, I can put it up here or mail it to you. – mpenkov Mar 31 '11 at 00:51
  • @yuk: I forgot to add a second Gaussian blur step to my explanation. Please see my updated answer – mpenkov Mar 31 '11 at 01:22
  • I think the Python code you have used would be helpful the everybody reading this question. Just append it to your answer. Thank you so much again. – yuk Mar 31 '11 at 15:37
  • @yuk: you're probably way over this but I've recently been playing around with OpenCV and used this problem as a demo. The source is here: https://github.com/mpenkov/sandpit/tree/master/stackoverflow. Sorry that it took so long. – mpenkov Oct 07 '11 at 15:32
  • Note that the valid edges will also enter the mask, as they produce intense response, so they can be damaged. A solution could be to use double thresholding. (?) – Yves Daoust May 07 '23 at 19:44
13

A median filter can help you a bit:

img = imread('https://i.stack.imgur.com/JzJMS.jpg');
%# convert rgb to grayscale
img = rgb2gray(img);
%# apply median filter
fimg = medfilt2(img,[15 15]);
%# show
imshow(fimg,[])

enter image description here

Note that you may want to pad the image first to avoid edge effects.

EDIT: A smaller filter kernel than [15 15] will preserve image texture better, but will leave more visible traces of the filtering.

Jonas
  • 74,690
  • 10
  • 137
  • 177
  • Thank you, Jonas for the solution. I'll try your and misha's approach and compare. – yuk Mar 30 '11 at 20:02
3

Well i have tried out a different approach using Anisotropc diffusion using the 2nd coefficient that operates on wider areas

Here is the output i got:

enter image description here

vini
  • 4,657
  • 24
  • 82
  • 170
1

From what i can See from the Picture, the Noise has a relatively high Frequency Compared to the image itself. So applying a low Pass filter should work. Have a look at the Power spectrum abs(fft(...)) to determine the cutoff Frequency.

michid
  • 10,536
  • 3
  • 32
  • 59
  • Unfortunately, low-pass filtering will also blur edges, which is something median filtering won't. – Jonas Mar 27 '11 at 23:22
  • @Jonas: median and low-pass filtering will **both** remove some fine detail from the image (in your case, look at the hairline and the edge of the face -- they are both blurrier than in the original). – mpenkov Mar 28 '11 at 06:45
  • @misha: Yes, they will both remove fine details (such as the white lines). Since the lines are white, the edge will be be somewhat affected. However, the effect on edges is much more pronounced in low-pass filters than in edge-preserving filters such as median filters. – Jonas Mar 28 '11 at 11:46