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
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:
- Multiply the table mask and the image element-wise to get the table out.
- Multiply the final image with 255 to get the pixel values back in the range 0-255.
However, this gives me the following 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?