qualitybrisque.hpp 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_QUALITYBRISQUE_HPP
  5. #define OPENCV_QUALITY_QUALITYBRISQUE_HPP
  6. #include "qualitybase.hpp"
  7. #include "opencv2/ml.hpp"
  8. namespace cv
  9. {
  10. namespace quality
  11. {
  12. /**
  13. @brief BRISQUE (Blind/Referenceless Image Spatial Quality Evaluator) is a No Reference Image Quality Assessment (NR-IQA) algorithm.
  14. BRISQUE computes a score based on extracting Natural Scene Statistics (https://en.wikipedia.org/wiki/Scene_statistics)
  15. and calculating feature vectors. See Mittal et al. @cite Mittal2 for original paper and original implementation @cite Mittal2_software .
  16. A trained model is provided in the /samples/ directory and is trained on the LIVE-R2 database @cite Sheikh as in the original implementation.
  17. When evaluated against the TID2008 database @cite Ponomarenko , the SROCC is -0.8424 versus the SROCC of -0.8354 in the original implementation.
  18. C++ code for the BRISQUE LIVE-R2 trainer and TID2008 evaluator are also provided in the /samples/ directory.
  19. */
  20. class CV_EXPORTS_W QualityBRISQUE : public QualityBase {
  21. public:
  22. /** @brief Computes BRISQUE quality score for input image
  23. @param img Image for which to compute quality
  24. @returns cv::Scalar with the score in the first element. The score ranges from 0 (best quality) to 100 (worst quality)
  25. */
  26. CV_WRAP cv::Scalar compute( InputArray img ) CV_OVERRIDE;
  27. /**
  28. @brief Create an object which calculates quality
  29. @param model_file_path cv::String which contains a path to the BRISQUE model data, eg. /path/to/brisque_model_live.yml
  30. @param range_file_path cv::String which contains a path to the BRISQUE range data, eg. /path/to/brisque_range_live.yml
  31. */
  32. CV_WRAP static Ptr<QualityBRISQUE> create( const cv::String& model_file_path, const cv::String& range_file_path );
  33. /**
  34. @brief Create an object which calculates quality
  35. @param model cv::Ptr<cv::ml::SVM> which contains a loaded BRISQUE model
  36. @param range cv::Mat which contains BRISQUE range data
  37. */
  38. CV_WRAP static Ptr<QualityBRISQUE> create( const cv::Ptr<cv::ml::SVM>& model, const cv::Mat& range );
  39. /**
  40. @brief static method for computing quality
  41. @param img image for which to compute quality
  42. @param model_file_path cv::String which contains a path to the BRISQUE model data, eg. /path/to/brisque_model_live.yml
  43. @param range_file_path cv::String which contains a path to the BRISQUE range data, eg. /path/to/brisque_range_live.yml
  44. @returns cv::Scalar with the score in the first element. The score ranges from 0 (best quality) to 100 (worst quality)
  45. */
  46. CV_WRAP static cv::Scalar compute( InputArray img, const cv::String& model_file_path, const cv::String& range_file_path );
  47. /**
  48. @brief static method for computing image features used by the BRISQUE algorithm
  49. @param img image (BGR(A) or grayscale) for which to compute features
  50. @param features output row vector of features to cv::Mat or cv::UMat
  51. */
  52. CV_WRAP static void computeFeatures(InputArray img, OutputArray features);
  53. protected:
  54. cv::Ptr<cv::ml::SVM> _model = nullptr;
  55. cv::Mat _range;
  56. /** @brief Internal constructor */
  57. QualityBRISQUE( const cv::String& model_file_path, const cv::String& range_file_path );
  58. /** @brief Internal constructor */
  59. QualityBRISQUE(const cv::Ptr<cv::ml::SVM>& model, const cv::Mat& range )
  60. : _model{ model }
  61. , _range{ range }
  62. {}
  63. }; // QualityBRISQUE
  64. } // quality
  65. } // cv
  66. #endif