This repository contains implementations of Laplacian Coordinates: Theory and Methods for Seeded Image Segmentation by Casaca et al., DOI 10.1109/TPAMI.2020.2974475. If you plan to use the code in this repository or any variant of it, please cite the paper.
- Author: Wallace Casaca (wallace.coc@gmail.com)
- Version: Preliminary prototype
- License: GPLv3
This code is a preliminary version of the hard-constrained Laplacian Coordinates framework (LCH) for seeded image segmentation.
The code is very simple to run and it has been implemented and tested in MATLAB 9.2 under Windows 10 (64-bit). No extra toolboxes or mex-C compilations are required to run this prototype, making it easy to use and less sensitive to OS.
run_me: Runs the LC segmentation for the sample images in theExample_*.matfiles.main_interactive('sample_image.png'): Provides an interactive interface for segmentation.
- For any question, suggestion or bug reports, please contact wallace.coc@gmail.com.
- Authors: Harlen Batagelo (hbatagelo@gmail.com) and João Paulo Gois (jpgois@gmail.com)
- License: GPLv3
This is a cross-platform C++ implementation of the Laplacian Coordinates segmentation framework with support to:
- Soft-constrained, pixel-based Laplacian Coordinates (LC).
- Hard-constrained, pixel-based Laplacian Coordinates (LCH).
- Soft-constrained, superpixel-based Laplacian Coordinates (SPLC).
- Hard-constrained, superpixel-based Laplacian Coordinates (SPLCH).
Install the build tools and dependencies:
-
Qt 6.
-
A C++20-compliant compiler.
-
CMake, Eigen 3.3, OpenCV 4.2 and SuiteSparse. On Linux these can be installed using the distribution's package manager.
Ubuntu 20.04 and later / Debian 11 and later:
sudo apt-get install cmake libeigen3-dev libopencv-dev libsuitesparse-devFedora 34 and later:
sudo dnf install cmake eigen3-devel opencv-devel suitesparse-devel blas-devel lapack-develmacOS with Homebrew:
brew install cmake eigen opencv suite-sparseFor instructions on how to build SuiteSparse on Windows with MSVC, refer to the suitesparse-metis-for-windows project.
After installing the dependencies, build the project in Qt Creator:
- Open
cpp/CMakeLists.txtin Qt Creator and configure/build the project from there.
As an alternative, build in the command line:
-
Set
CMAKE_PREFIX_PATHto the location where Qt 6 is installed (e.g.$HOME/Qt/6.2.2/gcc_64). -
From the
cppdirectory, run the following commands (assumingReleasebuild type):mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . --config "Release"
If a dependency is not found during the CMake configuration, manually set the missing path using the CMake variables Eigen3_DIR, OpenCV_DIR and SuiteSparse_DIR.
lcseg input seeds output [options]
where
inputis the name of the input image file.seedsis the name of the image file containing the foreground and background seeds. By default, red pixels (#ff0000) correspond to foreground seeds and blue pixels (#0000ff) correspond to background seeds.outputis the name of the output file that will contain the segmented image.
and [options] can be any combination of the following:
--fg: Sets the color of the foreground seeds (default is#ff0000).--bg: Sets the color of the background seeds (default is#0000ff).--hard: Uses seeds as hard labeling constraints (LCH and SPLCH).--superpixel: Uses SLIC superpixels (SPLC and SPLCH).--size: Sets superpixel size (default is 100).--compactness: Sets superpixel compactness (default is 10).-bor--binary: Writes output as a binary image.-qor--quiet: Runs in silent mode.