MATLAB: Finding Connected Components of Superpixels

cccellcomponentsconnectedimage processingImage Processing ToolboxMATLABsegmentationsuperpixel

If I know the idx of the following figure to be [ 261 325 331 333 339]. What sort of algorithm can I use that would detect that idxs [325 331 333 339] are all connected to one another, and that 261 has no connected components? The end goal being detecting regions that have 3 or more connected superpixels.
One method I am thinking of is using bwconncomp, which will return the 2 connected objects. And then for each connected object, check weather the idxs are 'contained' in it. I think this might not be a good solution though. Please any feedback is welcome. Thank you all kindly.

Best Answer

There is a superpixels() function in the Image Processing Toolbox. Using that could significantly simplify your homwwork assignment.