qualitygmsd.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef OPENCV_QUALITY_QUALITYGMSD_HPP
  5. #define OPENCV_QUALITY_QUALITYGMSD_HPP
  6. #include "qualitybase.hpp"
  7. namespace cv
  8. {
  9. namespace quality
  10. {
  11. /**
  12. @brief Full reference GMSD algorithm
  13. http://www4.comp.polyu.edu.hk/~cslzhang/IQA/GMSD/GMSD.htm
  14. */
  15. class CV_EXPORTS_W QualityGMSD
  16. : public QualityBase {
  17. public:
  18. /**
  19. @brief Compute GMSD
  20. @param cmp comparison image
  21. @returns cv::Scalar with per-channel quality value. Values range from 0 (worst) to 1 (best)
  22. */
  23. CV_WRAP cv::Scalar compute( InputArray cmp ) CV_OVERRIDE;
  24. /** @brief Implements Algorithm::empty() */
  25. CV_WRAP bool empty() const CV_OVERRIDE { return _refImgData.empty() && QualityBase::empty(); }
  26. /** @brief Implements Algorithm::clear() */
  27. CV_WRAP void clear() CV_OVERRIDE { _refImgData = _mat_data(); QualityBase::clear(); }
  28. /**
  29. @brief Create an object which calculates image quality
  30. @param ref reference image
  31. */
  32. CV_WRAP static Ptr<QualityGMSD> create( InputArray ref );
  33. /**
  34. @brief static method for computing quality
  35. @param ref reference image
  36. @param cmp comparison image
  37. @param qualityMap output quality map, or cv::noArray()
  38. @returns cv::Scalar with per-channel quality value. Values range from 0 (worst) to 1 (best)
  39. */
  40. CV_WRAP static cv::Scalar compute( InputArray ref, InputArray cmp, OutputArray qualityMap );
  41. protected:
  42. // holds computed values for a mat
  43. struct _mat_data
  44. {
  45. // internal mat type
  46. using mat_type = QualityBase::_mat_type;
  47. mat_type
  48. gradient_map
  49. , gradient_map_squared
  50. ;
  51. // allow default construction
  52. _mat_data() = default;
  53. // construct from mat_type
  54. _mat_data(const mat_type&);
  55. // construct from inputarray
  56. _mat_data(InputArray);
  57. // returns flag if empty
  58. bool empty() const { return this->gradient_map.empty() && this->gradient_map_squared.empty(); }
  59. // compute for a single frame
  60. static std::pair<cv::Scalar, mat_type> compute(const _mat_data& lhs, const _mat_data& rhs);
  61. }; // mat_data
  62. /** @brief Reference image data */
  63. _mat_data _refImgData;
  64. // internal constructor
  65. QualityGMSD(_mat_data refImgData)
  66. : _refImgData(std::move(refImgData))
  67. {}
  68. }; // QualityGMSD
  69. } // quality
  70. } // cv
  71. #endif