Geometrize  1.0
C++ library for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
core.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <functional>
5 #include <memory>
6 #include <vector>
7 
8 #include "bitmap/rgba.h"
9 #include "rasterizer/scanline.h"
10 #include "state.h"
11 
12 namespace geometrize
13 {
14 class Bitmap;
15 }
16 
17 namespace geometrize
18 {
19 
20 namespace core
21 {
22 
38 using EnergyFunction = std::function<double(
39  const std::vector<geometrize::Scanline>& lines,
40  const std::uint32_t alpha,
41  const geometrize::Bitmap& target,
42  const geometrize::Bitmap& current,
43  geometrize::Bitmap& buffer,
44  double score)>;
45 
57  const std::vector<geometrize::Scanline>& lines,
58  const std::uint32_t alpha,
59  const geometrize::Bitmap& target,
60  const geometrize::Bitmap& current,
61  geometrize::Bitmap& buffer,
62  double score);
63 
73  const geometrize::Bitmap& target,
74  const geometrize::Bitmap& current,
75  const std::vector<geometrize::Scanline>& lines,
76  std::uint8_t alpha);
77 
84 double differenceFull(const geometrize::Bitmap& first, const geometrize::Bitmap& second);
85 
96 double differencePartial(
97  const geometrize::Bitmap& target,
98  const geometrize::Bitmap& before,
99  const geometrize::Bitmap& after,
100  double score,
101  const std::vector<Scanline>& lines);
102 
117  const std::function<std::shared_ptr<geometrize::Shape>(void)>& shapeCreator,
118  std::uint32_t alpha,
119  std::uint32_t n,
120  std::uint32_t age,
121  const geometrize::Bitmap& target,
122  const geometrize::Bitmap& current,
123  geometrize::Bitmap& buffer,
124  double lastScore,
125  const EnergyFunction& customEnergyFunction = nullptr);
126 
127 }
128 
129 }
geometrize::State bestHillClimbState(const std::function< std::shared_ptr< geometrize::Shape >(void)> &shapeCreator, const std::uint32_t alpha, const std::uint32_t n, const std::uint32_t age, const geometrize::Bitmap &target, const geometrize::Bitmap &current, geometrize::Bitmap &buffer, const double lastScore, const EnergyFunction &customEnergyFunction)
bestHillClimbState Gets the best state using a hill climbing algorithm.
Definition: core.cpp:233
double differenceFull(const geometrize::Bitmap &first, const geometrize::Bitmap &second)
differenceFull Calculates the root-mean-square error between two bitmaps.
Definition: core.cpp:174
double defaultEnergyFunction(const std::vector< geometrize::Scanline > &lines, const std::uint32_t alpha, const geometrize::Bitmap &target, const geometrize::Bitmap &current, geometrize::Bitmap &buffer, const double score)
defaultEnergyFunction The default/built-in energy function that calculates a measure of the improveme...
Definition: core.cpp:108
geometrize::rgba computeColor(const geometrize::Bitmap &target, const geometrize::Bitmap &current, const std::vector< geometrize::Scanline > &lines, const std::uint8_t alpha)
computeColor Calculates the color of the scanlines.
Definition: core.cpp:122
The Bitmap class is a helper class for working with bitmap data.
Definition: bitmap.h:15
The rgba struct is a helper for manipulating RGBA8888 color data.
Definition: rgba.h:12
The State class relates a shape and related properties to a measure of how close it brings the workin...
Definition: state.h:20
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
EnergyFunction Type alias for a function that calculates a measure of the improvement adding the scan...
Definition: core.h:44
double differencePartial(const geometrize::Bitmap &target, const geometrize::Bitmap &before, const geometrize::Bitmap &after, const double score, const std::vector< Scanline > &lines)
differencePartial Calculates the root-mean-square error between the parts of the two bitmaps within t...
Definition: core.cpp:198