Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get contour area in skimage

I've defined contours in skimage following documenation:

contours = measure.find_contours(img, 0.8)

In OpenCV area could be obtained using:

cv2.contourArea(cnt)

Does skimage contains something similar (functionality for contour features)?

like image 334
MykolaSharhan Avatar asked Apr 30 '18 14:04

MykolaSharhan


1 Answers

I didn't find any similar function in scikit-image, however with some manipulation of the data you can use the function from opencv. You only need to expand the numpy object and convert it to float32 UMat.

# Expand numpy dimensions
c = np.expand_dims(countour.astype(np.float32), 1)
# Convert it to UMat object
c = cv2.UMat(c)
area = cv2.contourArea(c)
like image 96
Carlos Ramírez Avatar answered Sep 18 '22 16:09

Carlos Ramírez