PSMM / SLIC-Superpixels

Implementation of the SLIC superpixel algorithm to work with OpenCV
292 stars 147 forks source link

Assigned newly connectivity-enforced clusters to the clusters instance variable. #1

Closed CalumMurray closed 4 years ago

CalumMurray commented 10 years ago

When create_connectivity() was called, it only updated the local clusters copy.

CalumMurray commented 10 years ago

Actually, having done this, it seems to corrupt the cluster indexing, locations etc. Any ideas?

PSMM commented 10 years ago

There is indeed something not right in that function. I've got that part not from the paper, but from the corresponding source code: http://ivrg.epfl.ch/research/superpixels

Maybe something is done wrong here what has been done right in their code. It's been a while since I've seen that code, but it might also not be a vital part of the process.

On 24-03-14 20:47, Calum Murray wrote:

Actually, having done this, it seems to corrupt the cluster indexing, locations etc. Any ideas?

— Reply to this email directly or view it on GitHub https://github.com/PSMM/SLIC-Superpixels/pull/1#issuecomment-38491711.

CalumMurray commented 10 years ago

I've had a look through the original source code, and I can't see anything wrong really. But I guess, as well as reassigning clusters = new_clusters, you'll also need to reassign the centers, distances and center_counts? I've also updated this to work with the newer OpenCV 2 API by the way (e.g. cv::Mat and friends).

CalumMurray commented 10 years ago

What I've done is append "create_connectivity()" to the end of "generatesuperpixels()", then re run the code commented /* Clear the center values. / / Compute the new cluster centers. / /_ Normalize the clusters. */

Which looks like it's working so far, although there will almost certainly be a more efficient way to do it inline while create_connectivity is running or something.