Mark w
2013-06-04 15:58:48 UTC
There is this function in [Mahotas][1]: `bwperim` that returns an image
with only objects' contours.
How can I count contours and calculate the area of the objects and get a
new image with only the largest object?
Maybe similar to [opencv findcontours][2] and [cv2.contoursarea][3]
![image sample][4]
code:
path = 'image/2aJM6eB.jpg'
fork = mh.imread(path)
imgbnbin = fork[:,:,0]
bfork = imgbnbin < 150 # binarization
bfork = mh.morph.dilate(bfork, disk7)
bfork = mh.morph.close(bfork, disk3)
bwfork = mh.bwperim(bfork)
image after binarization, dilation,closing and bwperim:
![image after binarization, dilation,closing and bwperim][5]
[1]: https://pypi.python.org/pypi/mahotas
[2]:
http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours
[3]:
http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#double%20contourArea%28InputArray%20contour,%20bool%20oriented%29
[4]: Loading Image...
[5]: Loading Image...
with only objects' contours.
How can I count contours and calculate the area of the objects and get a
new image with only the largest object?
Maybe similar to [opencv findcontours][2] and [cv2.contoursarea][3]
![image sample][4]
code:
path = 'image/2aJM6eB.jpg'
fork = mh.imread(path)
imgbnbin = fork[:,:,0]
bfork = imgbnbin < 150 # binarization
bfork = mh.morph.dilate(bfork, disk7)
bfork = mh.morph.close(bfork, disk3)
bwfork = mh.bwperim(bfork)
image after binarization, dilation,closing and bwperim:
![image after binarization, dilation,closing and bwperim][5]
[1]: https://pypi.python.org/pypi/mahotas
[2]:
http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours
[3]:
http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#double%20contourArea%28InputArray%20contour,%20bool%20oriented%29
[4]: Loading Image...
[5]: Loading Image...
--
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.