From 4a9d720343078f502ececa0107d4d9deec14ed6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Tue, 14 Nov 2023 12:04:55 +0100 Subject: [PATCH] Sum all channels histograms --- histogram.cpp | 3 +-- rawimage.cpp | 6 ++++-- rawimage.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/histogram.cpp b/histogram.cpp index a745700..cc97c4c 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -13,7 +13,7 @@ void Histogram::imageLoaded(Image *img) { if(img && img->rawImage()) { - m_histogram = img->rawImage()->imageStats().m_histogram[0]; + m_histogram = img->rawImage()->imageStats().m_histogram; m_points.clear(); update(); } @@ -29,7 +29,6 @@ void Histogram::paintEvent(QPaintEvent *) if(m_histogram.size()) { - if(m_points.size() != w) { m_points.clear(); diff --git a/rawimage.cpp b/rawimage.cpp index 73ed373..499af7b 100644 --- a/rawimage.cpp +++ b/rawimage.cpp @@ -198,8 +198,10 @@ void calcStats(const T *data, size_t n, RawImage::Stats &stats) } } - for(size_t i = 0; i < ch; i++) - stats.m_histogram[i] = std::vector(histogram[i], histogram[i] + histSize); + stats.m_histogram.resize(histSize, 0); + for(size_t i = 0; i < histSize; i++) + for(size_t o = 0; o < ch; o++) + stats.m_histogram[i] += histogram[o][i]; } void RawImage::calcStats() diff --git a/rawimage.h b/rawimage.h index db0f686..c65d6cf 100644 --- a/rawimage.h +++ b/rawimage.h @@ -57,7 +57,7 @@ public: double m_max[4] = {0.0}; double m_mad[4] = {0.0}; uint32_t m_saturated[4] = {0}; - std::vector m_histogram[4]; + std::vector m_histogram; }; protected: std::unique_ptr m_pixels;