9

I have a hi-res scan of some paper, where you can see the grain. However, the scanner has made some parts of the page darker than others—for example, it is a lot darker near the page edges. This can be seen when repeating a section of the image (shown below)

enter image description here

How can I even out the colour differences in the page, but retain the existing grain?

My current attempt was to get the average of the page, and then blend this colour via colour burn to the page texture. Gaussian blurring this would give a map of the lighter and darker areas in the page. Inverting that and applying with soft blend to the original page would get close to removing the irregularities.

However, the method described is definitely not the correct way to get an overall map of the light and dark areas, and did not perform as well as hoped. It must be as exact as possible, as I want to be able to move parts of the page around without having a sudden break in the gradients on the page (again, shown in the image).

Any help here would be hugely appreciated!

Edit: I'm not looking to regenerate a paper grain, no matter how close it is, a generated paper grain won't have the right look-and-feel. I need to use the existing grain of the paper.

SOLUTION

To get the paper grain,

  1. Duplicate the original layer
  2. Select -> Color Range, click on some black in the page and drag the slider up until you can see you're selecting all the ink
  3. Select -> Modify -> Expand selection by a few pixels or so
  4. Edit -> Fill and use content aware

To find the shadows,

  1. Duplicate the paper grain layer
  2. Filters -> Blur -> Average
  3. Image -> Apply Image, select the paper grain layer, and use the subtract operation using an offset of 128 and a scale of 1

This will now give you a layer that is mostly mid-grey with darker and lighter areas corresponding to shadows and other blemishes in the picture. Ensure the grey image is both darker and lighter by going into the levels tool and checking that the brightness curve appears on both sides of the midpoint. If it does not, the next stages will not work.

Applying this image in a similar manner as before but to the original scan will change the paper to the average paper colour determined in step 2. However, this will also remove the grain, so to avoid this,

  1. Filters -> Blur -> Gaussian Blur and adjust the settings such that the grain disappears but the shadows are still visible

Finally, to apply this back to the original image and remove the shadows, hide all layers but the original scan, go to Image -> Apply Image, select the shadow layer, and use subtract with an offset of 128 and a scale of 1. Depending on the order of subtractions, this will either remove the shadows, or double them. If it is doubling them, select the invert option in the Apply Image window. Click okay, and it should remove the shadows.

As a last clean-up, you may to reimport the original scan, select just the ink (via select color range), and copy and paste-in-place the ink over the top of the adjusted scan. This is because it is theoretically possible that the edges of the ink will get affected by the transformation described above.

7
  • Have you tried with frequency separation? Then just equalize the low frequency data.
    – joojaa
    Dec 22, 2015 at 12:29
  • Never heard of it—looking it up now. Probably exactly what I need though! Dec 22, 2015 at 12:30
  • No luck with this. Any attempt to set up the filter (with gaussian blur, apply image, and then linear light) pretty much gives me a monochrome image. Dec 22, 2015 at 13:10
  • Can you share Original data?
    – joojaa
    Dec 22, 2015 at 13:22
  • 1
    I'm not sure it's down to the jpeg compression: it's a very old scan, so I think those artifacts are just there. However, if you're sure, the original is at i.imgur.com/nBN9bUJ.png Dec 22, 2015 at 13:56

5 Answers 5

6

This is a perfect situation for the smart-blur tool since the text information is high-contrast with respect to the background.

I have a sample below where I applied a mild smart blur just enough to flatten out the grainy nature of the scan.

I then added a layer filled with RGB(128,128,128) and used the noise filter with color on and gaussian distribution. I then blurred that layer to enlarge the grain a little and desaturated it back to greys. I set that layer to multiply at about 30% opacity. (the sample below shows the layer prior to adjusting layer opacity and blend mode)

Next I placed an exposure adjustment layer overall and brought the exposure up so that it matched the original.

To sum up, smart blur to eliminate the grain and unify the background and then simulate the paper grain.

Others have hinted in comments that the "proper" way to do this is with a fourier transform that isolates the frequencies. You would then smooth certain frequencies and then reverse the transform. I think there may actually be a post buried from a few years ago on this stackexchange that deals with this. I have played with it in the past and it is pretty close to magic IMO.

The manual way to eliminate grain is to blur the low frequencies by somehow doing a high-frequency cut filter and then blur. Then do an overlay of the same image with a low-cut filter and sharpen. You might find tutorials on how to clean up skin blemishes in photos that use this technique.

enter image description here

3
  • Yeah when simple blurs aren't enough then its time to pack your bag and move to signal processing land. Your answer is close enough as i dont have time for this im gona up vote this. Anyway sdont be scared of fourier theres a easy explanation here Thats perfect for a visual person like yourself (a bit long though)
    – joojaa
    Dec 22, 2015 at 20:32
  • Tried Fourier transforms: however, running the forward transform, doing nothing, and then reversing causes a lot of large artefacts, which made it not usable. Dec 23, 2015 at 14:27
  • @JacobParker What fourier and how many bins :) Quite clearly it works as you can jpeg compress the image :)
    – joojaa
    Dec 24, 2015 at 6:16
3

This is just how I would do this, maybe it's not an option for you. This is a technique that goes very quick and will not affect the quality of your black text at all.

  1. I'd isolate the black text using the levels; the textured background will become white and the black text will remain 100% black. To achieve this, you'll need to use the white color picker and click in the "darkest light gray" portion of your background to turn it to white;probably the gradient you don't like. You'll find the "levels" in the menu "image > adjustments > levels".

enter image description here

  1. Then I'd create my own version of the background by duplicating some parts of it and merging them together or simply using a texture of paper found online. You can patch up some areas you don't like with the stamp tool as well or you can decide to hide parts of the text by using the stamp tool or duplicating other areas of your texture. You need to be careful with this, the more you touch your background, the more you might lose the natural effect of your texture! In the example below, I used a nice paper background as it's a very common texture and nicer than using a noise filter. It's also way faster than trying to preserve the original texture you scanned.

  2. Finally, I'd add these 2 layers together in the same Photoshop file; the text layer would be using a Multiply layer blending effect over the background layer. This will make the white background of your layer with the black text "transparent" and the background below with the texture will be visible.

enter image description here

Results: You can make that texture light gray...

enter image description here

Or you can keep it cream...

enter image description here

This way you'll end up with your perfect background, can move the text and page as you want and if you have many different pages, you an re-use the same background for all or simply create 2-3 different versions.

The other benefit is if you need to patch up some imperfections, it won't affect your text at all and you won't need to go around each letter.

And actually, if your project is for offset printing, I'd go even further... I'd save the text part in bitmap mode (lineart) and would use Indesign to merge my background and this new bitmap together by using 2 image frame on top of each others; the bitmap will have a transparent background and will print more clearly as a lineart than as a rasterized image (eg. background + text merged together). This is a common technique used in commercial printing for maximum quality. Maybe the JPG files you have don't have a resolution high enough for this though.

How to save a bitmap lineart in Photoshop for clear printing on scanned images

Source and extra info for clean up of scanned images: http://dw-wp.com/resources/cartooning-quickguides/quickguides-cleanup/


Other option:

  • using the stamp tool and other selection tools to duplicate the part of the background you like over the parts you don't like (lot of work!)
  • using a different background similar to the one you like and using the technique above with the levels and multiply blend mode.

You can't really easily use other patch up tools or curves or adjustments because the texture you don't like seems to have the same kind of color or density as the one you like in your background! It would be hard to select one and not the other without having to do it manually somehow.


Related:

how to compensate 50% opacity white over photograph

clean up the background for scanned document

How to extend the background of an image?

Real non-destructive way of clonestamp tool in Photoshop

1
  • This is something I had considered. Not quite for my scenario, but I'm sure some other people will find this helpful. Thanks! Dec 23, 2015 at 13:18
1

In order to keep the texture and even out the background you have to use layer blending. Here is what you need to do:

  1. Create a layer with the desired background color
  2. Place your image on a layer above the background layer
  3. Double click on the image layer and go to Blending options
  4. Press Alt key and move the right slider to the left, until you get the desired texture (see the image). Please note that pressing the Alt key is very important at this step. If you don't press it, you get different result.
  5. Now you can merge all visible layers by pressing Ctrl+Alt+Shift+E (the result is on a new layer)
  6. Enjoy your creation! :)

enter image description here

4
  • I think this is only a value filter—areas between the two ranges are applied, but areas outside are not (and will use the fallback background colour). That's not quite it, because the areas outside should be lightened or darkened so they can keep their texture. Dec 22, 2015 at 13:06
  • Well ... yes, you keep the dark colors and blend the rest with the background. You will lose the texture that is lighter than the background difference that you talk about. You can create different paper texture by using noise techniques and blend the original texture even more. The problem is that noise paper texture doesn't look very natural but it does look digitally perfect, so it really depends on what you are trying to achieve here.
    – Komental
    Dec 22, 2015 at 13:17
  • Trying to achieve as much of the feel of the paper as possible! Dec 22, 2015 at 13:18
  • You can bring the texture out by using high-pass filtering which is beyond the scope of your question. I think there is no better way to go than the method I described. You keep what is equal in the image and then you can texture your background as much as you want. :)
    – Komental
    Dec 22, 2015 at 13:22
1

I would use a large radius "high pass" filter, followed by a correction with a levels layer.

High pass removes only the low frequency components of an image (the gradient you want to remove), but also centres the average luminosity of an image around mid-gray (by design). By using levels, you can restore the original background colour. The high frequency components (paper grain, music notation) will remain intact. It's a more direct approach of your original attempt.

Takes a bit of fiddling, but this technique works quite well. Generally you want the high pass to be as large as possible while still filtering out your undesired gradients.

0

Simplest answer: Wavelets

Wavelets are an easy way to manipulate an image at different frequencies. Each frequency scale is kept on a separate layer.

Steps

  1. Decompose to wavelets
  2. Select the "residual layer" (lowest frequency)
  3. Adjust Levels so anything close to white becomes white
  4. That's all, you are done.

Demonstration

The following examples are done in the GNU Image Manipulation Program, but any other software should be similar.

Starting image

Here is the image which has a slightly different shade on the left and right sides.

Initial image which has

Optional: A better view

In order to show the problem clearly, I enabled the Contrast display filter (ViewDisplay Filters). For this image, a value of 2.6 for the Contrast cycles made the changing shade between the two sides most obvious.

GIMP Display Filters dialog box The original image, with the Contrast Display Filter activated

Wavelet decompose

Decompose the image into wavelet layers. (FiltersEnhanceWavelet-decompose).

enter image description here

I used the default scale setting of 5, which gave me five wavelet layers (grain-merged) and a residual layer (opaque). The layer at the top (Scale 1) holds only the finest details. Each step down holds coarser and coarser features until the residual layer at bottom.

Layers created by wavelet decompose

Levels

Select the residual layer and use the Levels tool (ColorsLevels) to set very bright pixels to white. See the large peak on the right side of the histogram in the image below? That's all the almost white shades we want to get rid of. Underneath the peak there is a white triangle that represents the "white point". Drag the white-point triangle to the left until it goes past the large peak.

Levels dialog showing the white-point triangle adjusted to the left of the peak in the histogram

As you can see, I only had to nudge it a little bit, from 255 to 242. The contrast filter helps us to see that doing so had a profound impact on the image.

After levels adjustment, contrast view shows that the image no longer has unwanted gradients. Hurray!

The final result

Exporting the image to a PNG file and duplicating it to the side shows that the unwanted gradient has been removed and the paper grain pattern is preserved.

Side-by-side result proves that the left and right side are now equal in value

Your Answer

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

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