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

Provides measures to evaluate (over-) segmentations. More...

#include <evaluation.h>

Static Public Member Functions

static float computeUndersegmentationError (const cv::Mat &labels, const cv::Mat &gt)
 Compute the Undersegmentation error as follows: More...
 
static float computeOversegmentationError (const cv::Mat &labels, const cv::Mat &gt)
 
static float computeBoundaryRecall (const cv::Mat &labels, const cv::Mat &gt, float d=0.0025)
 Compute boundary recall: More...
 
static float computeBoundaryPrecision (const cv::Mat &labels, const cv::Mat &gt, float d=0.0025)
 Compute boundary precision: More...
 
static float computeExplainedVariation (const cv::Mat &labels, const cv::Mat &image)
 Compute the explained variation of the given segmentation. More...
 
static float computeNPUndersegmentationError (const cv::Mat &labels, const cv::Mat &gt)
 Computes the Undersegmentation Error (Neubert, Protzel): More...
 
static float computeLevinUndersegmentationError (const cv::Mat &labels, const cv::Mat &gt)
 Compute the Undersegmentation Error (Levinshtein et al.): More...
 
static float computeAchievableSegmentationAccuracy (const cv::Mat &labels, const cv::Mat &gt)
 Compute achievable segmentation accuracy as follows: More...
 
static float computeSumOfSquaredErrorRGB (const cv::Mat &labels, const cv::Mat &image)
 Compute Sum-of-Squared Error on RGB. More...
 
static float computeSumOfSquaredErrorXY (const cv::Mat &labels, const cv::Mat &image)
 Compute Sum-of-Squared Error XY. More...
 
static float computeMeanDistanceToEdge (const cv::Mat &labels, const cv::Mat &gt)
 Compute Mean Distance to Edge: More...
 
static float computeIntraClusterVariation (const cv::Mat &labels, const cv::Mat &image)
 Compute Intra-Cluster Variation, that is the average standard deviation over all superpixels. More...
 
static float computeCompactness (const cv::Mat &labels)
 Compute Compactness as follows: More...
 
static float computeContourDensity (const cv::Mat &labels)
 Contour Density is given as. More...
 
static float computeRegularity (const cv::Mat &labels)
 Regularity can be computed as the fraction of boundary pixels of a superpixels and the boundary pixels of the corresponding bounding boxes. More...
 
static int computeSuperpixels (const cv::Mat &labels)
 Count the number of superpixels. More...
 
static void computeSuperpixelSizes (const cv::Mat &labels, float &average_size, int &min_size, int &max_size, float &size_variation)
 Compute superpixel size statistics. More...
 
static float computeEdgeRecall (const cv::Mat &labels, const cv::Mat &edges, float d=0.0025)
 Compute edge recall based on a computed edge map. More...
 
static float computeAverageMetric (const std::vector< float > &values, const std::vector< float > &superpixels, int min_superpixels=200, int max_superpixels=5200)
 Computes the average of a metric, i.e. computes the integral of the metric in the given superpixel range using the trapezoidal rule. More...
 

Friends

class Visualization
 

Detailed Description

Provides measures to evaluate (over-) segmentations.

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

float Evaluation::computeAchievableSegmentationAccuracy ( const cv::Mat &  labels,
const cv::Mat &  gt 
)
static

Compute achievable segmentation accuracy as follows:

$ASA(G, S) = \frac{1}{N_t} \sum_{S_j \in S} |S_j \cap G_{g(j)}|$

where $g(j)$ is the ground truth segment with maximum overlap with $S_j$.

Parameters
[in]labelssuperpixel labels as int image [in] gt ground truth segmentation as int image
Returns
ASA(gt, labels)
float Evaluation::computeAverageMetric ( const std::vector< float > &  values,
const std::vector< float > &  superpixels,
int  min_superpixels = 200,
int  max_superpixels = 5200 
)
static

Computes the average of a metric, i.e. computes the integral of the metric in the given superpixel range using the trapezoidal rule.

Parameters
[in]valuesmetric values
[in]superpixelsnumber of superpixels corresponding to the metric values
[in]min_superpixelslower interval bound for intergration
[in]max_superpixelsupper interval bound for integration
float Evaluation::computeBoundaryPrecision ( const cv::Mat &  labels,
const cv::Mat &  gt,
float  d = 0.0025 
)
static

Compute boundary precision:

$Pre(S, G) = \frac{TP}{TP + FP}$

where TP is the number of true positives, and FP is the number of false positives.

For each boundary pixel in the G, the corresponding boundary pixel in S is allowed to deviate by a euclidean distance of d times the image diagonal.

Parameters
[in]labelssuperpixel labels as int image [in] gt ground truth segmentation as int image
[in]dfraction of the diagonal to use as tolerance
Returns
Pre(labels, gt)
float Evaluation::computeBoundaryRecall ( const cv::Mat &  labels,
const cv::Mat &  gt,
float  d = 0.0025 
)
static

Compute boundary recall:

$Rec(S, G) = \frac{TP}{TP + FN}$

where TP is the number of true positives, and FN is the number of false negatives.

For each boundary pixel in the G, the corresponding boundary pixel in S is allowed to deviate by a euclidean distance of d times the image diagonal.

Parameters
[in]labelssuperpixel labels as int image
[in]gtground truth segmentation as int image
[in]dfraction of the diagonal to use as tolerance
Returns
Rec(labels, gt)

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.

float Evaluation::computeCompactness ( const cv::Mat &  labels)
static

Compute Compactness as follows:

$CO(S) = \sum_{S_j in S} \frac{|S_j|}{N} \frac{4*pi*A(S_j)}{L(S_j)*L(S_j)}$

where $A(S_j)$ is the area and $L(S_j)$ the perimeter of the superpixel $S_j$.

Parameters
[in]labelssuperpixel labels as int image
Returns
CO(labels)
float Evaluation::computeContourDensity ( const cv::Mat &  labels)
static

Contour Density is given as.

$CD(S) = \frac{|C|}{N}$

where C is the set of all contours int he superpixel segmentation and N the number of pixels.

Parameters
[in]labelssuperpixel labels as int image
Returns
CD(labels)
float Evaluation::computeEdgeRecall ( const cv::Mat &  labels,
const cv::Mat &  edges,
float  d = 0.0025 
)
static

Compute edge recall based on a computed edge map.

Parameters
[in]labelssuperpixel labels as int image
[in]edgesand edge map as unsigned char image
[in]dfraction of the diagonal used as tolerance
Returns
edge recall
float Evaluation::computeExplainedVariation ( const cv::Mat &  labels,
const cv::Mat &  image 
)
static

Compute the explained variation of the given segmentation.

Parameters
[in]labelssuperpixel labels as int image
[in]imageimage of the corresponding superpixel labels
Returns
explained variation
float Evaluation::computeIntraClusterVariation ( const cv::Mat &  labels,
const cv::Mat &  image 
)
static

Compute Intra-Cluster Variation, that is the average standard deviation over all superpixels.

Parameters
[in]labelssuperpixel labels as int image
[in]imageimage corresponding to the superpixel labels
Returns
intra-cluster variation
float Evaluation::computeLevinUndersegmentationError ( const cv::Mat &  labels,
const cv::Mat &  gt 
)
static

Compute the Undersegmentation Error (Levinshtein et al.):

$UE_{Levin}(S, G) = \frac{1}{|G|} \sum_{G_i \in G} \frac{\sum_{S_j \cap G_i \neq \emptyset} |S_j| - |G_i|}{|G_i|}$

Parameters
[in]labelssuperpixel labels as int image [in] gt ground truth segmentation as int image
Returns
UE_Levin(labels, gt)
float Evaluation::computeMeanDistanceToEdge ( const cv::Mat &  labels,
const cv::Mat &  gt 
)
static

Compute Mean Distance to Edge:

$MDE(S, G) = \frac{1}{|B|} \sum_{b \in B} D(b)$

where B is the set of boundary pixels in the ground truth segmentation G and D is a distance transform image of the superpixel segmentation S.

Parameters
[in]labelssuperpixel labels as int image
[in]gtground truth segmentation as int image
Returns
MDE(labels, gt)
float Evaluation::computeNPUndersegmentationError ( const cv::Mat &  labels,
const cv::Mat &  gt 
)
static

Computes the Undersegmentation Error (Neubert, Protzel):

$UE_{NP}(S, G) = \frac{1}{N} \sum_{G_i \in G} \sum_{S_j \cap G_i \neq \emptyset} \min\{S_j \cap G_i, S_j - g_i\}$

Parameters
[in]labelssuperpixel labels as int image [in] gt ground truth segmentation as int image
Returns
UE_NP(labels, gt)
float Evaluation::computeOversegmentationError ( const cv::Mat &  labels,
const cv::Mat &  gt 
)
static

$

Parameters
sv_video
gt_video
Returns
float Evaluation::computeRegularity ( const cv::Mat &  labels)
static

Regularity can be computed as the fraction of boundary pixels of a superpixels and the boundary pixels of the corresponding bounding boxes.

Parameters
[in]labelssuperpixel labels as int image
Returns
regularity
float Evaluation::computeSumOfSquaredErrorRGB ( const cv::Mat &  labels,
const cv::Mat &  image 
)
static

Compute Sum-of-Squared Error on RGB.

Parameters
[in]labelssuperpixel labels as int image
[in]imageimage corresponding to the superpixel labels
Returns
sum-of-squared error on RGB
float Evaluation::computeSumOfSquaredErrorXY ( const cv::Mat &  labels,
const cv::Mat &  image 
)
static

Compute Sum-of-Squared Error XY.

Parameters
[in]labelssuperpixel labels as int image
[in]imageimage corresponding to the superpixel labels
Returns
sum-of-squared error on XY
int Evaluation::computeSuperpixels ( const cv::Mat &  labels)
static

Count the number of superpixels.

Parameters
[in]labelssuperpixel labels as int image
Returns
number of superpixels
void Evaluation::computeSuperpixelSizes ( const cv::Mat &  labels,
float &  average_size,
int &  min_size,
int &  max_size,
float &  size_variation 
)
static

Compute superpixel size statistics.

Parameters
[in]labelssuperpixel labels as int image
[out]average_sizeaverage size of superpixels
[out]min_sizeminimum size of superpixels
[out]max_sizemaximum size of superpixels
float Evaluation::computeUndersegmentationError ( const cv::Mat &  labels,
const cv::Mat &  gt 
)
static

Compute the Undersegmentation error as follows:

$UE(G, S) = \frac{1}{N} = \sum_{S_j \in S} \min_{G_i} \{|G_i - S_j|\}$

Parameters
[in]labelssuperpixel labels as int image
[in]gtground truth segmentation as int image
Returns
UE(gt, labels)

Friends And Related Function Documentation

friend class Visualization
friend

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