prittt / YACCLAB

YACCLAB: Yet Another Connected Components Labeling Benchmark
BSD 3-Clause "New" or "Revised" License
203 stars 37 forks source link
3d 3d-algorithms benchmark ccl ccl-algorithms cpp dataset gpu gpu-algorithm labeling-algorithms yacclab

Yet Another Connected Components Labeling Benchmark

release license contributors

OS Build Compiler OpenCV CMake GPU GitHub Actions Jenkins
Ubuntu
18.04 LTS
x64 gcc 9.3.0 4.1.2 3.13.5 None Build Status N/A
MacOS
(Darwin 19.6.0)
x64 AppleClang 12.0.0
(Xcode-12)
3.1.0 3.13.0 None Build Status N/A
Ubuntu
16.04 LTS
x64 gcc 5.4.0 4.4 3.10.3 2080Ti, CUDA 9.2 N/A Action Status
Ubuntu
20.04.02 LTS
x64 gcc 9.3.0 4.4 3.10.3 2080Ti, CUDA 11.4 N/A Action Status

Please include the following references when citing the YACCLAB project/dataset:

YACCLAB is an open source C++ project that enables researchers to test CCL algorithms under extremely variable points of view, running and testing algorithms on a collection of datasets described below. The benchmark performs the following tests which will be described later in this readme: correctness, average run-time (average), average run-time with steps (average_ws), density, size, granularity and memory accesses (memory). Notice that 8-connectivity is always used in the project.

Reproducible Research

This project follows the Reproducible Research paradigms and received the Reproducible Label in Pattern Recognition (RLPR).

## Requirements

To correctly install and run YACCLAB following packages, libraries and utilities are needed: - CMake 3.18 or higher (https://cmake.org); - OpenCV 3.0 or higher (http://opencv.org), required packages are `core`, `imgcodecs`, `imgproc`; - Gnuplot (http://www.gnuplot.info/); - One of your favourite IDE/compiler with C++14 support. GPU algorithms also require: - CUDA Toolkit 9.2 or higher (https://developer.nvidia.com/cuda-toolkit) and OpenCV `cudafeatures2d` package (as of OpenCV 4.5.3, package dependencies entail that required packages for CUDA algorithms are `core`, `cudafeatures2d`, `cudaarithm`, `cudafilters`, `cudaimgproc`, `cudawarping`, `cudev`, `features2d`, `imgcodecs`, `imgproc`). Notes for gnuplot: - on Windows system: be sure add gnuplot to system path if you want YACCLAB automatically generates charts. - on MacOS system: 'pdf terminal' seems to be not available due to old version of cairo, 'postscript' is used instead.

## Installation (refer to the image below) -

Clone the GitHub repository (HTTPS clone URL: https://github.com/prittt/YACCLAB.git) or simply download the full master branch zip file and extract it (e.g YACCLAB folder).

Cmake

CMake Configuration Variables

Name Meaning Default
YACCLAB_DOWNLOAD_DATASET whether to automatically download the 2D YACCLAB dataset or not OFF
YACCLAB_DOWNLOAD_DATASET_3D whether to automatically download the 3D YACCLAB dataset or not OFF
YACCLAB_ENABLE_3D enable/disable the support for 3D algorithms OFF
YACCLAB_ENABLE_CUDA enable/disable CUDA support OFF
YACCLAB_ENABLE_EPDT_19C enable/disable the EPDT_19C 3D algorithm which is based on a heuristic decision tree generated from a 3D mask with 19 conditions (may noticeably increase compilation time), it has no effect when YACCLAB_ENABLE_3D is OFF OFF
YACCLAB_ENABLE_EPDT_22C enable/disable the EPDT_22C 3D algorithm which is based on a heuristic decision tree generated from a 3D mask with 22 conditions (may noticeably increase compilation time), it has no effect when YACCLAB_ENABLE_3D is OFF OFF
YACCLAB_ENABLE_EPDT_26C enable/disable the EPDT_26C 3D algorithm which is based on a heuristic decision tree generated from a 3D mask with 26 conditions (may noticeably increase compilation time), it has no effect when YACCLAB_ENABLE_3D is OFF OFF
YACCLAB_FORCE_CONFIG_GENERATION whether to force the generation of the default configuration file (config.yaml) or not. When this flag is turned OFF any existing configuration file will not be overwritten OFF
YACCLAB_INPUT_DATASET_PATH path to the input dataset folder, where to find test datasets ${CMAKE_INSTALL_PREFIX}/input
YACCLAB_OUTPUT_RESULTS_PATH path to the output folder, where to save output results ${CMAKE_INSTALL_PREFIX}/output
OpenCV_DIR OpenCV installation path -

How to include a YACCLAB algorithm into your own project?

If your project requires a Connected Components Labeling algorithm and you are not interested in the whole YACCLAB benchmark you can use the connectedComponent function of the OpenCV library which implements the BBDT and SAUF algorithms since version 3.2., Spaghetti Labeling algorithm and BKE (for GPU only) since version 4.6.

Anyway, when the connectedComponents function is called, a lot of additional code will be executed together with the core function. If your project requires the best performance you can include an algorithm implemented in YACCLAB adding the following files to your project:

  1. labeling_algorithms.h and labeling_algorithms.cc which define the base class from which every algorithm derives from;
  2. yacclab_tensor.h, yacclab_tensor.cc which define input and output data tensors;
  3. label_solver.h and label_solver.cc which cointain the implementation of labels solving algorithms;
  4. memory_tester.h, performance_evaluator.h, volume_util.h, volume_util.cc, utilities.h, utilities.cc, system_info.h, system_info.cc, check_labeling.h, check_labeling.cc, file_manager.h, file_manager.cc, stream_demultiplexer.h, config_data.h, register.h, yacclab_test.h, progress_bar.h, cuda_mat3.hpp, cuda_types3.hpp, and cuda_mat3.inl.hpp just to make things work without changing the code;
  5. headers and sources files of the required algorithm/s. The association between algorithms and headers/sources files is reported in the tables below.

2D/3D CPU Algorithms

Algorithm Name Authors Year Acronym Required Files Templated on Labels Solver
- L. Di Stefano,
A. Bulgarelli [3]
1999 DiStefano labeling_distefano_1999.h
Contour Tracing F. Chang,
C.J. Chen,
C.J. Lu [1]
1999 CT labeling_fchang_2003.h
Run-Based Two-Scan L. He,
Y. Chao,
K. Suzuki [30]
2008 RBTS labeling_he_2008.h
Scan Array-based with Union Find K. Wu,
E. Otoo,
K. Suzuki [6]
2009 SAUF labeling_wu_2009.h, labeling_wu_2009_tree.inc
Stripe-Based Labeling Algorithm H.L. Zhao,
Y.B. Fan,
T.X. Zhang,
H.S. Sang [8]
2010 SBLA labeling_zhao_2010.h
Block-Based with Decision Tree C. Grana,
D. Borghesani,
R. Cucchiara [4]
2010 BBDT labeling_grana_2010.h, labeling_grana_2010_tree.inc
Configuration Transition Based L. He,
X. Zhao,
Y. Chao,
K. Suzuki [7]
2014 CTB labeling_he_2014.h, labeling_he_2014_graph.inc
Block-Based with Binary Decision Trees W.Y. Chang,
C.C. Chiu,
J.H. Yang [2]
2015 CCIT labeling_wychang_2015.h, labeling_wychang_2015_tree.inc, labeling_wychang_2015_tree_0.inc
Light Speed Labeling L. Cabaret,
L. Lacassagne,
D. Etiemble [5]
2016 LSL_STDI
LSL_STDZII
LSL_RLEIII
labeling_lacassagne_2016.h, labeling_lacassagne_2016_code.inc IV
Pixel Prediction C.Grana,
L. Baraldi,
F. Bolelli [9]
2016 PRED labeling_grana_2016.h, labeling_grana_2016_forest.inc, labeling_grana_2016_forest_0.inc
Directed Rooted Acyclic Graph F. Bolelli,
L. Baraldi,
M. Cancilla,
C. Grana [23]
2018 DRAG labeling_bolelli_2018.h, labeling_grana_2018_drag.inc
Spaghetti Labeling F. Bolelli,
S. Allegretti,
L. Baraldi,
C. Grana [26]
2019 Spaghetti labeling_bolelli_2019.h, labeling_bolelli_2019_forest.inc, labeling_bolelli_2019_forest_firstline.inc, labeling_bolelli_2019_forest_lastline.inc, labeling_bolelli_2019_forest_singleline.inc
PRED++ F. Bolelli,
S. Allegretti,
C. Grana [33]
2021 PREDpp labeling_PREDpp_2021.h, labeling_PREDpp_2021_center_line_forest_code.inc.h, labeling_PREDpp_2021_first_line_forest_code.inc.h
Tagliatelle Labeling F. Bolelli,
S. Allegretti,
C. Grana [33]
2021 Tagliatelle labeling_tagliatelle_2021.h, labeling_tagliatelle_2021_center_line_forest_code.inc.h, labeling_tagliatelle_2021_first_line_forest_code.inc.h, labeling_tagliatelle_2021_last_line_forest_code.inc.h, labeling_tagliatelle_2021_single_line_forest_code.inc.h
Bit-Run Two Scan W. Lee,
F. Bolelli,
S. Allegretti,
C. Grana [32]
2021 BRTSVII labeling_lee_2021_brts.h
Bit-Merge-Run Scan W. Lee,
F. Bolelli,
S. Allegretti,
C. Grana [32]
2021 BMRSVII labeling_lee_2021_bmrs.h
Null Labeling F. Bolelli,
M. Cancilla,
L. Baraldi,
C. Grana [13]
- NULLV labeling_null.h
SAUF 3D F. Bolelli,
S. Allegretti,
C. Grana [33]
2021 SAUF_3D labeling3D_SAUF_2021.h, labeling3D_SAUF_2021_tree_code.inc.h
SAUF++ 3D F. Bolelli,
S. Allegretti,
C. Grana [33]
2021 SAUFpp_3D labeling3D_SAUFpp_2021.h, labeling3D_SAUFpp_2021_tree_code.inc.h
PRED 3D F. Bolelli,
S. Allegretti,
C. Grana [33]
2021 PRED_3D labeling3D_PRED_2021.h, labeling3D_PRED_2021_center_line_forest_code.inc.h, labeling3D_PRED_2021_first_line_forest_code.inc.h, labeling3D_PRED_2021_last_line_forest_code.inc.h, labeling3D_PRED_2021_single_line_forest_code.inc.h
PRED++ 3D F. Bolelli,
S. Allegretti,
C. Grana [33]
2021 PREDpp_3D labeling3D_PREDpp_2021.h, labeling3D_PREDpp_2021_center_line_forest_code.inc.h, labeling3D_PREDpp_2021_first_line_forest_code.inc.h, labeling3D_PREDpp_2021_last_line_forest_code.inc.h, labeling3D_PREDpp_2021_single_line_forest_code.inc.h
Entropy Partitioning Decision Tree RLPR M. Söchting,
S. Allegretti,
F. Bolelli,
C. Grana [31]
2021 EPDT_19c and EPDT_22cVI labeling3D_BBDT_2019.h, labeling_bolelli_2019_forest.inc, labeling_bolelli_2019_forest_firstline.inc, labeling_bolelli_2019_forest_lastline.inc, labeling_bolelli_2019_forest_singleline.inc

I standard version.
II with zero-offset optimization.
III with RLE compression.
IV only on TTA and UF.
V it only copies the pixels from the input image to the output one simply defining a lower bound limit for the execution time of CCL algorithms on a given machine and dataset.
VI EPDT_19c and EPDT_22c algorithms are based on very big decision trees that translate to many lines of C++ code. They may thus noticeably increase the build time. For this reason, a special flag (YACCLAB_ENABLE_EPDT_ALGOS) to enable/disable such algorithms is provided in the CMake file. By default the flag is OFF.
VII CCL algorithm for images in bitonal (1 bit per pixel) format. When applied to these algorithms, the average tests also consider the time for 1 byte to 1 bit per pixel conversion. On the other hand, when performing average with steps tests conversion time is ignored.

2D/3D GPU Algorithms

Algorithm Name Authors Year Acronym Required Files 2D/3D
Union Find V. Oliveira,
R. Lotufo [18]
2010 UF labeling_oliveira_2010.cu 2D and 3D
Optimized
Label Equivalence
O. Kalentev,
A. Rai,
S. Kemnitz,
R. Schneider [19]
2011 OLE labeling_kalentev_2011.cu 2D
Block-run-based P. Chen,
H.L. Zhao,
C. Tao,
H.S. Sang [25]
2011 BRB labeling_chen_2011.cu 2D
Stava O. Stava,
B. Benes [38]
2011 STAVA labeling_stava_2011.cu 2D
Rasmusson A. Rasmusson,
T.S. Sørensen,
G. Ziegler [37]
2013 RASMUSSON labeling_rasmusson_2013.cu 2D
Accelerated CCL F. N. Paravecino,
D. Kaeli [34]
2014 ACCL labeling_paravecino_2014.cu 2D
8-Directional Label Selection Y. Soh,
H. Ashraf,
Y. Hae,
I. Kim [36]
2014 DLS labeling_soh_2014_8DLS.cu 2D
Modified 8-Directional Label Selection Y. Soh,
H. Ashraf,
Y. Hae,
I. Kim [36]
2014 M8DLS labeling_soh_2014_M8DLS.cu 2D
Line-based Union-Find K. Yonehara,
K. Aizawa [39]
2015 LBUF labeling_yonehara_2015.cu 2D
Block Equivalence S. Zavalishin,
I. Safonov,
Y. Bekhtin,
I. Kurilin [20]
2016 BE labeling_zavalishin_2016.cu 2D and 3D
Distanceless
Label Propagation
L. Cabaret,
L. Lacassagne,
D. Etiemble [21]
2017 DLP labeling_cabaret_2017.cu 2D
Komura Equivalence (8-conn) S. Allegretti,
F. Bolelli,
M. Cancilla,
C. Grana [22]
2018 KE labeling_allegretti_2018.cu 2D
Hardware Accelerated
4-connected
A. Hennequin,
L. Lacassagne,
L. Cabaret,
Q. Meunier [35]
2018 HA4 labeling_hennequin_2018_HA4.cu 2D
Hardware Accelerated
8-connected
A. Hennequin,
L. Lacassagne,
L. Cabaret,
Q. Meunier [35]
2018 HA8 labeling_hennequin_2018_HA8.cu 2D
CUDA SAUF S. Allegretti,
F. Bolelli,
M. Cancilla,
C. Grana [29]
2019 C-SAUF labeling_allegretti_2019_SAUF.cu,
labeling_wu_2009_tree.inc
2D
CUDA BBDT S. Allegretti,
F. Bolelli,
M. Cancilla,
C. Grana [29]
2019 C-BBDT labeling_allegretti_2019_BBDT.cu, labeling_grana_2010_tree.inc 2D
CUDA DRAG S. Allegretti,
F. Bolelli,
M. Cancilla,
C. Grana [29]
2019 C-DRAG labeling_allegretti_2019_DRAG.cu 2D
Block-based Union Find S. Allegretti,
F. Bolelli,
C. Grana [24]
2019 BUF labeling_allegretti_2019_BUF.cu 2D and 3D
Block-based Komura Equivalence S. Allegretti,
F. Bolelli,
C. Grana [24]
2019 BKE labeling_allegretti_2019_BKE.cu 2D and 3D

Example of Algorithm Usage Outside the Benchmark

#include "labels_solver.h"
#include "labeling_algorithms.h"
#include "labeling_grana_2010.h" // To include the algorithm code (BBDT in this example)

#include <opencv2/opencv.hpp>

using namespace cv;

int main()
{
    BBDT<UFPC> BBDT_UFPC; // To create an object of the desired algorithm (BBDT in this example)
                          // templated on the labels solving strategy. See the README for the
                          // complete list of the available labels solvers, available algorithms
                          // (N.B. non all the algorithms are templated on the solver) and their
                          // acronyms.

    BBDT_UFPC.img_ = imread("test_image.png", IMREAD_GRAYSCALE); // To load into the CCL object
                                                                 // the BINARY image to be labeled

    threshold(BBDT_UFPC.img_, BBDT_UFPC.img_, 100, 1, THRESH_BINARY); // Just to be sure that the
                                                                      // loaded image is binary

    BBDT_UFPC.PerformLabeling(); // To perform Connected Components Labeling!

    Mat1i output = BBDT_UFPC.img_labels_; // To get the output labeled image  
    unsigned n_labels = BBDT_UFPC.n_labels_; // To get the number of labels found in the input img

    return EXIT_SUCCESS;
}

Configuration File

A YAML configuration file placed in the installation folder lets you specify which kinds of tests should be performed, on which datasets and on which algorithms. Four categories of algorithms are supported: 2D CPU, 2D GPU, 3D CPU and 3D GPU. For each of them, the configuration parameters are reported below.