Sonntag, 2. Juli 2023

Advanced Photoshop technique for image restoration: remove erratic backgroud structures

 

This new Photoshop technique will allow you to remove any erratic, chaotic background patterns, caused by old printing machines ('random dotted pattern') or visible paper structures (fibers, depths), with the least possible blur. Note that there are various methods for recovering halftone prints from newspapers or color magazines (with the fast fourier transformation method) covered elsewhere. The images have in common that they show at the highest zoom a kind of chaotic leopard pattern. What you would like to do is to lighten the spots, and darken the background, so that they merge to a uniform color. The difficulty is to get a selection that is exactly right.

It all started with this photograph from around 1900, my great-grandfather. You see the erratic pattern, which is at high resolution a few pixels wide. You can remove it with the 'median' filter or 'gaussian blur', but you loose detail as well. I did try quit a lot unsuccessfully. In this case the pattern seemed to be caused by small differences in depth in the paper that cast shadows on a flatbed scanner. For this problem the solution would be to use a good camera and photograph it with the right lighting. In my case, this old photo had such faint tones that I wanted to restore, that I needed the full 48bit range of the scanner. My dslr camera could not cover the same tonal range. Back to the scanned image. In the end the goal is - after restoring tones and removing all scratches - to use (smart) sharpening techniques to get a sharper image. This is not possible if the image is blurred before or has this background pattern that will be sharpened too.
What I needed is mask of the pattern, so that I can lighten dark parts and darken light parts. That would in theory remove the pattern entirely. I tried all kinds of filters, like 'find edges' and 'emboss'. Nothing was nearly satisfying, nor were suggestions from the internet. I had to find something else. As I already had given up, I came with an idea to use the high pass filter, and it worked! At the end of this post you find a Photoshop action you can download. Here are the steps for this method.

As an example I use this detailed cutout of an historical printed card, where you can see the pattern and the steps quite well. If you want to keep the original for comparison, start with a background layer copy.

  • Make a new layer copy and apply a high pass filter (Filter => Other => High Pass...) of 1.0-2.5 Pixel radius. To get a feeling which value is suitable for which image, you could try different values and see what works best.

  • To get a good mask, we need different steps. First we use curves to narrow the black and white points as in the image above.

  • In the following step, we use curves to further increase contrast. A mask works best with very dark and very bright values.
  • Apply a Gaussian blur of 0.4.
  • From this image we make an new alpha layer. Select all, copy. Go to Channels panel (if not visible use menu Windows => Channels), use the options button on the right, choose 'New Channel'. Paste. Now the image mask is in the new channel.
  • Switch to RGB levels again and go to layers panel. Delete the layer we have worked on.

  • Add a new curves adjustment layer (Layer = New adjustment layer => Curves). In the layers panel, click on the mask, and select the saved alpha channel (Select => load selection => .. choose Alpha 1 or the right name..). Delete. Now you have the mask in the curves layer. (There are probably more efficient ways to do this...)
  • Go the the curves (leave the mask) and adjust the curves, similar as in the image above. Use the three curve points to lighten the dark spots. There is an optimal setting for all 3 points, try what works best (at 100% view). Too much creates new artifacts. The pattern is now already for 60-80% reduced.

  • Copy the curves adjustment layer, go to the mask and invert it (ctrl+I). Use the three curve points to darken the light areas. Also look for light spots in dark areas you want to make invisible (at 100%). Now the remainder of the pattern disappears.
  • Merge the curve adjustment layers down and compare with the original layer.
  • You can now start to do any other editing on the image

 

The result is quite amazing. Although not 100% removed, the patterns are now hardly visible anymore and it is a so much better basis to do restoration work on.  

Back to the original 'problem image' (left). Also here the patterns are hardly visible anymore (middle). Now I can e.g. edit the eye in tone, without increasing the contrast of the paper pattern. I was a bit surprised about the amount of blur this method introduces. As an alternative I show the effect of a 3 pixel median filter (right), which also removes the spots similarly. However, the median filter is more destructive, and less successful in removing the pattern.

 
Another example, with original (left), the new method (middle left), median filter (middle right) and gaussian blur (right). They do similar things, but in different quality. (You can choose view image in new tab/window to see at 100%). You can see the the median filter introduces 'blobs' instead of keeping the image smooth at 100%. The new method can also introduce artifacts (errors in the mask) - here it made sense to keep a bit of the noise for the best result. Gaussian blur always keeps it smooth, but looses sharpness.

I am happy with it and applied it already to many images. If you like, you can download my Photoshop action here.

Keine Kommentare:

Kommentar veröffentlichen