9
\$\begingroup\$

A lot of questions include photographs of writing on paper (equations, diagrams, etc.) that were hastily taken in poor and/or uneven lighting. Is there a straightforward way to improve them?

\$\endgroup\$
0
11
\$\begingroup\$

Yes, there is.

I have created a procedure based on ImageMagick that seems to do a good job. You can see examples here: original vs improved, and also here (original vs improved).

The process is to first crop the image to remove all extraneous stuff outside the boundaries of the paper. For example, on the second one, I used:

convert -crop 3456x2000+0+1800 XGU75.jpg XGU75_a.jpg

Then, the following command uses a blurred copy of the image to approximate the lighting with the text and diagrams removed. This copy is negated and added to the original image in order to cancel out the effects of the uneven lighting, and then the contrast is stretched (normalized):

convert XGU75_a.jpg \( +clone -blur 30x30 -negate \) -compose Plus -composite -normalize XGU75_b.jpg

Finally, in some cases, it makes sense to convert the result to a binary (black and white rather than grayscale) PNG, which greatly reduces the file size:

convert -threshold 50000 XGU75_b.jpg XGU75_b.png

YMMV. Tweak the parameters as needed.

\$\endgroup\$
5
  • \$\begingroup\$ If you have Photoshop (or similar) you can use Curves to reduce midrange tones or enhance contrast. \$\endgroup\$ – Alan Campbell Jan 4 '18 at 23:47
  • 3
    \$\begingroup\$ @AlanCampbell Users who do not trust closed source software can use Gimp docs.gimp.org/en/gimp-tool-curves.html, which runs on most operating systems. \$\endgroup\$ – Jonas Stein Jan 5 '18 at 7:02
  • 2
    \$\begingroup\$ I really wouldn't expect moderators (user moderators or diamond ones) to put the time and effort into improving crappy questions with this method. If you do it, then that's awesome, but we really should be prompting the poster to ask a better question instead. Let the poster do the work by creating a readable schematic (it is not that hard to do using Circuitlab). We can compare this situation with the situation over at SO, when users are posting screenshots of their source code, instead of posting the code as formatted text. Such poor quality questions get closed and heavily down-voted. \$\endgroup\$ – Lundin Jan 8 '18 at 13:45
  • \$\begingroup\$ @Lundin: All good points. I'm addressing the edge case where a question is otherwise fairly good, except for the bad photo(s). Newbies can't be expected to know the intricacies of CircuitLab (face it, it is rather quirky) and cellphones don't generally have easily-accessible image processing tools. I happen to do image processing as part of my day job (real-time image enhancement of HD video in FPGAs), so I had a personal interest in seeing what could be done with readily-available tools. \$\endgroup\$ – Dave Tweed Jan 8 '18 at 17:07
  • \$\begingroup\$ These are similar to the process used on B/W photocopiers that maximize contrast ratio while minimizing loss of resolution with half-tones and gamma control. \$\endgroup\$ – Tony Stewart EE75 Aug 6 '20 at 15:45
1
\$\begingroup\$

I think you are going in the wrong direction here.

Since we have tools for both diagrams & equations, why not remove those pictures alltogether and replace them with the right tools?

To take it a step further, i believe we should enforce that as a rule, i do not want to decipher an equation or a diagram on a crappy picture when the site provides good tools to write very clear ones.

Besides, it is not that hard to take a decent-quality picture of a diagram.

\$\endgroup\$
0
\$\begingroup\$

There are many tools to enhance image to make it more readable. The best tool is the one you learn to use well and if you have a lot, one with fast GUI interface for interactive optimization or batch processing if the optimization is identical.

In terms of theory, we might call it a transform, where by applying Shannon's Law to optimize spectral signal/noise ratio (SNR) we can reduce the error rate in viewing the contents. The transforms can include cropping, histogram normalization or simply applying fixed gamma, contrast and brightness values then applying sharpening values with colour contrast enhancement.

There are many software tools that are quick and easy to use, but it depends what you know how to use. I have used Picassa, Gimp, Photoshop, PSP, but for the longest time I have used Irfanview (free). These are all windows tools but you may prefer iOS or android image edit tools which all can work if you know how to manually edit gamma, contrast and brightness.

Example of IrfanView ( which has most of the features of ImageMagick and supports all the adobe .8bf plugins, if you have them.)

Often crop and autocorrect are good enough, but edit and manual adjust can improve if you understand how.

Say, you wanted to read the characters on the Chinese Checkers. enter image description here It would take to long to show you how to automate or repeat saved settings, but this just to give you another snapshot impression of how image transformation can be done to improve readability.

From left original to right Bot.left corner going clockwise. 1) auto adjust 2) manual correct (gamma, contrast) 3) greyscale only 4) greyscale with gamma adjustment, contrast, brightness

Histogram graph of levels is inserted in some results to show the peak number of pixels at various levels from dark to light.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .