StrengthLine.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*********************************************************************/
  2. /* */
  3. /* Copyright 2022-2023 Rémi Synave - remi.synave@univ-littoral.fr */
  4. /* */
  5. /* This file is part of DSL. */
  6. /* This software uses Qt to build the Graphical User Interface */
  7. /* https://www.qt.io/ */
  8. /* */
  9. /* DSL is free software: you can redistribute it and/or modify */
  10. /* it under the terms of the GNU General Public License as published */
  11. /* by the Free Software Foundation, either version 3 of the License, */
  12. /* or (at your option) any later version. */
  13. /* */
  14. /* DSL is distributed in the hope that it will be useful, */
  15. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  16. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  17. /* GNU General Public License for more details. */
  18. /* */
  19. /* You should have received a copy of the GNU General Public License */
  20. /* along with DSL. If not, see <http://www.gnu.org/licenses/>. */
  21. /* */
  22. /*********************************************************************/
  23. #ifndef STRENGTHLINE_HPP
  24. #define STRENGTHLINE_HPP
  25. #include <iostream>
  26. #include <cmath>
  27. #include <QPoint>
  28. #include <QImage>
  29. class StrengthLine
  30. {
  31. private:
  32. QPoint *p1 = NULL, *p2 = NULL;
  33. std::pair < float, float > equation () const;
  34. public:
  35. StrengthLine (double ax = 0.0, double ay = 0.0, double bx = 1.0, double by = 1.0);
  36. StrengthLine (QPoint * p1 = new QPoint (0, 0), QPoint * p2 =
  37. new QPoint (1, 1));
  38. QPoint* getP1() const;
  39. QPoint* getP2() const;
  40. std::pair < QPoint *, QPoint * > toDraw (QImage * img) const;
  41. std::pair < QPoint *, QPoint * > toDraw (int imgWidth, int imgHeight) const;
  42. std::pair < QPoint *, QPoint * > interpolateToEdge (QImage * img) const;
  43. std::pair < QPoint *, QPoint * > interpolateToEdge (int imgWidth, int imgHeight) const;
  44. float ea_score(const StrengthLine *sl, double imgWidth, double imgHeight) const;
  45. float distance(const StrengthLine *sl, double imgWidth, double imgHeight) const;
  46. static StrengthLine* getRandomLine (QImage * img);
  47. static StrengthLine* getRandomLine (int width, int height);
  48. friend std::ostream& operator<<(std::ostream&, const StrengthLine);
  49. };
  50. #endif