Removing the entire background from a mathematical formula image

81 Views Asked by At

Consider the following image:

enter image description here

I would like to remove the entire background (everything that does not belong to the) to be left only with the integral. My purpose is to make it easier to get the integral in LaTeX from OCR.

1

There are 1 best solutions below

2
fmw42 On BEST ANSWER

Is this what you want? Using Imagemagick, I do a division normalization followed by a thresholding.

Input:

enter image description here

convert image.png \( +clone -blur 99 \) +swap -compose divide -composite -negate -threshold 18% -negate result.png

enter image description here

Adjust the threshold as desired.

ADDITION

Add morphology to thicken the lines

convert image.png \( +clone -blur 99 \) +swap -compose divide -composite -negate -threshold 25% -negate -morphology erode diamond:1 result.png

enter image description here