Example of using the Boykov-Kolmogorov Max-Flow/Min-Cut algorithm implementation from The Boost Graph Library for image denoising.
To dive in the implementation details, check out my Medium post dedicated to this repository.
The project depends on CMake (at least 3.12), OpenCV 4, and The Boost Graph Library (tested with versions 1.82 and 1.74).
If you use apt
, which is the default package manager
for Ubuntu, Debian, and many others, use
sudo apt update
sudo apt install -y libopencv-dev libboost-graph-dev
Under Windows 11, the code was tested with OpenCV 4.8.0 and Boost Graph 1.82.0 installed via vcpkg.
The project benefits from CMake. With CMake 3.13 or newer, you can easily build the project using
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build
In earlier versions, the -S
parameter is not available.
So, if you use CMake 3.12, build the project using
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build
If you use vcpkg, the things are trickier. Read vcpkg in CMake projects for more details or use an IDE that supports vcpkg.
The application accepts three positional command-line arguments:
maxflow_image_denoising <input image> <output image> <discontinuity penalty>
The paths can be relative or absolute. The discontinuity penalty (smoothness term) must be a non-negative integer.
The program contains the input arguments validation.
The project uses MIT license, so you can freely use the source code in pet projects, commercial projects, and home assignments. You can also modify it, distribute it, and sell it. Note that the project is provided "as is", so the author is not responsible for your usage of it.