View Source Evision.XImgProc.SuperpixelSEEDS (Evision v0.2.9)

Summary

Types

t()

Type that represents an XImgProc.SuperpixelSEEDS struct.

Functions

Clears the algorithm state

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read

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

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

Returns the segmentation labeling of the image.

Returns the segmentation labeling of the image.

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

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

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

Reads algorithm parameters from a file storage

Stores algorithm parameters in a file storage

Types

@type t() :: %Evision.XImgProc.SuperpixelSEEDS{ref: reference()}

Type that represents an XImgProc.SuperpixelSEEDS struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

@spec clear(Keyword.t()) :: any() | {:error, String.t()}
@spec clear(t()) :: t() | {:error, String.t()}

Clears the algorithm state

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()

Python prototype (for reference only):

clear() -> None
@spec empty(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(t()) :: boolean() | {:error, String.t()}

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Return
  • retval: bool

Python prototype (for reference only):

empty() -> retval
Link to this function

getDefaultName(named_args)

View Source
@spec getDefaultName(Keyword.t()) :: any() | {:error, String.t()}
@spec getDefaultName(t()) :: binary() | {:error, String.t()}

getDefaultName

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Return

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.

Python prototype (for reference only):

getDefaultName() -> retval
Link to this function

getLabelContourMask(named_args)

View Source
@spec getLabelContourMask(Keyword.t()) :: any() | {:error, String.t()}
@spec getLabelContourMask(t()) :: Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Keyword Arguments
  • thick_line: bool.

    If false, the border is only one pixel wide, otherwise all pixels at the border are masked.

Return
  • image: Evision.Mat.t().

    Return: CV_8UC1 image mask where -1 indicates that the pixel is a superpixel border, and 0 otherwise.

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

Python prototype (for reference only):

getLabelContourMask([, image[, thick_line]]) -> image
Link to this function

getLabelContourMask(self, opts)

View Source
@spec getLabelContourMask(t(), [{:thick_line, term()}] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Keyword Arguments
  • thick_line: bool.

    If false, the border is only one pixel wide, otherwise all pixels at the border are masked.

Return
  • image: Evision.Mat.t().

    Return: CV_8UC1 image mask where -1 indicates that the pixel is a superpixel border, and 0 otherwise.

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

Python prototype (for reference only):

getLabelContourMask([, image[, thick_line]]) -> image
@spec getLabels(Keyword.t()) :: any() | {:error, String.t()}
@spec getLabels(t()) :: Evision.Mat.t() | {:error, String.t()}

Returns the segmentation labeling of the image.

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Return
  • labels_out: Evision.Mat.t().

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

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

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

Python prototype (for reference only):

getLabels([, labels_out]) -> labels_out
@spec getLabels(t(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Returns the segmentation labeling of the image.

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Return
  • labels_out: Evision.Mat.t().

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

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

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

Python prototype (for reference only):

getLabels([, labels_out]) -> labels_out
Link to this function

getNumberOfSuperpixels(named_args)

View Source
@spec getNumberOfSuperpixels(Keyword.t()) :: any() | {:error, String.t()}
@spec getNumberOfSuperpixels(t()) :: integer() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
Return
  • retval: integer()

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

Python prototype (for reference only):

getNumberOfSuperpixels() -> retval
@spec iterate(Keyword.t()) :: any() | {:error, String.t()}
@spec iterate(t(), Evision.Mat.maybe_mat_in()) :: t() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()

  • img: Evision.Mat.

    Input 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.

Keyword Arguments
  • num_iterations: integer().

    Number of pixel level iterations. Higher number improves the result.

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.

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

Python prototype (for reference only):

iterate(img[, num_iterations]) -> None
Link to this function

iterate(self, img, opts)

View Source
@spec iterate(t(), Evision.Mat.maybe_mat_in(), [{:num_iterations, term()}] | nil) ::
  t() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()

  • img: Evision.Mat.

    Input 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.

Keyword Arguments
  • num_iterations: integer().

    Number of pixel level iterations. Higher number improves the result.

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.

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

Python prototype (for reference only):

iterate(img[, num_iterations]) -> None
@spec read(Keyword.t()) :: any() | {:error, String.t()}
@spec read(t(), Evision.FileNode.t()) :: t() | {:error, String.t()}

Reads algorithm parameters from a file storage

Positional Arguments

Python prototype (for reference only):

read(fn) -> None
@spec save(Keyword.t()) :: any() | {:error, String.t()}
@spec save(t(), binary()) :: t() | {:error, String.t()}

save

Positional Arguments
  • self: Evision.XImgProc.SuperpixelSEEDS.t()
  • filename: String

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

Python prototype (for reference only):

save(filename) -> None
@spec write(Keyword.t()) :: any() | {:error, String.t()}
@spec write(t(), Evision.FileStorage.t()) :: t() | {:error, String.t()}

Stores algorithm parameters in a file storage

Positional Arguments

Python prototype (for reference only):

write(fs) -> None
@spec write(t(), Evision.FileStorage.t(), binary()) :: t() | {:error, String.t()}

write

Positional Arguments

Has overloading in C++

Python prototype (for reference only):

write(fs, name) -> None