A question about SSLIC genericity

Hello,

I have just seen today the beta release of ITK 5 and was happy to see that SLIC was included in the future release. I have not tested yet but looking at the code, it misses something for an application I have long waited to try. I see there are two distance functions that are rather fixed. However, I was interested in having the choice on the pixel distance to test several ones.

However the two distance functions are not virtual. Do you think there would be a way to include an optional way to have other distances in the filter (and if possible external ones) ? I am keen in trying to implement that but would like to have your input on it first.

Thanks

1 Like

Hello Olivier,

Glad to hear you are happy to see the SLIC filter :slight_smile:

Having the ability to experiment with different functions to measure the distance between joint domains ( location + intensity) is certainly a good idea. It was on my wish list to implement, but spent the time on scalability analysis of the algorithm instead.

The two distance functions you mention , both implement the same metric but with different parameters. This was part of the performance improvements that were performed. This also makes implementing custom distance metrics more difficult.

To improve the class to support custom distance functions the following should be done:

  • Move the two distance functions into a separate struct/class perhaps called DefaultSLICDistanceFunctor. They are not static because they need access to m_DistanceScales. This will have to be a member variable of the new class with Set/Get methods. ( These methods should be const functions, not sure why they are not. )
  • Add a new template parameter to SLICImageFilter, and default it to the new functor class.
  • Construct the new functor and set the distance scale in the SLIC filter. The Update the call to the distance metric to use the new functor class.

The tricky part is getting all the types to propagate to the functor. Does this sound do able?

2 Likes