removed deprecated functions

This commit is contained in:
Phuntsok Drak-pa 2019-04-28 17:34:46 +02:00
parent 1d3b149f43
commit 93ae4693ff
3 changed files with 3 additions and 74 deletions

View File

@ -65,13 +65,6 @@ private:
/// \brief Creates and returns a random color
[[nodiscard]] auto random_color() const noexcept;
/// \brief Generates random square coordinates
[[deprecated]] [[nodiscard]] auto get_square_values() const noexcept;
/// \brief Generates controlled random square coordinates
[[deprecated]] [[nodiscard]] auto get_controlled_square_values() const
noexcept;
/// \brief Generates a candidate for image generation improvement
[[nodiscard]] auto create_candidate(bool const t_controlled_size);
@ -84,11 +77,6 @@ private:
/// \brief Threaded helper for \ref get_color_set
void threaded_get_color(int const t_h);
/// \brief Draw a square on an image
[[deprecated]] void draw_square(cv::Mat &t_img, cv::Point const &t_top_left,
int const t_size,
cv::Scalar const &t_color) const;
void draw_shape(cv::Mat &t_img, cv::Scalar &&t_color);
void create_shape() noexcept;
void create_controlled_shape() noexcept;

View File

@ -33,7 +33,7 @@ public:
/// \brief Generates a shape's points
void update(cv::Point &&t_max_pos, int const t_max_size,
int const t_min_size = 0) noexcept;
int const t_min_size = 1) noexcept;
[[nodiscard]] auto get_points() const noexcept
-> std::array<cv::Point, Shape::MAX_POINTS> const &

View File

@ -161,45 +161,6 @@ ImageManipulator::euclidian_distance(cv::Mat const &t_img) const noexcept
return cv::Scalar(rand() % 255, rand() % 255, rand() % 255);
}
/**
* Generates random x/y coordinates for a square and the size of said square.
*
* \return Tuple of three ints
*/
[[nodiscard]] auto ImageManipulator::get_square_values() const noexcept
{
int rand_x = rand() % reference_.size().width;
int rand_y = rand() % reference_.size().height;
int size = rand()
% std::min(reference_.size().width - rand_x,
reference_.size().height - rand_y);
return std::tuple<int, int, int>(rand_x, rand_y, size);
}
/**
* Generates random x/y coordinates for a squares origin (top left), and a
* random size whichs max and minimal value are controled as mentionned in the
* [report](https://labs.phundrak.fr/phundrak/genetic-images/blob/master/report/report.pdf).
*
* \return Tuple of three ints
*/
[[nodiscard]] auto ImageManipulator::get_controlled_square_values() const
noexcept
{
int rand_x = rand() % reference_.size().width;
int rand_y = rand() % reference_.size().height;
float const coef = static_cast<float>(remaining_iter_)
/ static_cast<float>(total_iterations_);
int const min_size
= static_cast<int>((static_cast<float>(std::min(reference_.size().width,
reference_.size().height))
/ 2.0f)
* coef);
int const max_size = min_size * 2 + 1;
int size = rand() % (max_size - min_size) + min_size;
return std::tuple<int, int, int>(rand_x, rand_y, size);
}
void ImageManipulator::create_shape() noexcept
{
shape_.update(cv::Point{reference_.size().width, reference_.size().height},
@ -235,9 +196,9 @@ ImageManipulator::create_candidate(bool const t_controlled_size = false)
auto temp_img = generated_image_.clone();
auto const &color = colors_[rand() % colors_.size()];
if (t_controlled_size) {
create_shape();
} else {
create_controlled_shape();
} else {
create_shape();
}
draw_shape(temp_img, cv::Scalar{static_cast<double>(color[0]),
static_cast<double>(color[1]),
@ -323,26 +284,6 @@ void ImageManipulator::threaded_get_color(int const t_h)
}
}
/**
* Draw a square on the image passed as its argument, following its passed
* coordinates and with the passed color.
*
* \param[out] t_img Image to draw the square to
* \param[in] t_top_left Origin of the square
* \param[in] t_size Size of the square
* \param[in] t_color Color of the square
*/
void ImageManipulator::draw_square(cv::Mat &t_img, cv::Point const &t_top_left,
int const t_size,
cv::Scalar const &t_color) const
{
std::array<cv::Point, 4> points
= {t_top_left, cv::Point{t_top_left.x, t_top_left.y + t_size},
cv::Point{t_top_left.x + t_size, t_top_left.y + t_size},
cv::Point{t_top_left.x + t_size, t_top_left.y}};
fillConvexPoly(t_img, points.data(), 4, t_color);
}
void ImageManipulator::draw_shape(cv::Mat &t_img, cv::Scalar &&t_color)
{
fillConvexPoly(t_img, shape_.get_points().data(), shape_.get_nb_points(),