Dealing with scans of 100-year-old, pencil-written notes in which the paper has darkened and the pencil lightened so contrast and readability have both diminished, the goal is to preserve page pixels (unmarked by pencil) as-is while only darkening the pencil ones. (Otherwise, one could just tinker with brightness/contrast, which is easy.)
- * Since the pencil pixels are gray, it would be great if there were an adjustment to set the allowable deviation from true gray for pixel selection, R±x = G = B±x ('x' = allowable deviation).
* To be selected, a pixel would also have to pass below a maximum threshhold, avg(RGB) < t ('t' = upper threshhold. Note no lower threshhold needed, though if present, could be set at 0.)
* And the last parameter would be the amount of darkening (or could be a negative brightening) to apply to selected pixels.
Code: Select all
For each pixel:
If within gray color tolerance AND below an upper limit of brightness
Darken the pixel by selected amount
Otherwise
Do nothing
Good community here; hope someone can help.