From 93ae4693ff6f1d4e8b48f086ae7f626afeadfa30 Mon Sep 17 00:00:00 2001 From: Phuntsok Drak-pa Date: Sun, 28 Apr 2019 17:34:46 +0200 Subject: [PATCH] removed deprecated functions --- include/genimg/methods.hh | 12 -------- include/genimg/shapes.hh | 2 +- src/methods.cc | 63 ++------------------------------------- 3 files changed, 3 insertions(+), 74 deletions(-) diff --git a/include/genimg/methods.hh b/include/genimg/methods.hh index 28f9241..403fd39 100644 --- a/include/genimg/methods.hh +++ b/include/genimg/methods.hh @@ -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; diff --git a/include/genimg/shapes.hh b/include/genimg/shapes.hh index dafe65a..568cc4c 100644 --- a/include/genimg/shapes.hh +++ b/include/genimg/shapes.hh @@ -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 const & diff --git a/src/methods.cc b/src/methods.cc index a59e659..d09ae2c 100644 --- a/src/methods.cc +++ b/src/methods.cc @@ -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(rand_x, rand_y, size); -} - -/** - * Generates random x/y coordinates for a square’s origin (top left), and a - * random size which’s 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(remaining_iter_) - / static_cast(total_iterations_); - int const min_size - = static_cast((static_cast(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(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(color[0]), static_cast(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 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(),