2

I have the following image of a table enter image description here

I want to remove the background colors (blue, grey, white) and also reduce noise. I want to remove only the colors and I don't want to remove the table and text. After removing the background colors I will process it to OCR to extract the table with the text. (I want to extract the table contents including the text). I have Mathpix, a LaTeX OCR, but it is not able to recognize my image, so I want to remove the background color and reduce noise and then process OCR. So I want something like this, for example;

enter image description here

I tried Adobe Free Online Transparent Background Maker and Background Remover and I also tried vectorize the image but it gave me poor, unsatisfactory results. So how to remove background color and noise from a text image or any other alternative solution? Thanks in advance!

EDIT: I found a similar question on stack overflow remove background color in image processing for ocr, but the solutions are programming-based.

3
  • 1
    Do you have many tables like this? If it's just this one table it will be way faster to just manually write the text. First you need to manipulate the image, then run OCR, then manually compare the text with the image to spot errors (those superscript and subscript numbers might be a problem), then create a table with the text.
    – Wolff
    Jul 17, 2021 at 11:12
  • It's difficult. You can achieve some degree of success, but still you will manually need to fix a few areas.
    – Vikas
    Jul 17, 2021 at 11:13
  • I would reset this text, not mess with a raster image. Quality will never be outmatched by resetting as live text,. Even if OCR is not possible, I'd type it manually.
    – Scott
    Jul 17, 2021 at 18:22

2 Answers 2

2

You'll need to do some manual editing to get a result like that. Don't think there is anyway to do this fully automatically. I'll let you be the judge whether manual editing, then using OCR, will be quicker than simply retyping the text.

If you don't have Photoshop, get GIMP it's free.

  1. Using the rectangle select tool, click and drag to select the entire blue section. Then do Edit > Copy

  2. Do Edit > Paste as > New Layer in Place

  3. Do Colours > Invert, this will invert the selected layer, to create black text, the blue background will turn yellow (the inverse of blue).

You should get a result like this:

enter image description here

  1. Do Colours > Components > Mono Mixer, then in the dialog that opens move the Red channel slider to lighten the yellow area

enter image description here

  1. Do Image > Flatten Image, then do Colours > Desaturate > Desaturate

  2. Do Colours > Curves and create a curve like this by clicking and dragging on the diagonal line.

enter image description here

To save as an image file, do File > Export As, and set file extension to PNG.

4
  • Seems to me that thos provess would be easy to do automatically with imagemagik
    – joojaa
    Jul 17, 2021 at 13:43
  • @joojaa I tried doing such, images vary so much that it rarely match two of them (the gray is a bit darker/lighter, etc.) so it makes it difficult. AI, though, could do it. Where you train a system to understand what the end result should be and it would certainly be able to do it automatically. Jul 17, 2021 at 19:42
  • @AlexisWilke, yeah I think you're right. If the images are all different, you'd need some kind of AI enabled software. I'm not aware of any that exist for this specific task, but I'm sure somebody is probably working on it! My method could probably be simplified a bit if I think about it. The need to copy to a new layer isn't really required. A simple selection would be enough before applying the invert and mono mixer.
    – Billy Kerr
    Jul 17, 2021 at 19:58
  • @AlexisWilke there are ways to deal with that by blurring and recombining
    – joojaa
    Jul 18, 2021 at 8:14
1

This is pretty easily done with the free Windows app Paint.net.

What you want to do is open your picture in Paint.net. Then according to the screenshot below, you'll want to:

  1. click on the menu "Adjustments" and
  2. select "Levels". Then you remove the histogram hump at
  3. from your picture (this hump corresponds to the gray background behind your text). To do this, move the slider at
  4. downwards, and the slider at
  5. also downwards, in order to make the text black again.

Done!

As suggested by @Billy Kerr, you could invert the white text with the blue background first to also have this text prepared for OCR.

adjust Histogram levels in Paint.net

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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