I'm using ImageMagick service to pre-process the receipt image before using tesseract-OCR engine to extract texts. I need to remove the background of the receipts. I've gone through masking to remove the border here. But I'm unable to create the mask for the receipts.
However, I've tried to remove shadows from the receipt images.
Initial Image (Example receipt)
convert input.png -colorspace gray \
\( +clone -blur 0x2 \) +swap -compose divide -composite \
-linear-stretch 5%x0% photocopy.png
After the code is applied:
I've tried the code below to make all colors except white to black but this does not seem to be totally blacking out the background of photocopy.png.
convert receipt.jpg -fill black -fuzz 20% +opaque "#ffffff" black_border.jpg
Is there any way to remove the border of the receipt image? Or create any kind of masks out of the image? Note: I need to remove noise and border for multiple images with different backgrounds.