Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Split bounding rectangle on white spaces columnwise

outputImage = img.copy()

npaContours, npaHierarchy = cv2.findContours(rectdilation.copy(),
cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)

for npaContour in npaContours:
x,y,w,h = cv2.boundingRect(npaContour) if w < 10 or h < 10: continue

cv2.rectangle(outputImage,(x,y),(x+w,y+h),(0,255,0),2)

if cv2.contourArea(npaContour) > MIN_CONTOUR_AREA:          

    **[intX, intY, intW, intH] = cv2.boundingRect(npaContour)**

*split npaContour white spaces columnwise

click to hide/show revision 2
None

updated 2020-06-22 07:48:38 -0600

berak gravatar image

Split bounding rectangle on white spaces columnwise

.

outputImage = img.copy()

img.copy() npaContours, npaHierarchy = cv2.findContours(rectdilation.copy(),
cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)

for npaContour in npaContours:
x,y,w,h = cv2.boundingRect(npaContour) if w < 10 or h < 10: continue

 cv2.rectangle(outputImage,(x,y),(x+w,y+h),(0,255,0),2)

 if cv2.contourArea(npaContour) > MIN_CONTOUR_AREA:          

    **[intX,     [intX, intY, intW, intH] = cv2.boundingRect(npaContour)**
cv2.boundingRect(npaContour)

*split npaContour white spaces columnwise

Split bounding rectangle on white spaces columnwise

.image description

outputImage = img.copy()

outputImage = img.copy()

npaContours, npaHierarchy = cv2.findContours(rectdilation.copy(),        
                                             cv2.RETR_EXTERNAL,                 
                                             cv2.CHAIN_APPROX_SIMPLE)          

for npaContour in npaContours:                         
    x,y,w,h = cv2.boundingRect(npaContour)
    if w < 10 or h < 10:
        continue  

    cv2.rectangle(outputImage,(x,y),(x+w,y+h),(0,255,0),2)

    if cv2.contourArea(npaContour) > MIN_CONTOUR_AREA:          

        [intX, intY, intW, intH] = cv2.boundingRect(npaContour)

*split npaContour white spaces columnwise

Split bounding rectangle on white spaces columnwise

image description

outputImage = img.copy()

npaContours, npaHierarchy = cv2.findContours(rectdilation.copy(),        
                                             cv2.RETR_EXTERNAL,                 
                                             cv2.CHAIN_APPROX_SIMPLE)          

for npaContour in npaContours:                         
    x,y,w,h = cv2.boundingRect(npaContour)
    if w < 10 or h < 10:
        continue  

    cv2.rectangle(outputImage,(x,y),(x+w,y+h),(0,255,0),2)

    if cv2.contourArea(npaContour) > MIN_CONTOUR_AREA:          

        [intX, intY, intW, intH] = cv2.boundingRect(npaContour)

*split npaContour white spaces columnwise

Split bounding rectangle on white spaces columnwise

image descriptionimage description

outputImage = img.copy()

npaContours, npaHierarchy = cv2.findContours(rectdilation.copy(),        
                                             cv2.RETR_EXTERNAL,                 
                                             cv2.CHAIN_APPROX_SIMPLE)          

for npaContour in npaContours:                         
    x,y,w,h = cv2.boundingRect(npaContour)
    if w < 10 or h < 10:
        continue  

    cv2.rectangle(outputImage,(x,y),(x+w,y+h),(0,255,0),2)

    if cv2.contourArea(npaContour) > MIN_CONTOUR_AREA:          

        [intX, intY, intW, intH] = cv2.boundingRect(npaContour)

*split npaContour white spaces columnwise

Split bounding rectangle on white spaces columnwise

image description

snippet:

 outputImage = img.copy()

img.copy()

    npaContours, npaHierarchy = cv2.findContours(rectdilation.copy(),        
                                              cv2.RETR_EXTERNAL,                 
                                              cv2.CHAIN_APPROX_SIMPLE)          

 for npaContour in npaContours:                         
     x,y,w,h = cv2.boundingRect(npaContour)
     if w < 10 or h < 10:
         continue  

     cv2.rectangle(outputImage,(x,y),(x+w,y+h),(0,255,0),2)

     if cv2.contourArea(npaContour) > MIN_CONTOUR_AREA:          

         [intX, intY, intW, intH] = cv2.boundingRect(npaContour)

*split npaContour white spaces columnwise