opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.34k stars 5.75k forks source link

Function to get number of pixels per label and centroid for Superpixel classes #2136

Open jasjuang opened 5 years ago

jasjuang commented 5 years ago
System information (version)
Detailed description

I think it will be very useful if we can directly query the 1. number of pixels per label, and 2. the centroid per label from functions for the super pixel classes. @cbalint13 what do you think?

cbalint13 commented 5 years ago

@jasjuang ,

  1. For number of superpixel there is already GetNumberOfSuperpixels exposed in C++ and Python.

    As for statistics inside centroids there could be many like average intensity (per channel), area (as number of pixels), std deviation of intensities (as smoothnes), top-k histogram of intensities, edge contour compactness, number of neighbours and perhaps many more. Stacking them would be usefull as input features for any kind of classifiers. R: I would not tie such feature extractors into ximgproc class, would leave cvision people choose implement their favourit features on top of the superpixels.

  2. Regarding centroid i am afraid there are many options (center of geometry, center of gravity etc..), the centerof itself would be a larger CVision subject. Not counting the efficiency of such numerical methods.

I believe we could create some geometry functions in OpenCV specialized to get centroids in multiple flavours but their place would be along e.g. convexhull and similar geometry functions. R: I would not tie them inside ximgproc class. Of course they should be numerically efficient implementations accepting more flexible inputs (e.g. countour, points collection).

jasjuang commented 5 years ago

I can understand your arguments on the centroid functionality. However, GetNumberOfSuperpixels only returns the total number of super pixels in an image. I am referring to the total number of pixels per super pixel. I had to write a for loop to manually count them and I think this is a common information a lot of downstream users will like to know.