Mosaic++ is a tool that produces photomosaics. It offers a range of options that have an effect on the final result. It can be used for entertainment purposes or be converted to an applicable tool in fields like image processing or mesh generation.
This project started as a college assignment for a Modern C++ course we took during the first term in our second year. We chose it because we are keen on challenging ourselves and the idea of learning image processing basics besides the required modern C++ elements was catching.
Mosaics can be grouped by:
- Shape
- Square shaped cells
- Square-mosaic
- Quad-mosaic
- Triangle shaped cells
- Diamond shaped cells
- Square shaped cells
- Blend
- with
- without
- Color distance method
- Riemersma
- Euclidean
The user also has some configurable parameters:
- Select the picture to be mosaiced
- Cell size
- Add/Replace to the database of cell-pictures
- Final result options
- Final result extension
- *.jpg
- *.png
- Final result resolution
- keep original
- custom width and/or height
- Final result name
- Final result save location
- Final result extension
- Quad-Mosaic options
- Threshold
- Minimum cell size
- with/without details
class BasePictures
{
public:
/*
This class handles most of the directory work using <filesystem>.
It maps every image and its path with a key equal to its mean.
In this case, it is fairly efficient (in terms of time complexity)
to have acces to any image that is needed.
*/
};
class Mosaic
{
public:
/*
This class handles all the mosaicing algorithms and logic. It recieves
an input image and the user's desired configurations and passes the
cv::Mat object through all the required methods in order to process the
final photomosaic.
*/
};
class PictureTools
{
public:
/*
This class has multiple image processing methods. It is used to resize,
crop, blend and calculate the mean for a given photo.
*/
};
class QuadTreeImages
{
public:
/*
This class is used inside the Mosaic class in order to quad-divide a
photo. It represents a QuadTree data structure implemented by us for
the purpose of this project.
*/
};
class StopWatch
{
public:
/*
This class's purpose is to count the time our mosaicing algorithms take
to finish in seconds. We used it to benchmark and test our code.
*/
};
class MyWindow : public QMainWindow
{
public:
/*
These classes are UI classes that connect the user to the back-end
processes. Our UI also acts like a config manager, letting the user
choose from a range of options(shape, final size, algorithm used, etc)
in order to make the tool more flexible.
*/
};
- Qt
- OpenCV
- Threading
- Every Mosaic type runs on 4 threads, greatly increasing performance.
- Modern structures, algorithms and synthax
- Everything from maps to smart-pointers ensures our code is both readable and memory-leak proof
- UnitTests
- Test-Driven-Development helped us spot out bugs
The threshold option have a great inpact in the final result, especially when things got a little bit bigger (or in our case, tremendously large 😄).
Input Image (10,000 x 10,000) | Resulted Mosaic (threshold = 50) | Resulted Mosaic (threshold = 1000) |
Input Image | Square shaped cells | Diamond shaped cells | Diamond shaped cells |