Connected Components Labeling on Label Matrix
5 views (last 30 days)
I try to implement SLIC Superpixels Method on MATLAB. I've done the clustering part and as writers said in this paper I need to apply a connected components labeling algorithm to get rid of bad labels. Upper image is output of SLIC code written by writers of paper and the other one is output of my SLIC code but without connected components part. Input of the connected components algorithm must be the "Label Matrix" which has same size as image but contains only labels which have more values than just 0 or 1. So how can I correct the bad labels?
Image Analyst on 4 Jun 2017
superpixels() already gives the labeled (connected components) image. https://www.mathworks.com/help/images/ref/superpixels.html?s_tid=srchtitle
Show your code where you called superpixels().
Also define what it is that you think makes a label "bad" as opposed to good. It doesn't make sense to have labels as only 0 or 1. You will have numbers up as high as the number of superpixel regions that were found. Virtually every region in there will have label numbers more than 1.
And you say "Input of the connected components algorithm must be the "Label Matrix"" Not true. Labeling and determining the connected components are the same thing. There are two functions for that - bwlabel() and bwconncomp() - and they both work off binary images. It doesn't make sense to send an already-labeled image into bwlabel() or bwconncomp() as you said. Actually the output of the connected components algorithm will be the "Label Matrix", NOT the input.
Bottom line - I don't know what you need to do. Your said your overall task is "to implement SLIC Superpixels Method" and that is done by the superpixels() function. Use it, if you haven't already. I don't know what else to answer.
Alex Taylor on 5 Jun 2017
If you want to implement SLIC yourself, rather than use the implementation that is already in the Image Processing Toolbox as superpixels(), then I would recommend looking at the following site which includes reference implementations of SLIC:
The MATLAB implementation of SLIC already performs the post-processing step you are referring to in which labeled regions below some minimum size are merged with adjacent regions.