for a image hsplit working but vsplit not working in python

Question:

Here img is an image of 6×10 size.

def splitBoxes(img):
cols= np.hsplit(img,6) 
for c in cols:
    rows = np.vsplit(c,10) // Problem in this line. error showing here. 
    cv2.imshow('COL', c) 
    cv2.waitKey(0)

Error message: array split does not result in an equal division

Answers:

I got my answer. For vsplit or hsplit we have to keep one thing in our mind that is:

For image we have to take a perfect size of height or width which is a divisor of the number we want to split. For Example:
np.vsplit(c,10) here "c" is a image, as I want to split this image vertically into 10 pieces so image must be multiplier of 10 as like 100, 200, 250… all are dividable by 10.
Thats all. Same as hsplit either for image or array.

Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.