How to find text area after dilating the image
This is the original image:
At first I applied the sobel operator to the image:
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
sobel = cv.Sobel(gray, cv.CV_8U, 1, 0, 1)
x = cv.Sobel(gray, cv.CV_16S, 1, 0)
y = cv.Sobel(gray, cv.CV_16S, 0, 1)
absX = cv.convertScaleAbs(x)
absY = cv.convertScaleAbs(y)
sobel = cv.addWeighted(absX, 0.2, absY, 0.8, 0)
Then I dilated the image:
kernel = cv.getStructuringElement(cv.MORPH_RECT, (24, 14))
dilate = cv.dilate(sobel, kernel, iterations=1)
findContours
can't find the rect of text, it detected the irrelevant rect on the left of the image: