OpenCV for Unity 2.6.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.XimgprocModule.SuperpixelSEEDS Class Reference

Class implementing the SEEDS (Superpixels Extracted via Energy-Driven Sampling) superpixels algorithm described in [VBRV14] . More...

Public Member Functions

void getLabelContourMask (Mat image)
 Returns the mask of the superpixel segmentation stored in SuperpixelSEEDS object.
 
void getLabelContourMask (Mat image, bool thick_line)
 Returns the mask of the superpixel segmentation stored in SuperpixelSEEDS object.
 
void getLabels (Mat labels_out)
 Returns the segmentation labeling of the image.
 
int getNumberOfSuperpixels ()
 Calculates the superpixel segmentation on a given image stored in SuperpixelSEEDS object.
 
void iterate (Mat img)
 Calculates the superpixel segmentation on a given image with the initialized parameters in the SuperpixelSEEDS object.
 
void iterate (Mat img, int num_iterations)
 Calculates the superpixel segmentation on a given image with the initialized parameters in the SuperpixelSEEDS object.
 
- Public Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm
virtual void clear ()
 Clears the algorithm state.
 
virtual bool empty ()
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.
 
virtual string getDefaultName ()
 
IntPtr getNativeObjAddr ()
 
void save (string filename)
 
- Public Member Functions inherited from OpenCVForUnity.DisposableObject
void Dispose ()
 
void ThrowIfDisposed ()
 

Static Public Member Functions

static new SuperpixelSEEDS __fromPtr__ (IntPtr addr)
 
- Static Public Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm
static Algorithm __fromPtr__ (IntPtr addr)
 
- Static Public Member Functions inherited from OpenCVForUnity.DisposableObject
static IntPtr ThrowIfNullIntPtr (IntPtr ptr)
 

Protected Member Functions

override void Dispose (bool disposing)
 
- Protected Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm
- Protected Member Functions inherited from OpenCVForUnity.DisposableOpenCVObject
 DisposableOpenCVObject ()
 
 DisposableOpenCVObject (bool isEnabledDispose)
 
 DisposableOpenCVObject (IntPtr ptr)
 
 DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableObject
 DisposableObject ()
 
 DisposableObject (bool isEnabledDispose)
 

Additional Inherited Members

- Package Functions inherited from OpenCVForUnity.CoreModule.Algorithm
- Package Attributes inherited from OpenCVForUnity.DisposableOpenCVObject
- Properties inherited from OpenCVForUnity.DisposableObject
bool IsDisposed [get, protected set]
 
bool IsEnabledDispose [get, set]
 

Detailed Description

Class implementing the SEEDS (Superpixels Extracted via Energy-Driven Sampling) superpixels algorithm described in [VBRV14] .

The algorithm uses an efficient hill-climbing algorithm to optimize the superpixels' energy function that is based on color histograms and a boundary term, which is optional. The energy function encourages superpixels to be of the same color, and if the boundary term is activated, the superpixels have smooth boundaries and are of similar shape. In practice it starts from a regular grid of superpixels and moves the pixels or blocks of pixels at the boundaries to refine the solution. The algorithm runs in real-time using a single CPU.

Member Function Documentation

◆ __fromPtr__()

static new SuperpixelSEEDS OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.__fromPtr__ ( IntPtr addr)
static

◆ Dispose()

override void OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.Dispose ( bool disposing)
protectedvirtual

◆ getLabelContourMask() [1/2]

void OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.getLabelContourMask ( Mat image)

Returns the mask of the superpixel segmentation stored in SuperpixelSEEDS object.

Parameters
imageReturn: CV_8UC1 image mask where -1 indicates that the pixel is a superpixel border, and 0 otherwise.
thick_lineIf false, the border is only one pixel wide, otherwise all pixels at the border are masked.

The function return the boundaries of the superpixel segmentation.

Note
  • (Python) A demo on how to generate superpixels in images from the webcam can be found at opencv_source_code/samples/python2/seeds.py
    • (cpp) A demo on how to generate superpixels in images from the webcam can be found at opencv_source_code/modules/ximgproc/samples/seeds.cpp. By adding a file image as a command line argument, the static image will be used instead of the webcam.
    • It will show a window with the video from the webcam with the superpixel boundaries marked in red (see below). Use Space to switch between different output modes. At the top of the window there are 4 sliders, from which the user can change on-the-fly the number of superpixels, the number of block levels, the strength of the boundary prior term to modify the shape, and the number of iterations at pixel level. This is useful to play with the parameters and set them to the user convenience. In the console the frame-rate of the algorithm is indicated.

image

◆ getLabelContourMask() [2/2]

void OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.getLabelContourMask ( Mat image,
bool thick_line )

Returns the mask of the superpixel segmentation stored in SuperpixelSEEDS object.

Parameters
imageReturn: CV_8UC1 image mask where -1 indicates that the pixel is a superpixel border, and 0 otherwise.
thick_lineIf false, the border is only one pixel wide, otherwise all pixels at the border are masked.

The function return the boundaries of the superpixel segmentation.

Note
  • (Python) A demo on how to generate superpixels in images from the webcam can be found at opencv_source_code/samples/python2/seeds.py
    • (cpp) A demo on how to generate superpixels in images from the webcam can be found at opencv_source_code/modules/ximgproc/samples/seeds.cpp. By adding a file image as a command line argument, the static image will be used instead of the webcam.
    • It will show a window with the video from the webcam with the superpixel boundaries marked in red (see below). Use Space to switch between different output modes. At the top of the window there are 4 sliders, from which the user can change on-the-fly the number of superpixels, the number of block levels, the strength of the boundary prior term to modify the shape, and the number of iterations at pixel level. This is useful to play with the parameters and set them to the user convenience. In the console the frame-rate of the algorithm is indicated.

image

◆ getLabels()

void OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.getLabels ( Mat labels_out)

Returns the segmentation labeling of the image.

Each label represents a superpixel, and each pixel is assigned to one superpixel label.

Parameters
labels_outReturn: A CV_32UC1 integer array containing the labels of the superpixel segmentation. The labels are in the range [0, getNumberOfSuperpixels()].

The function returns an image with ssthe labels of the superpixel segmentation. The labels are in the range [0, getNumberOfSuperpixels()].

◆ getNumberOfSuperpixels()

int OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.getNumberOfSuperpixels ( )

Calculates the superpixel segmentation on a given image stored in SuperpixelSEEDS object.

The function computes the superpixels segmentation of an image with the parameters initialized with the function createSuperpixelSEEDS().

◆ iterate() [1/2]

void OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.iterate ( Mat img)

Calculates the superpixel segmentation on a given image with the initialized parameters in the SuperpixelSEEDS object.

This function can be called again for other images without the need of initializing the algorithm with createSuperpixelSEEDS(). This save the computational cost of allocating memory for all the structures of the algorithm.

Parameters
imgInput image. Supported formats: CV_8U, CV_16U, CV_32F. Image size & number of channels must match with the initialized image size & channels with the function createSuperpixelSEEDS(). It should be in HSV or Lab color space. Lab is a bit better, but also slower.
num_iterationsNumber of pixel level iterations. Higher number improves the result.

The function computes the superpixels segmentation of an image with the parameters initialized with the function createSuperpixelSEEDS(). The algorithms starts from a grid of superpixels and then refines the boundaries by proposing updates of blocks of pixels that lie at the boundaries from large to smaller size, finalizing with proposing pixel updates. An illustrative example can be seen below.

image

◆ iterate() [2/2]

void OpenCVForUnity.XimgprocModule.SuperpixelSEEDS.iterate ( Mat img,
int num_iterations )

Calculates the superpixel segmentation on a given image with the initialized parameters in the SuperpixelSEEDS object.

This function can be called again for other images without the need of initializing the algorithm with createSuperpixelSEEDS(). This save the computational cost of allocating memory for all the structures of the algorithm.

Parameters
imgInput image. Supported formats: CV_8U, CV_16U, CV_32F. Image size & number of channels must match with the initialized image size & channels with the function createSuperpixelSEEDS(). It should be in HSV or Lab color space. Lab is a bit better, but also slower.
num_iterationsNumber of pixel level iterations. Higher number improves the result.

The function computes the superpixels segmentation of an image with the parameters initialized with the function createSuperpixelSEEDS(). The algorithms starts from a grid of superpixels and then refines the boundaries by proposing updates of blocks of pixels that lie at the boundaries from large to smaller size, finalizing with proposing pixel updates. An illustrative example can be seen below.

image


The documentation for this class was generated from the following file: