ITK
5.0.0
Insight Segmentation and Registration Toolkit
|
#include <itkSLICImageFilter.h>
Simple Linear Iterative Clustering (SLIC) super-pixel segmentation.
The Simple Linear Iterative Clustering (SLIC) algorithm groups pixels into a set of labeled regions or super-pixels. Super-pixels follow natural image boundaries, are compact, and are nearly uniform regions which can be used as a larger primitive for more efficient computation. The SLIC algorithm can be viewed as a spatially constrained iterative k-means method.
The original algorithm was designed to cluster on the joint domain of the images index space and it's CIELAB color space. This implementation works with images of arbitrary dimension as well as scalar, single channel, images and most multi-component image types including ITK's arbitrary length VectorImage.
The distance between a pixel and a cluster is the sum of squares of the difference between their joint range and domains ( index and value ). The computation is done in index space with scales provided by the SpatialProximityWeight parameters.
The output is a label image with each label representing a superpixel cluster. Every pixel in the output is labeled, and the starting label id is zero.
This code was contributed in the Insight Journal paper: "Scalable Simple Linear Iterative Clustering (SSLIC) Using a Generic and Parallel Approach" by Lowekamp B. C., Chen D. T., Yaniv Z., Yoo T. S. https://hdl.handle.net/1926/3596
Definition at line 60 of file itkSLICImageFilter.h.
Classes | |
struct | UpdateCluster |
Public Types | |
using | ClusterComponentType = double |
using | ClusterType = vnl_vector_ref< ClusterComponentType > |
using | ConstPointer = SmartPointer< const Self > |
using | ContinuousIndexType = ContinuousIndex< typename PointType::ValueType, ImageDimension > |
using | DistanceImageType = Image< DistanceType, ImageDimension > |
using | DistanceType = TDistancePixel |
using | IndexType = typename InputImageType::IndexType |
using | InputImageType = TInputImage |
using | InputPixelType = typename InputImageType::PixelType |
using | OutputImageRegionType = typename OutputImageType::RegionType |
using | OutputImageType = TOutputImage |
using | OutputPixelType = typename OutputImageType::PixelType |
using | Pointer = SmartPointer< Self > |
using | PointType = typename InputImageType::PointType |
using | Self = SLICImageFilter |
using | Superclass = ImageToImageFilter< TInputImage, TOutputImage > |
using | SuperGridSizeType = FixedArray< unsigned int, ImageDimension > |
Public Types inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
using | ConstPointer = SmartPointer< const Self > |
using | InputImageConstPointer = typename InputImageType::ConstPointer |
using | InputImagePixelType = typename InputImageType::PixelType |
using | InputImagePointer = typename InputImageType::Pointer |
using | InputImageRegionType = typename InputImageType::RegionType |
using | InputImageType = TInputImage |
using | OutputImagePixelType = typename Superclass::OutputImagePixelType |
using | OutputImageRegionType = typename Superclass::OutputImageRegionType |
using | Pointer = SmartPointer< Self > |
using | Self = ImageToImageFilter |
using | Superclass = ImageSource< TOutputImage > |
Public Types inherited from itk::ImageSource< TOutputImage > | |
using | ConstPointer = SmartPointer< const Self > |
using | DataObjectIdentifierType = Superclass::DataObjectIdentifierType |
using | DataObjectPointer = DataObject::Pointer |
using | DataObjectPointerArraySizeType = Superclass::DataObjectPointerArraySizeType |
using | OutputImagePixelType = typename OutputImageType::PixelType |
using | OutputImagePointer = typename OutputImageType::Pointer |
using | OutputImageRegionType = typename OutputImageType::RegionType |
using | OutputImageType = TOutputImage |
using | Pointer = SmartPointer< Self > |
using | Self = ImageSource |
using | Superclass = ProcessObject |
Public Types inherited from itk::ProcessObject | |
using | ConstPointer = SmartPointer< const Self > |
using | DataObjectIdentifierType = DataObject::DataObjectIdentifierType |
using | DataObjectPointer = DataObject::Pointer |
using | DataObjectPointerArray = std::vector< DataObjectPointer > |
using | DataObjectPointerArraySizeType = DataObjectPointerArray::size_type |
using | MultiThreaderType = MultiThreaderBase |
using | NameArray = std::vector< DataObjectIdentifierType > |
using | Pointer = SmartPointer< Self > |
using | Self = ProcessObject |
using | Superclass = Object |
Public Types inherited from itk::Object | |
using | ConstPointer = SmartPointer< const Self > |
using | Pointer = SmartPointer< Self > |
using | Self = Object |
using | Superclass = LightObject |
Public Types inherited from itk::LightObject | |
using | ConstPointer = SmartPointer< const Self > |
using | Pointer = SmartPointer< Self > |
using | Self = LightObject |
Static Public Member Functions | |
static Pointer | New () |
Static Public Member Functions inherited from itk::Object | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool flag) |
Static Public Member Functions inherited from itk::LightObject | |
static void | BreakOnError () |
static Pointer | New () |
Static Public Attributes | |
static constexpr unsigned int | ImageDimension = TInputImage::ImageDimension |
Static Public Attributes inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
static constexpr unsigned int | InputImageDimension = TInputImage::ImageDimension |
static constexpr unsigned int | OutputImageDimension = TOutputImage::ImageDimension |
Static Public Attributes inherited from itk::ImageSource< TOutputImage > | |
static constexpr unsigned int | OutputImageDimension = TOutputImage::ImageDimension |
Private Types | |
using | MarkerImageType = Image< unsigned char, ImageDimension > |
using | UpdateClusterMap = std::map< vcl_size_t, UpdateCluster > |
Private Member Functions | |
void | RelabelConnectedRegion (const IndexType &seed, OutputPixelType requiredLabel, OutputPixelType outputLabel, std::vector< IndexType > &indexStack) |
Private Attributes | |
double | m_AverageResidual |
std::vector< ClusterComponentType > | m_Clusters |
DistanceImageType::Pointer | m_DistanceImage |
FixedArray< double, ImageDimension > | m_DistanceScales |
bool | m_EnforceConnectivity {true} |
bool | m_InitializationPerturbation {true} |
MarkerImageType::Pointer | m_MarkerImage |
unsigned int | m_MaximumNumberOfIterations |
std::mutex | m_Mutex |
std::vector< ClusterComponentType > | m_OldClusters |
double | m_SpatialProximityWeight { 10.0 } |
SuperGridSizeType | m_SuperGridSize |
std::vector< UpdateClusterMap > | m_UpdateClusterPerThread |
Additional Inherited Members | |
Protected Types inherited from itk::ImageToImageFilter< TInputImage, TOutputImage > | |
using | InputToOutputRegionCopierType = ImageToImageFilterDetail::ImageRegionCopier< Self::OutputImageDimension, Self::InputImageDimension > |
using | OutputToInputRegionCopierType = ImageToImageFilterDetail::ImageRegionCopier< Self::InputImageDimension, Self::OutputImageDimension > |
Static Protected Member Functions inherited from itk::ImageSource< TOutputImage > | |
static const ImageRegionSplitterBase * | GetGlobalDefaultSplitter () |
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION | ThreaderCallback (void *arg) |
Protected Attributes inherited from itk::ImageSource< TOutputImage > | |
bool | m_DynamicMultiThreading |
Protected Attributes inherited from itk::ProcessObject | |
TimeStamp | m_OutputInformationMTime |
bool | m_Updating |
Protected Attributes inherited from itk::LightObject | |
std::atomic< int > | m_ReferenceCount |
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::ClusterComponentType = double |
Definition at line 94 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::ClusterType = vnl_vector_ref<ClusterComponentType> |
Definition at line 95 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::ConstPointer = SmartPointer< const Self > |
Definition at line 70 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::ContinuousIndexType = ContinuousIndex<typename PointType::ValueType, ImageDimension> |
Definition at line 92 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::DistanceImageType = Image<DistanceType, ImageDimension> |
Definition at line 88 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::DistanceType = TDistancePixel |
Definition at line 87 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::IndexType = typename InputImageType::IndexType |
Definition at line 90 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::InputImageType = TInputImage |
Image type information.
Definition at line 83 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::InputPixelType = typename InputImageType::PixelType |
Definition at line 84 of file itkSLICImageFilter.h.
|
private |
Definition at line 215 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::OutputImageRegionType = typename OutputImageType::RegionType |
Definition at line 97 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::OutputImageType = TOutputImage |
Definition at line 85 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::OutputPixelType = typename OutputImageType::PixelType |
Definition at line 86 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::Pointer = SmartPointer< Self > |
Definition at line 69 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::PointType = typename InputImageType::PointType |
Definition at line 91 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::Self = SLICImageFilter |
Standard class type aliases.
Definition at line 67 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::Superclass = ImageToImageFilter< TInputImage, TOutputImage > |
Definition at line 68 of file itkSLICImageFilter.h.
using itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::SuperGridSizeType = FixedArray< unsigned int, ImageDimension > |
Definition at line 99 of file itkSLICImageFilter.h.
|
private |
Definition at line 213 of file itkSLICImageFilter.h.
|
protected |
|
overrideprotecteddefault |
|
overrideprotectedvirtual |
If an imaging filter needs to perform processing after all processing threads have completed, the filter can can provide an implementation for AfterThreadedGenerateData(). The execution flow in the default GenerateData() method will be: 1) Allocate the output buffer 2) Call BeforeThreadedGenerateData() 3) Spawn threads, calling ThreadedGenerateData() in each thread. 4) Call AfterThreadedGenerateData() Note that this flow of control is only available if a filter provides a ThreadedGenerateData() method and NOT a GenerateData() method.
Reimplemented from itk::ImageSource< TOutputImage >.
|
overrideprotectedvirtual |
If an imaging filter needs to perform processing after the buffer has been allocated but before threads are spawned, the filter can can provide an implementation for BeforeThreadedGenerateData(). The execution flow in the default GenerateData() method will be: 1) Allocate the output buffer 2) Call BeforeThreadedGenerateData() 3) Spawn threads, calling ThreadedGenerateData() in each thread. 4) Call AfterThreadedGenerateData() Note that this flow of control is only available if a filter provides a ThreadedGenerateData() method and NOT a GenerateData() method.
Reimplemented from itk::ImageSource< TOutputImage >.
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::Object.
|
protected |
|
protected |
|
virtual |
|
virtual |
|
overrideprotectedvirtual |
Generate full output and require full input
Reimplemented from itk::ProcessObject.
|
overrideprotectedvirtual |
A version of GenerateData() specific for image processing filters. This implementation will split the processing across multiple threads. The buffer is allocated by this method. Then the BeforeThreadedGenerateData() method is called (if provided). Then, a series of threads are spawned each calling DynamicThreadedGenerateData(). After all the threads have completed processing, the AfterThreadedGenerateData() method is called (if provided). If an image processing filter cannot be threaded, the filter should provide an implementation of GenerateData(). That implementation is responsible for allocating the output buffer. If a filter can be threaded, it should NOT provide a GenerateData() method but should provide a DynamicThreadedGenerateData() instead.
Reimplemented from itk::ImageSource< TOutputImage >.
|
virtual |
Get the current average cluster residual.
After each iteration the residual is computed as the distance between the current clusters and the previous. This is averaged so that the value is independent of the number of clusters.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Run-time type information (and related methods).
Reimplemented from itk::ImageToImageFilter< TInputImage, TOutputImage >.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
static |
Method for creation through the object factory.
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::ImageToImageFilter< TInputImage, TOutputImage >.
|
private |
|
virtual |
Post processing step to enforce superpixel morphology.
Enable an additional computation which ensures all label pixels of the same value are spatially connected. Disconnected labeled components are assigned a new value if of sufficient size, or are relabeled to the previously encountered value if small.
|
virtual |
Enable perturbation of initial cluster center location.
After grid based initialization, this option enables moving the initial cluster center location to the minimum gradient in a small neighborhood. If the grid size is less than three this is automatically disabled.
|
virtual |
Number of iterations to run.
Specify the number of iterations to run when optimizing the clusters.
|
virtual |
The spatial weight for the distance function.
Increasing this value makes the superpixel shape more regular, but more varied in image values. The range of the pixel values and image dimension can effect the appropriate value.
|
virtual |
The expected superpixel size and shape.
The requested size of a superpixel used to form a regular grid for initialization and limits the search space for pixels. The size may be set anisotropically to provide a directional bias. This may be set to reflect spacing of this image.
void itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::SetSuperGridSize | ( | unsigned int | factor | ) |
void itk::SLICImageFilter< TInputImage, TOutputImage, TDistancePixel >::SetSuperGridSize | ( | unsigned int | i, |
unsigned int | factor | ||
) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
ImageDimension constants
Definition at line 79 of file itkSLICImageFilter.h.
|
private |
Definition at line 226 of file itkSLICImageFilter.h.
|
private |
Definition at line 198 of file itkSLICImageFilter.h.
|
private |
Definition at line 219 of file itkSLICImageFilter.h.
|
private |
Definition at line 197 of file itkSLICImageFilter.h.
|
private |
Definition at line 222 of file itkSLICImageFilter.h.
|
private |
Definition at line 224 of file itkSLICImageFilter.h.
|
private |
Definition at line 220 of file itkSLICImageFilter.h.
|
private |
Definition at line 194 of file itkSLICImageFilter.h.
|
private |
Definition at line 227 of file itkSLICImageFilter.h.
|
private |
Definition at line 199 of file itkSLICImageFilter.h.
|
private |
Definition at line 195 of file itkSLICImageFilter.h.
|
private |
Definition at line 193 of file itkSLICImageFilter.h.
|
private |
Definition at line 217 of file itkSLICImageFilter.h.