A CLI tool that partitions an image into a monochromatic rectangle -and background such that the sum of squared errors between the original and segmented image is minimized. OpenMP and Intel Intrinsics are utilized to accelerate computations. This work is related to an assignment from the Aalto University course Programming Parallel Computers.
Figure 1: An image along with the corresponding optimal segmentation
- Ensure you have CMake version ≥ 3.16, and OpenCV version ≥ 4.4.0
- In the project directory, do
mkdir build; cd build
- Define an environment variable
OpenCV_DIR
pointing topath/to/opencv/build
directory. Alternatively, define it as a CMake cache variable. - To generate project files, do
cmake ..
- You can use
cmake --build .
to build the project while abstracting away any platform-specific build tool usage. Note, however, that certain compilers, such as MSVC, support different build configurations. To achieve best performance, you may need to specify the configuration, for example in the case of MSVC, with--config Release
. - Run the executable, passing it the input and output image paths
Despite the implementation being highly parallel, the brute-force nature of the algorithm still makes segmenting large images with it infeasible. Further, there are likely aspects in the current implementation that could be improved to achieve even better performance.