# What image processing operation should I use to remove fuzzy black area

I'm performing some rudimentary OCR on some images that I have. The image below is from a VIN tag in a car. The image was originally color with a lot of glare that made some of the characters illegible. I performed the following operations.

• Color Invert (tag was black and text was white, I wanted the reverse)
• Color Threshold to get rid of the worst of the glare.
• Make image black+white only
• Erode/Dilate in order to tinker with the text to make it easier for Tesseract OCR to read.
• Run Tesseract OCR to extract the characters

The issue that I'm having now is that the black "fuzz" that surrounds the sticker is slowing down Tesseract. What I would like is the name of some operation or a series of steps that I can regularly use in a case like this to get rid of these distortions. I could manually write something to look at squares of the image and if there's way more dark then light, replace with white. There has to be some formal image processing technique to handle this case that I just don't know of.

If I manually remove the black in the margins, my accuracy goes up substantially in Tesseract.

• Use edges to find the bright white area, and run tesseract only on that ? And lay of the erose/dilate unless you are really plagued by pixel noise. It will deform the letters. – Marco van de Voort Nov 11 '16 at 21:27

You can perform local averaging/blurring of the picture and then use a threshold to remove all areas that are too dark:

img = cv2.imread('k1aqp.png')
figure(figsize=(20,20))
subplot(2,2,1);
imshow(img)

subplot(2,2,2);
B = cv2.blur(img, (55,55), 0)
imshow(B)

subplot(2,2,3)