Superpixel Benchmark
Superpixel benchmark, tools and algorithms.
|
Given a directory of superpixel segmentations and a directory of ground truth segmentations, this class is used to generate a CSV file of statistics of different metrics. More...
#include <evaluation_summary.h>
Classes | |
struct | EvaluationMetrics |
Available metrics, see evaluation.h. More... | |
struct | EvaluationStatistics |
Available statistics that may be computed for each metric. More... | |
struct | SuperpixelVisualizations |
Available superpixel visualizations, see visualization.h. More... | |
Protected Member Functions | |
int | countMetrics () |
Count number of metrics used. More... | |
void | evaluateHeader (std::stringstream &output, std::vector< std::string > &metric_order) |
Add header to output. More... | |
void | evaluate (const cv::Mat &sp_segmentation, const cv::Mat >_segmentation, const cv::Mat &image, cv::Mat &data, std::stringstream &output) |
Actually do the evaluation. More... | |
void | visualize (const cv::Mat &sp_segmentation, const cv::Mat >_segmentation, const cv::Mat &image, std::string name, int t=0) |
Visualize given segmentation. More... | |
void | correlate (const cv::Mat &mat_results, const std::vector< std::string > &metric_order, cv::Mat &mat_correlation, std::string &csv_correlation) |
Compute correlation between all metrics. More... | |
int | countStatistics (int gt_max) |
Count the number of statistics to be used. More... | |
void | validateStatistics () |
Validate and correct statistics. More... | |
void | summaryHeader (const std::vector< int > >, std::stringstream &output) |
Add the summary header to output. More... | |
void | summarize (const std::vector< int > >, const cv::Mat &data, int j, cv::Mat &mat_summary, std::stringstream &output) |
Summarize a specific column of the evaluation data (corresponding to a particular metric). More... | |
float | computeMean (const std::vector< int > gt, const cv::Mat &data, int j, std::vector< float > &mean, float &mean_min, float &mean_max) |
Compute mean statistic. More... | |
float | comuteMedian (const std::vector< int > gt, const cv::Mat &data, int j, std::vector< float > &median, float &median_min, float &median_max) |
Compute median statistic. More... | |
void | comuteMedianFirstAndThirdQuartile (const std::vector< int > gt, const cv::Mat &data, int j, std::vector< float > &median, std::vector< float > &first_q, std::vector< float > &thrid_q, float &median_min, float &first_q_min, float &third_q_min, float &median_max, float &first_q_max, float &second_q_max) |
Compute median, first quartile and third quartile. More... | |
void | comuteMinMax (const std::vector< int > gt, const cv::Mat &data, int j, std::vector< float > &min, std::vector< float > &max, float &min_min, float &max_min, float &min_max, float &max_max) |
Compute min/max over all ground truth segmentations. More... | |
float | computeStandardDeviation (const std::vector< int > gt, const cv::Mat &data, int j, const std::vector< float > &mean, std::vector< float > &std, float &std_min, float &std_max) |
Compute standard deviation over all ground truth segmentations. More... | |
Protected Attributes | |
EvaluationMetrics | evaluation_metrics |
Evaluation metrics to use. More... | |
EvaluationStatistics | evaluation_statistics |
Evaluation statistics to use. More... | |
SuperpixelVisualizations | superpixel_visualizations |
Visualizations to compute. More... | |
bool | compute_correlation |
Whether to compute correlation. More... | |
boost::filesystem::path | sp_directory |
Directory of superpixel segmentations. More... | |
boost::filesystem::path | gt_directory |
Directory of ground truth segmentations. More... | |
boost::filesystem::path | img_directory |
Directory of images. More... | |
boost::filesystem::path | results_file |
Path to results file. More... | |
boost::filesystem::path | correlation_file |
Path to correlation file. More... | |
boost::filesystem::path | summary_file |
Path to summary file. More... | |
boost::filesystem::path | vis_directory |
Path to visualization directory. More... | |
boost::filesystem::path | append_file |
Path to file to append summary to. More... | |
Given a directory of superpixel segmentations and a directory of ground truth segmentations, this class is used to generate a CSV file of statistics of different metrics.
Copyright (c) 2016, David Stutz Contact: david, davidstutz.de All rights reserved. .stu tz@rw th-a achen .de
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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.
EvaluationSummary::EvaluationSummary | ( | boost::filesystem::path | sp_directory, |
boost::filesystem::path | gt_directory, | ||
boost::filesystem::path | img_directory | ||
) |
Create an evaluation summary for the given directory.
The directory is assumed to contain several superpixel segmentations as CSV files. The files are assumed to be named according to the ground truth files, see below.
In addition, a directory containing ground truth segmentations as CSV files needs to be provided.
[in] | sp_directory | directory containing superpixel segmentations as CSV files |
[in] | gt_directory | directory containing ground truth segmentations as CSV files |
[in] | img_directory | directory containing the corresponding images as JPEG or PNG |
Copyright (c) 2016, David Stutz Contact: david, davidstutz.de All rights reserved. .stu tz@rw th-a achen .de
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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.
EvaluationSummary::EvaluationSummary | ( | boost::filesystem::path | sp_directory, |
boost::filesystem::path | gt_directory, | ||
boost::filesystem::path | img_directory, | ||
EvaluationMetrics | evaluation_metrics, | ||
EvaluationStatistics | evaluation_statistics | ||
) |
Constructor.
[in] | sp_directory | directory containing superpixel segmentations as CSV files |
[in] | gt_directory | directory containing ground truth segmentations as CSV files |
[in] | img_directory | directory containing the corresponding images as JPEG or PNG |
[in] | evaluation_metrics | evaluation metrics to use |
[in] | evaluation_statistics | evaluation statistics to compute |
EvaluationSummary::EvaluationSummary | ( | boost::filesystem::path | sp_directory, |
boost::filesystem::path | gt_directory, | ||
boost::filesystem::path | img_directory, | ||
EvaluationMetrics | evaluation_metrics, | ||
EvaluationStatistics | evaluation_statistics, | ||
SuperpixelVisualizations | superpixel_visualizations | ||
) |
Constructor.
[in] | sp_directory | directory containing superpixel segmentations as CSV files |
[in] | gt_directory | directory containing ground truth segmentations as CSV files |
[in] | img_directory | directory containing the corresponding images as JPEG or PNG |
[in] | evaluation_metrics | evaluation metrics to use |
[in] | evaluation_statistics | evaluation statistics to compute |
[in] | superpixel_visualizations | visualizations to create |
|
protected |
Compute mean statistic.
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
[in] | data | data to summarize |
[in] | j | the column |
[out] | mean | computed means as vector for each ground truth segmentation |
[out] | mean_min | minimum of means in case of multiple ground truth segmentations per image |
[out] | mean_max | maximum of means in case of multiple ground truth segmentations per image |
|
protected |
Compute standard deviation over all ground truth segmentations.
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
[in] | data | data to summarize |
[in] | j | the column |
[out] | mean | means as vector for each ground truth segmentation |
[out] | std | std as vector for each ground truth segmentation |
[out] | std_min | minimum of std over all ground truth segmentations |
[out] | std_max | maximum of std over all ground truth segmentations |
void EvaluationSummary::computeSummary | ( | int & | gt_max | ) |
Summarize the results; this is the main entrance point.
[out] | gt_max | the maxmimum number of ground truth used, for BSDS 5 for all other 1 |
|
protected |
Compute median statistic.
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
[in] | data | data to summarize |
[in] | j | the column |
[out] | median | computed medians as vector for each ground truth segmentation |
[out] | median_min | minimum of medians in case of multiple ground truth segmentations per image |
[out] | median_max | maximum of medians in case of multiple ground truth segmentations per image |
|
protected |
Compute median, first quartile and third quartile.
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
[in] | data | data to summarize |
[in] | j | the column |
[out] | median | computed medians as vector for each ground truth segmentation |
[out] | first_q | computed first quantiles as vector for each ground truth segmentation |
[out] | thrid_q | computed third quantiles as vector for each ground truth segmentation |
[out] | median_min | minimum of medians in case of multiple ground truth segmentations per image |
[out] | first_q_min | minimum of first quantiles in case of multiple ground truth segmentations per image |
[out] | third_q_min | minimum of quantiles in case of multiple ground truth segmentations per image |
[out] | median_max | maximum of medians in case of multiple ground truth segmentations per image |
[out] | first_q_max | maximum of first quantiles in case of multiple ground truth segmentations per image |
[out] | second_q_max | maximum of quantiles in case of multiple ground truth segmentations per image |
|
protected |
Compute min/max over all ground truth segmentations.
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
[in] | data | data to summarize |
[in] | j | the column |
[out] | min | minimum as vector for each ground truth segmentation |
[out] | max | maximum as vector for each ground truth segmentation |
[out] | min_min | minimum of minimum over all ground truth segmentations |
[out] | max_min | maximum of minimum over all ground truth segmentations |
[out] | min_max | minimum of maximum over all ground truth segmentations |
[out] | max_max | maximum of maximum over all ground truth segmentations |
|
protected |
Compute correlation between all metrics.
[in] | mat_results | matrix containing results in order to compute correlatiom |
[in] | metric_order | order of metrix used in mat_results |
[out] | mat_correlation | correlation matrix |
[out] | csv_correlation | correlation matrix as CSV string |
|
protected |
Count number of metrics used.
|
protected |
Count the number of statistics to be used.
[in] | gt_max | maximum number of ground truth segmentations to consider |
|
protected |
Actually do the evaluation.
[in] | sp_segmentation | superpixel labels as int image |
[in] | gt_segmentation | ground truth segmentation as int image |
[in] | image | corresponding image |
[in] | data | data matrix to append results to |
[in] | output | CSV file stream to append results to |
|
protected |
Add header to output.
[in] | output | the header of the CSV file to create |
[out] | metric_order | the order of the metrics |
bool EvaluationSummary::getComputeCorrelation | ( | ) |
Get whether correlation is computed.
void EvaluationSummary::getEvaluationMetrics | ( | EvaluationSummary::EvaluationMetrics & | evaluation_metrics | ) |
Get the evaluation metrics used.
[out] | evaluation_metrics | evaluation metrics used |
void EvaluationSummary::getEvaluationStatistics | ( | EvaluationSummary::EvaluationStatistics & | evaluation_statistics | ) |
Get the evaluation statistics used.
[out] | evaluation_statistics | evaluation statistics used |
void EvaluationSummary::getSuperpixelVisualizations | ( | EvaluationSummary::SuperpixelVisualizations & | superpixel_visualizations | ) |
Get the visualizations used.
[out] | superpixel_visualizations | visualizations used |
void EvaluationSummary::setAppendFile | ( | const boost::filesystem::path & | append_file | ) |
Add CSV file to append CSV output to.
[in] | append_file | path to CSV file to append to |
void EvaluationSummary::setComputeCorrelation | ( | bool | compute_correlation | ) |
Set whether to compute correlation.
[in] | compute_correlation | whether to compute correlation matrix |
void EvaluationSummary::setEvaluationMetrics | ( | const EvaluationMetrics & | evaluation_metrics | ) |
Set the evaluation metrics to compute.
[in] | evaluation_metrics | evaluation metrics to compute |
void EvaluationSummary::setEvaluationStatistics | ( | const EvaluationStatistics & | evaluation_statistics | ) |
Set the evaluation statistics to compute.
[in] | evaluation_statistics | evaluation statistics to compute |
void EvaluationSummary::setSuperpixelVisualizations | ( | const SuperpixelVisualizations & | superpixel_visualizations | ) |
Set the superpixel visualizations to compute.
[in] | superpixel_visualizations | visualizations to compute |
|
protected |
Summarize a specific column of the evaluation data (corresponding to a particular metric).
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
[in] | data | data to summarize |
[in] | j | the column |
[out] | mat_sumamry | summary as matrix |
[out] | output | summary as CSV string |
|
protected |
Add the summary header to output.
[in] | gt | ground truth indices to determine the number of ground truth segmentations |
|
protected |
Validate and correct statistics.
|
protected |
Visualize given segmentation.
[in] | sp_segmentation | superpixel labels as int image |
[in] | gt_segmentation | ground truth segmentation as int image |
[in] | image | corresponding image |
[in] | name | name or identifier of image to visualize |
[in] | t | ground truth number |
|
protected |
Path to file to append summary to.
|
protected |
Whether to compute correlation.
|
protected |
Path to correlation file.
|
protected |
Evaluation metrics to use.
|
protected |
Evaluation statistics to use.
|
protected |
Directory of ground truth segmentations.
|
protected |
Directory of images.
|
protected |
Path to results file.
|
protected |
Directory of superpixel segmentations.
|
protected |
Path to summary file.
|
protected |
Visualizations to compute.
|
protected |
Path to visualization directory.