polaroid-pp

Schlieren and contour plot tool
git clone https://git.0xfab.ch/polaroid-pp.git
Log | Files | Refs | Submodules | README | LICENSE

commit a41b46d1915f3d1cf8e8d7f9d3f8570c024ba249
parent ed4f8fe990d4cf78c2c8e082386a76020d2eaaeb
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Mon,  2 May 2016 00:09:19 +0200

added mean/std computation

Diffstat:
Mapps/polaroidCamera/SchlierenCartridge.h | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/apps/polaroidCamera/SchlierenCartridge.h b/apps/polaroidCamera/SchlierenCartridge.h @@ -6,12 +6,17 @@ #ifndef SCHLIERENCARTRIDGE_H_AUHX7ILM #define SCHLIERENCARTRIDGE_H_AUHX7ILM +#include <cstdio> #include <algorithm> #include <cmath> #include "Cartridge.h" +#include "GammaCorrection.h" class SchlierenCartridge : public Cartridge { + Real m_mean; + Real m_std; + size_t m_k; Slice m_gradX; Slice m_gradY; @@ -21,13 +26,14 @@ class SchlierenCartridge : public Cartridge void _gradY(const Slice& data); public: - SchlierenCartridge(ArgumentParser& parser) : Cartridge(parser) {} + SchlierenCartridge(ArgumentParser& parser) : Cartridge(parser), m_mean(0.0), m_std(0.0), m_k(0) {} virtual void capture(PhotoPaper& photo, Slice& data) { const Real ka = m_parser("-ka").asDouble(1.0); const Real k0 = m_parser("-k0").asDouble(0.0); const Real k1 = m_parser("-k1").asDouble(1.0); + GammaCorrection gammaCorrect(m_parser); photo.resize(data.width(), data.height()); @@ -48,7 +54,10 @@ public: const Real fac = -ka/(k1 - k0); for (int h=0; h < data.height(); ++h) for (int w=0; w < data.width(); ++w) - photo.set_pixel(w, h, std::exp(fac*(data(w,h)*dataMaxInv - k0))); + { + const Real phi = std::exp(fac*(data(w,h)*dataMaxInv - k0)); + photo.set_pixel(w, h, gammaCorrect(phi)); + } photo.write(); } @@ -59,6 +68,21 @@ public: m_dataMin = std::min(m_dataMin, data.min()); m_dataMax = std::max(m_dataMax, data.max()); m_bComputed = true; + for (int h=0; h < data.height(); ++h) + for (int w=0; w < data.width(); ++w) + { + ++m_k; + const Real delta = data(w,h) - m_mean; + m_mean += delta/m_k; + m_std += delta*(data(w,h) - m_mean); + } + } + + virtual void reset() + { + Cartridge::reset(); + m_mean = 0.0; + m_std = 0.0; } };