Python Opencv morphological closing gives src data type = 0 is not supported

David picture David · Nov 10, 2015 · Viewed 14.3k times · Source

I'm trying to morphologically close a volume with a ball structuring element created by the function SE3 = skimage.morphology.ball(8). When using closing = cv2.morphologyEx(volume_start, cv2.MORPH_CLOSE, SE) it returns TypeError: src data type = 0 is not supported Do you know how to solve this issue? Thank you

Answer

Daniel Azemar picture Daniel Azemar · May 27, 2017

Make sure volume_start is dtype=uint8. You can convert it with volume_start = np.array(volume_start, dtype=np.uint8).

Or nicer: volume_start = volume_start.astype(np.uint8)