Superpixel Benchmark
Superpixel benchmark, tools and algorithms.
Static Public Member Functions | List of all members
SuperpixelTools Class Reference

Superpixel utilities. More...

#include <superpixel_tools.h>

Static Public Member Functions

static int computeRegionSizeFromSuperpixels (const cv::Mat &image, int superpixels)
 Compute region size from desired number of superpixels. More...
 
static void computeHeightWidthFromSuperpixels (const cv::Mat &image, int superpixels, int &height, int &width)
 Compute width and height for the given number of superpixels. More...
 
static void computeHeightWidthLevelsFromSuperpixels (const cv::Mat &image, int superpixels, int &height, int &width, int &levels)
 Compute width, height and levels for the given number of superpixels. More...
 
static void computeRegionSizeLevels (const cv::Mat &image, int superpixels, int &region_size, int &levels)
 Compute region size and levels for the given number of superpixels. More...
 
static void relabelSuperpixels (cv::Mat &labels)
 Relabel superpixel segmentation. More...
 
static void computeLabelsFromBoundaries (const cv::Mat &image, const cv::Mat &boundaries, cv::Mat &labels, int BOUNDARY_VALUE=-1, int INNER_VALUE=-2)
 Compute label map from boundaries by assigning boundary pixels to the nearest superpixel and flooding the connected components. More...
 
static void assignBoundariesToSuperpixels (const cv::Mat &image, const cv::Mat &boundaries, cv::Mat &labels, int BOUNDARY_VALUE=-1)
 Assigns boundary pixels (indicated by -1) to the nearest superpixel (indicated by labels >= 0). More...
 
static int countSuperpixels (const cv::Mat &labels)
 Count number of superpixels. More...
 
static int relabelConnectedSuperpixels (cv::Mat &labels)
 Relabel superpixels based on connected components. More...
 
static int enforceMinimumSuperpixelSize (const cv::Mat &image, cv::Mat &labels, int size)
 Enforce the minimum segment size by merging small superpixels with similar neighboring superpixels. More...
 
static int enforceMinimumSuperpixelSizeUpTo (const cv::Mat &image, cv::Mat &labels, int number)
 Enforce the minimum segment size by merging small superpixels with similar neighboring superpixels such that the given number of superpixels is merged. More...
 

Detailed Description

Superpixel utilities.

Copyright (c) 2016, David Stutz Contact: david.nosp@m..stu.nosp@m.tz@rw.nosp@m.th-a.nosp@m.achen.nosp@m..de, davidstutz.de All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
David Stutz

Member Function Documentation

void SuperpixelTools::assignBoundariesToSuperpixels ( const cv::Mat &  image,
const cv::Mat &  boundaries,
cv::Mat &  labels,
int  BOUNDARY_VALUE = -1 
)
static

Assigns boundary pixels (indicated by -1) to the nearest superpixel (indicated by labels >= 0).

Parameters
[in]imageimage to compute superpixels for
[in]boudnariesgiven boundaries to convert to superpixel labels
[in]BOUDARY_VALUEvalue a boundary pixel takes
void SuperpixelTools::computeHeightWidthFromSuperpixels ( const cv::Mat &  image,
int  superpixels,
int &  height,
int &  width 
)
static

Compute width and height for the given number of superpixels.

Parameters
[in]imageimage for the number of rows and cols
[in]superpixelsnumber of desired superpixels
[out]heightregion height to achieve desired number of superpixels
[out]widthregion width to achieve desired number of superpixels
void SuperpixelTools::computeHeightWidthLevelsFromSuperpixels ( const cv::Mat &  image,
int  superpixels,
int &  height,
int &  width,
int &  levels 
)
static

Compute width, height and levels for the given number of superpixels.

Parameters
[in]imageimage for the number of rows and cols
[in]superpixelsdesired number of superpixels
[out]heightregion height on lowest level
[out]widthregion width on lowest level
[out]levelsnumber of levels to achieve the desired number of superpixels
void SuperpixelTools::computeLabelsFromBoundaries ( const cv::Mat &  image,
const cv::Mat &  boundaries,
cv::Mat &  labels,
int  BOUNDARY_VALUE = -1,
int  INNER_VALUE = -2 
)
static

Compute label map from boundaries by assigning boundary pixels to the nearest superpixel and flooding the connected components.

Parameters
[in]imageimage to compute superpixel labels for
[in]boundariesgiven boundaries for image
[out]labelscomputed superpixel labels
[in]BOUDNARY_VALUEthe value a boundary pixel takes
[in]INNER_VALUEthe value an inner pixel takes
int SuperpixelTools::computeRegionSizeFromSuperpixels ( const cv::Mat &  image,
int  superpixels 
)
static

Compute region size from desired number of superpixels.

Parameters
[in]imageimage for number of rows and cols
[in]superpixelsnumber of desired superpixels
Returns
region size required for the desired number of superpixels on the given image size

Copyright (c) 2016, David Stutz Contact: david.nosp@m..stu.nosp@m.tz@rw.nosp@m.th-a.nosp@m.achen.nosp@m..de, davidstutz.de All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

void SuperpixelTools::computeRegionSizeLevels ( const cv::Mat &  image,
int  superpixels,
int &  region_size,
int &  levels 
)
static

Compute region size and levels for the given number of superpixels.

Parameters
[in]imageimage for the number of rows and cols
[in]superpixelsdesired number of superpixels
[out]region_sizeregion size on lowest level
[out]levelsnumber of levels to achieve desired number of superpixels
int SuperpixelTools::countSuperpixels ( const cv::Mat &  labels)
static

Count number of superpixels.

Parameters
[in]labelssuperpixel labels
Returns
number of superpixels
int SuperpixelTools::enforceMinimumSuperpixelSize ( const cv::Mat &  image,
cv::Mat &  labels,
int  size 
)
static

Enforce the minimum segment size by merging small superpixels with similar neighboring superpixels.

Parameters
[in]imageimage to enforce minimum superpixel size for
[in]labelssuperpixel labels
[in]sizeminimum superpixel size
Returns
new number of superpixels
int SuperpixelTools::enforceMinimumSuperpixelSizeUpTo ( const cv::Mat &  image,
cv::Mat &  labels,
int  number 
)
static

Enforce the minimum segment size by merging small superpixels with similar neighboring superpixels such that the given number of superpixels is merged.

Parameters
[in]imageimage to enforce minimum superpixels on
[in]labelssuperpixel labels
[in]numbernumber of desired superpixels after enforcing minimum size
int SuperpixelTools::relabelConnectedSuperpixels ( cv::Mat &  labels)
static

Relabel superpixels based on connected components.

Parameters
[in]labelssuperpixel labels to relabel as connected
void SuperpixelTools::relabelSuperpixels ( cv::Mat &  labels)
static

Relabel superpixel segmentation.

Parameters
[in]labelssuperpixel labels to relabel

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