Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. template<typename T> class RGBHistogramTrait
  2. {
  3. public:
  4. RGBHistogramTrait(const QImage &image, RGBHistogram<T> hist) : _hist(hist), _base((QRgb *) (image.bits()));
  5. private:
  6. const QRgb *_base;
  7. RGBHistogram<T> _hist;
  8. };
  9.  
  10. template<typename T> struct RGBHistogram
  11. {
  12. RGBHistogram<T>(Histogram<T> &redHist, Histogram<T> &greenHist, Histogram<T> &blueHist)
  13. : redHist(redHist), greenHist(greenHist), blueHist(blueHist) {}
  14.  
  15. Histogram<T> &redHist, &greenHist, &blueHist;
  16. };
  17.  
  18. template<typename T> void ImageReader<T>::calculate(RGBHistogram<T> &hist)
  19. {
  20. QImage image;
  21.  
  22. if (image.load(QString::fromUtf8(_file.c_str())))
  23. {
  24. std::vector<RGBHistogramTrait<T> > *fs = new std::vector<RGBHistogramTrait<T> >[_threads];
  25.  
  26. for (ThreadNum i = 0; i < _threads; i++)
  27. {
  28. fs->push_back(RGBHistogramTrait<T>(image, hist));
  29. }
  30.  
  31. ThreadCoord::start(image.width() * image.height(), _threads, *fs);
  32.  
  33. // Now aggregate the results in fs back into the original hist
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement