![]() |
Geometrize 1.0
C++ library for geometrizing images into geometric primitives
|
Typedefs | |
using | EnergyFunction = std::function< double(const std::vector< geometrize::Scanline > &lines, const std::uint32_t alpha, const geometrize::Bitmap &target, const geometrize::Bitmap ¤t, geometrize::Bitmap &buffer, double score)> |
EnergyFunction Type alias for a function that calculates a measure of the improvement adding the scanlines of a shape provides - lower energy is better. More... | |
Functions | |
double | defaultEnergyFunction (const std::vector< geometrize::Scanline > &lines, const std::uint32_t alpha, const geometrize::Bitmap &target, const geometrize::Bitmap ¤t, geometrize::Bitmap &buffer, double score) |
defaultEnergyFunction The default/built-in energy function that calculates a measure of the improvement adding the scanlines of a shape provides - lower energy is better. More... | |
geometrize::rgba | computeColor (const geometrize::Bitmap &target, const geometrize::Bitmap ¤t, const std::vector< geometrize::Scanline > &lines, std::uint8_t alpha) |
computeColor Calculates the color of the scanlines. More... | |
double | differenceFull (const geometrize::Bitmap &first, const geometrize::Bitmap &second) |
differenceFull Calculates the root-mean-square error between two bitmaps. More... | |
double | differencePartial (const geometrize::Bitmap &target, const geometrize::Bitmap &before, const geometrize::Bitmap &after, double score, const std::vector< Scanline > &lines) |
differencePartial Calculates the root-mean-square error between the parts of the two bitmaps within the scanline mask. This is for optimization purposes, it lets us calculate new error values only for parts of the image we know have changed. More... | |
geometrize::State | bestHillClimbState (const std::function< std::shared_ptr< geometrize::Shape >(void)> &shapeCreator, std::uint32_t alpha, std::uint32_t n, std::uint32_t age, const geometrize::Bitmap &target, const geometrize::Bitmap ¤t, geometrize::Bitmap &buffer, double lastScore, const EnergyFunction &customEnergyFunction=nullptr) |
bestHillClimbState Gets the best state using a hill climbing algorithm. More... | |
using geometrize::core::EnergyFunction = typedef std::function<double( const std::vector<geometrize::Scanline>& lines, const std::uint32_t alpha, const geometrize::Bitmap& target, const geometrize::Bitmap& current, geometrize::Bitmap& buffer, double score)> |
EnergyFunction Type alias for a function that calculates a measure of the improvement adding the scanlines of a shape provides - lower energy is better.
The core functions for Geometrize.
lines | The scanlines of the shape. |
alpha | The alpha of the scanlines. |
target | The target bitmap. |
current | The current bitmap. |
buffer | The buffer bitmap. |
score | The score. |
geometrize::State geometrize::core::bestHillClimbState | ( | const std::function< std::shared_ptr< geometrize::Shape >(void)> & | shapeCreator, |
std::uint32_t | alpha, | ||
std::uint32_t | n, | ||
std::uint32_t | age, | ||
const geometrize::Bitmap & | target, | ||
const geometrize::Bitmap & | current, | ||
geometrize::Bitmap & | buffer, | ||
double | lastScore, | ||
const EnergyFunction & | customEnergyFunction = nullptr |
||
) |
bestHillClimbState Gets the best state using a hill climbing algorithm.
shapeCreator | A function that will create the shapes that will be chosen from. |
alpha | The opacity of the shape. |
n | The number of random states to generate. |
age | The number of hillclimbing steps. |
target | The target bitmap. |
current | The current bitmap. |
buffer | The buffer bitmap. |
lastScore | The last score. |
customEnergyFunction | An optional function to calculate the energy (if unspecified a default implementation is used). |
geometrize::rgba geometrize::core::computeColor | ( | const geometrize::Bitmap & | target, |
const geometrize::Bitmap & | current, | ||
const std::vector< geometrize::Scanline > & | lines, | ||
std::uint8_t | alpha | ||
) |
computeColor Calculates the color of the scanlines.
target | The target image. |
current | The current image. |
lines | The scanlines. |
alpha | The alpha of the scanline. |
double geometrize::core::defaultEnergyFunction | ( | const std::vector< geometrize::Scanline > & | lines, |
const std::uint32_t | alpha, | ||
const geometrize::Bitmap & | target, | ||
const geometrize::Bitmap & | current, | ||
geometrize::Bitmap & | buffer, | ||
double | score | ||
) |
defaultEnergyFunction The default/built-in energy function that calculates a measure of the improvement adding the scanlines of a shape provides - lower energy is better.
lines | The scanlines of the shape. |
alpha | The alpha of the scanlines. |
target | The target bitmap. |
current | The current bitmap. |
buffer | The buffer bitmap. |
score | The score. |
double geometrize::core::differenceFull | ( | const geometrize::Bitmap & | first, |
const geometrize::Bitmap & | second | ||
) |
differenceFull Calculates the root-mean-square error between two bitmaps.
first | The first bitmap. |
second | The second bitmap. |
double geometrize::core::differencePartial | ( | const geometrize::Bitmap & | target, |
const geometrize::Bitmap & | before, | ||
const geometrize::Bitmap & | after, | ||
double | score, | ||
const std::vector< Scanline > & | lines | ||
) |
differencePartial Calculates the root-mean-square error between the parts of the two bitmaps within the scanline mask. This is for optimization purposes, it lets us calculate new error values only for parts of the image we know have changed.
target | The target bitmap. |
before | The bitmap before the change. |
after | The bitmap after the change. |
score | The score. |
lines | The scanlines. |