Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to find text area after dilating the image

At first I applied the sobel operator to the image:

sobel

Then I dilated the image:

kernel = cv.getStructuringElement(cv.MORPH_RECT, (24, 14))
dilate = cv.dilate(binary, kernel, iterations=1)

image description

findContours can't find the rect of text, it detected the irrelevant rect on the left of the image:

image description

How to find text area after dilating the 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)

sobel

Then I dilated the image:

kernel = cv.getStructuringElement(cv.MORPH_RECT, (24, 14))
dilate = cv.dilate(binary, cv.dilate(sobel, kernel, iterations=1)

image description

findContours can't find the rect of text, it detected the irrelevant rect on the left of the image:

image description

How to find text area after dilating the image

This is the original image:

original

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)

sobel

Then I dilated the image:

kernel = cv.getStructuringElement(cv.MORPH_RECT, (24, 14))
dilate = cv.dilate(sobel, kernel, iterations=1)

image description

findContours can't find the rect of text, it detected the irrelevant rect on the left of the image:

image description