How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Advice and Help

Moderator: kcleung

Post Reply
Bhm
regular poster
Posts: 20
Joined: Fri Jul 19, 2024 8:41 am
notabot: 42
notabot2: Human

How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by Bhm »

Hi all,

I'm working on a score from HathiTrust in preparation for uploading it to IMSLP.* It's not already monochrome or even grayscale, so I'm running it through ScanTailor to convert it to monochrome as well as set uniform page sizes. (I already removed the Google watermarks.)

Of course, some of the pages are yellowed, but my issue is the non-uniformity of the yellowing on some of the pages (example).** In ScanTailor, if I change the Threshold Method from Otsu (default) to Sauvola or Wolf, I can avoid the really overt smudging in the bottom-right. Overall, I would even say it's a decent scan. But the bottom-right is still too dark (filled-in accidentals), and the center of the page is still too light (broken staff lines).

I've tried adjusting the other Threshold parameters, but without any success. Ultimately, I think the problem is that the scan is simply not uniform; the inside edge is darker, yellower, than the rest. So, I was wondering if there were any ways to pre-process the image to correct the non-uniformity of the background before going to ScanTailor. I don't just mean de-yellowing; that's the idea, but I mean getting rid of the gradient background on the right without affecting the middle, which is okay as it stands.

*Technically, the score is already on IMSLP, but the existing IMSLP scan has a lot of overwritten material—sometimes entire systems at once. So, I'm trying to make the original edition available without alterations.
**Admittedly, a lot of scans from HathiTrust look like this, so I'm a bit surprised that I couldn't find this question asked here before.
Pnorcks
regular poster
Posts: 33
Joined: Tue Jun 27, 2023 4:29 am
notabot: 42
notabot2: Human

Re: How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by Pnorcks »

I'm sure it's possible to eliminate the non-uniform yellowing, but that's not something I know how to do.

A couple of pre-processing steps you could try that might lessen the effect of the non-uniformity:
  • For 300dpi color JPGs, try scaling the images 2x and set the DPI to 600.
  • If you scale the images 2x, I would recommend running the images through a sharpening filter (like an unsharp mask). If you don't scale up, the sharpening filter will probably still be an improvement... With Google Books scans, the noise from the lighter parts of images tend to be blurred, so sharpening doesn't introduce as much noise when converting to black/white.
Pnorcks
regular poster
Posts: 33
Joined: Tue Jun 27, 2023 4:29 am
notabot: 42
notabot2: Human

Re: How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by Pnorcks »

I went ahead and processed the HathiTrust image you linked, scaling up the images (2x), applying an unsharp mask, and converting to black/white using OTSU, Sauvola, and Wolf threshold options in ScanTailor Advanced. (If you are using the original ScanTailor, the results will probably be largely the same).

Isolating two sections: The first, near the bottom-right corner, with the more blurred and yellowish background. The second, an area where the staff lines have uneven thickness, or appear broken depending on the threshold option chosen.

I am posting images with side-by-side comparisons below to show my results. If you want to try the pre-processing steps I described, then hopefully this will be a helpful comparison.

For the first section:
snippet1-OTSU.png
snippet1-OTSU.png (91.31 KiB) Viewed 165 times
snippet1-Sauvola.png
snippet1-Sauvola.png (86.38 KiB) Viewed 165 times
snippet1-Wolf.png
snippet1-Wolf.png (85.37 KiB) Viewed 165 times
Pnorcks
regular poster
Posts: 33
Joined: Tue Jun 27, 2023 4:29 am
notabot: 42
notabot2: Human

Re: How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by Pnorcks »

For the second section:
snippet2-OTSU.png
snippet2-OTSU.png (88.35 KiB) Viewed 164 times
snippet2-Sauvola.png
snippet2-Sauvola.png (88.99 KiB) Viewed 164 times
snippet2-Wolf.png
snippet2-Wolf.png (87.4 KiB) Viewed 164 times
Bhm
regular poster
Posts: 20
Joined: Fri Jul 19, 2024 8:41 am
notabot: 42
notabot2: Human

Re: How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by Bhm »

The unsharp mask is very promising! I'm noticing that OTSU is still the worst in terms of smudging. Sauvola is better in the corner, while Wolf is better in the center, but since I think the former area is more sensitive, I'll stick to Sauvola.

One question: how are you scaling and unsharpening the images? I'd like to use IrfanView to batch-resize all of my images from 300 DPI to 600 DPI, using the Resample option as well as Resize based only on DPI, which takes care of both the scaling and the DPI parameter at once. But I'm not sure how (if) I can use the same wizard for the unsharpening. I've tried both Sharpen and Blur in the batch conversion Advanced Options, but they don't seem to change anything.
Pnorcks
regular poster
Posts: 33
Joined: Tue Jun 27, 2023 4:29 am
notabot: 42
notabot2: Human

Re: How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by Pnorcks »

Depending on the situation, I either use imagemagick (https://imagemagick.org) or libvips (https://www.libvips.org/) to do both the scaling and sharpening operations.

It's been ages since I've used IrfanView, so I don't know if it has any sharpening options available.
coulonnus
active poster
Posts: 1635
Joined: Thu Jul 12, 2007 8:53 am
notabot: 42
notabot2: Human
Location: Nice, France
Contact:

Re: How to eliminate non-uniform yellowing from a HathiTrust scan before converting to monochrome?

Post by coulonnus »

Bhm wrote: Thu May 28, 2026 4:37 pm I'm working on a score from HathiTrust in preparation for uploading it to IMSLP.* It's not already monochrome or even grayscale, so I'm running it through ScanTailor to convert it to monochrome as well as set uniform page sizes. (I already removed the Google watermarks.) [...]
I am having trouble with your example. Please provide the link to a Hathitrust score already present on imslp.
I'll see what I can do. Need perhaps my procedure of adaptative threshold if some regions of the score are dark (symbols and background) and some other are light.
Post Reply