ImageSegmentation.jl icon indicating copy to clipboard operation
ImageSegmentation.jl copied to clipboard

proposal: add SLIC superpixel algorithm

Open Cuda-Chen opened this issue 5 years ago • 9 comments

Recently, I wrote a SLIC superpixel algorithm in pure Julia. For watching this repo almost a year, I found there was no one add SLIC into ImageSegmentation.jl. Therefore, I would like to add my implementation, though it needs a lot of reworking to fit into.

Cuda-Chen avatar Jul 27 '20 02:07 Cuda-Chen

There's a WIP PR https://github.com/johnnychen94/SuperPixels.jl/pull/2 that I failed to continue because I'm unsure how to enforce pixel connectivity when I wrote that. If you're interested, could you help finish that part?

I've introduced a SuperPixel struct to make post-processing easier there.

johnnychen94 avatar Jul 27 '20 03:07 johnnychen94

@johnnychen94 I think I can give it a try :)

By the way, will prune_segments be a good start of enforce connectivity?

Cuda-Chen avatar Jul 27 '20 03:07 Cuda-Chen

By the way, will prune_segments be a good start of enforce connectivity?

Probably! TBH I'm don't have much knowledge of image segmentation, I suggest we follow the original implementation unless we know what's actually happening there.

Ha, I just saw your note that "Current I do not implement enforce connectivity part." 😄

johnnychen94 avatar Jul 27 '20 03:07 johnnychen94

OK, I will realize how the original implementation does on enforce connectivity. And we can watch how PSMM does on enforce connectivity, too.

Cuda-Chen avatar Jul 27 '20 03:07 Cuda-Chen

And we can watch how PSMM does on enforce connectivity, too.

Yes, it could be a good recourse, the only issue is that PSMM doesn't have a license file. We may need to list it as a reference if you find it useful.

On the other hand, scikit-image is a better resource as it has a clear license (Modified BSD).

Cref: https://github.com/JuliaImages/ImageFiltering.jl/pull/81#issuecomment-429640026

johnnychen94 avatar Jul 27 '20 03:07 johnnychen94

After reading your comment, I have to admit my SLIC implementation in Julia have reference laixintao's work.

I have added the reference in my Julia SLIC repo as a good practice.

Cuda-Chen avatar Jul 27 '20 05:07 Cuda-Chen

Is this work still in progress? Or do folks just use https://github.com/johnnychen94/SuperPixels.jl for SLIC?

jsundram avatar Feb 09 '21 19:02 jsundram

Still in WIP, I need to work through https://github.com/johnnychen94/SuperPixels.jl/pull/6 first to find out what the best type design is in Julia. Hopefully, we could work on ImageSegmentation.jl to merge everything in SuperPixels.jl.

FYI, with @Cuda-Chen's help, a working SLIC version is available in the analyze branch (https://github.com/johnnychen94/SuperPixels.jl/blob/analyze/src/analyze.jl), it's usable but I'm not satisfied with the internal type design in SuperPixels and I plan to rework it entirely so I haven't make a release yet.

johnnychen94 avatar Feb 10 '21 05:02 johnnychen94

Thanks @johnnychen94! This code works for me -- I wonder if you are open to just having _slic return a SegmentedImage type (which is what the rest of ImageSegmentation.jl returns)? I've reworked the code in analyze branch to do that . . . it looks as follows (see the SegmentedImage function at the bottom of the file)

https://gist.github.com/jsundram/e78bc63cb131fb66cb7c811bdd9a3e0e

jsundram avatar Feb 18 '21 16:02 jsundram