1

I need to segment out tables from an image. For this, I have the table mask for the given image based on which I need to extract the table from the image.
Here is the code for getting the masks :

# getting the predictions
table_mask_pred, col_mask_pred = tablenet.predict(image)
# getting the argmax values and expanding the dimensionality
table_mask_pred = tf.argmax(table_mask_pred, axis=-1)
table_mask_pred = table_mask_pred[..., tf.newaxis][0]
col_mask_pred = tf.argmax(col_mask_pred, axis=-1)
col_mask_pred = col_mask_pred[..., tf.newaxis][0]

Here is the original image, the mask for the columns in the image and the mask for the table Masks for the image

I now want to use this table mask to extract the table from the image. The strategy that I am using right now is something like this:

  1. Multiply the table mask and the image element-wise to get the table out.
  2. Multiply the final image with 255 to get the pixel values back in the range 0-255.

However, this gives me the following image:

Filtered image

But, I want the filtered image to have a white background and not be so dark since I will be using the filtered image to extract the table contents using OCR.
How do I go about doing that?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Aman Savaria
  • 164
  • 1
  • 1
  • 11
  • 1
    OCR should be pretty independent of your background color – Eumel Aug 06 '21 at 12:08
  • So even if I do OCR on the mask I'm getting, the results would be fine? If that is the case then my problem is solved. Thanks a lot. – Aman Savaria Aug 06 '21 at 17:51
  • 1
    OCR is independent of background color,you can find the paper [here](http://www.m.cs.osakafu-u.ac.jp/cbdar2007/proceedings/papers/O1-1.pdf). Take a look at similar issue https://stackoverflow.com/a/39309744/14290244. –  Aug 12 '21 at 02:41

0 Answers0