The Model class is the model for the core optimization/fitting algorithm.
More...
#include <model.h>
|
| Model (const geometrize::Bitmap &target) |
| Model Creates a model that will aim to replicate the target bitmap with shapes. More...
|
|
| Model (const geometrize::Bitmap &target, const geometrize::Bitmap &initial) |
| Model Creates a model that will optimize for the given target bitmap, starting from the given initial bitmap. The target bitmap and initial bitmap must be the same size (width and height). More...
|
|
| ~Model () |
|
Model & | operator= (const Model &)=delete |
|
| Model (const Model &)=delete |
|
void | reset (geometrize::rgba backgroundColor) |
| reset Resets the model back to the state it was in when it was created. More...
|
|
std::int32_t | getWidth () const |
| getWidth Gets the width of the target bitmap. More...
|
|
std::int32_t | getHeight () const |
| getHeight Gets the height of the target bitmap. More...
|
|
std::vector< geometrize::ShapeResult > | step (const std::function< std::shared_ptr< geometrize::Shape >(void)> &shapeCreator, std::uint8_t alpha, std::uint32_t shapeCount, std::uint32_t maxShapeMutations, std::uint32_t maxThreads, const geometrize::core::EnergyFunction &energyFunction=nullptr, const geometrize::ShapeAcceptancePreconditionFunction &addShapePrecondition=nullptr) |
| step Steps the primitive optimization/fitting algorithm. More...
|
|
geometrize::ShapeResult | drawShape (std::shared_ptr< geometrize::Shape > shape, geometrize::rgba color) |
| drawShape Draws a shape on the model. Typically used when to manually add a shape to the image (e.g. when setting an initial background). NOTE this unconditionally draws the shape, even if it increases the difference between the source and target image. More...
|
|
geometrize::Bitmap & | getCurrent () |
| getCurrent Gets the current bitmap. More...
|
|
geometrize::Bitmap & | getTarget () |
| getTarget Gets the target bitmap. More...
|
|
const geometrize::Bitmap & | getCurrent () const |
| getCurrent Gets the current bitmap, const-edition. More...
|
|
const geometrize::Bitmap & | getTarget () const |
| getTarget Gets the target bitmap, const-edition. More...
|
|
void | setSeed (std::uint32_t seed) |
| setSeed Sets the seed that the random number generators of this model use. Note that the model also uses an internal seed offset which is incremented when the model is stepped. More...
|
|
The Model class is the model for the core optimization/fitting algorithm.
- Author
- Sam Twidale (https://samcodes.co.uk/)
◆ Model() [1/3]
Model Creates a model that will aim to replicate the target bitmap with shapes.
- Parameters
-
target | The target bitmap to replicate with shapes. |
221 :
d{std::unique_ptr<Model::ModelImpl>(
new Model::ModelImpl(target))}
222{}
std::unique_ptr< Model::ModelImpl > d
Definition: model.h:146
◆ Model() [2/3]
Model Creates a model that will optimize for the given target bitmap, starting from the given initial bitmap. The target bitmap and initial bitmap must be the same size (width and height).
- Parameters
-
target | The target bitmap to replicate with shapes. |
initial | The starting bitmap. |
224 :
d{std::unique_ptr<Model::ModelImpl>(
new Model::ModelImpl(target, initial))}
225{}
◆ ~Model()
geometrize::Model::~Model |
( |
| ) |
|
◆ Model() [3/3]
geometrize::Model::Model |
( |
const Model & |
| ) |
|
|
delete |
◆ drawShape()
drawShape Draws a shape on the model. Typically used when to manually add a shape to the image (e.g. when setting an initial background). NOTE this unconditionally draws the shape, even if it increases the difference between the source and target image.
- Parameters
-
shape | The shape to draw. |
color | The color (including alpha) of the shape. |
- Returns
- Data about the shape drawn on the model.
258{
259 return d->drawShape(shape, color);
260}
◆ getCurrent() [1/2]
getCurrent Gets the current bitmap.
- Returns
- The current bitmap.
268{
269 return d->getCurrent();
270}
◆ getCurrent() [2/2]
getCurrent Gets the current bitmap, const-edition.
- Returns
- The current bitmap.
278{
279 return d->getCurrent();
280}
◆ getHeight()
std::int32_t geometrize::Model::getHeight |
( |
| ) |
const |
getHeight Gets the height of the target bitmap.
- Returns
- The height of the target bitmap.
241{
242 return d->getHeight();
243}
◆ getTarget() [1/2]
getTarget Gets the target bitmap.
- Returns
- The target bitmap.
263{
264 return d->getTarget();
265}
◆ getTarget() [2/2]
getTarget Gets the target bitmap, const-edition.
- Returns
- The target bitmap.
273{
274 return d->getTarget();
275}
◆ getWidth()
std::int32_t geometrize::Model::getWidth |
( |
| ) |
const |
getWidth Gets the width of the target bitmap.
- Returns
- The width of the target bitmap.
236{
237 return d->getWidth();
238}
◆ operator=()
Model & geometrize::Model::operator= |
( |
const Model & |
| ) |
|
|
delete |
◆ reset()
reset Resets the model back to the state it was in when it was created.
- Parameters
-
backgroundColor | The starting background color to use. |
231{
232 d->reset(backgroundColor);
233}
◆ setSeed()
void geometrize::Model::setSeed |
( |
std::uint32_t |
seed | ) |
|
setSeed Sets the seed that the random number generators of this model use. Note that the model also uses an internal seed offset which is incremented when the model is stepped.
- Parameters
-
seed | The random number generator seed. |
◆ step()
step Steps the primitive optimization/fitting algorithm.
- Parameters
-
shapeCreator | A function that will produce the shapes. |
alpha | The alpha of the shape. |
shapeCount | The number of random shapes to generate (only 1 is chosen in the end). |
maxShapeMutations | The maximum number of times to mutate each random shape. |
maxThreads | The maximum number of threads to use during this step. |
energyFunction | An optional function to calculate the energy (if unspecified a default implementation is used). |
addShapePrecondition | An optional function to determine whether to accept a shape (if unspecified a default implementation is used). |
- Returns
- A vector containing data about the shapes added to the model in this step. This may be empty if no shape that improved the image could be found.
253{
254 return d->step(shapeCreator, alpha, shapeCount, maxShapeMutations, maxThreads, energyFunction, addShapePrecondition);
255}
The documentation for this class was generated from the following files:
- /home/appveyor/projects/geometrize-lib-docs/geometrize-lib/geometrize/geometrize/model.h
- /home/appveyor/projects/geometrize-lib-docs/geometrize-lib/geometrize/geometrize/model.cpp