polaroid-pp

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

commit 61b161517b29343fc44385013f509859355371df
parent 47db2052f927c0253d02d4078e085836a2fe7479
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Thu, 28 Apr 2016 18:28:53 +0200

dded SchlierenCartridge

Diffstat:
Aapps/polaroidCamera/SchlierenCartridge.h | 44++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)

diff --git a/apps/polaroidCamera/SchlierenCartridge.h b/apps/polaroidCamera/SchlierenCartridge.h @@ -0,0 +1,44 @@ +// File : SchlierenCartridge.h +// Date : Thu 28 Apr 2016 04:45:20 PM CEST +// Author : Fabian Wermelinger +// Description: Schlieren Image Cartridge +// Copyright 2016 ETH Zurich. All Rights Reserved. +#ifndef SCHLIERENCARTRIDGE_H_AUHX7ILM +#define SCHLIERENCARTRIDGE_H_AUHX7ILM + +#include "Cartridge.h" + +class SchlierenCartridge : public Cartridge +{ +public: + SchlierenCartridge(ArgumentParser& parser) : Cartridge(parser) {} + + virtual void capture(PhotoPaper& photo, Slice& data) + { + photo.resize(data.width(), data.height()); + + // set description + string desc("2D Schlieren Data"); + photo.set_description(desc.c_str()); + + // compute min/max + Real data_min = data(0,0); + Real data_max = data(0,0); + for (int h=0; h < data.height(); ++h) + for (int w=0; w < data.width(); ++w) + { + data_min = min(data_min, data(w,h)); + data_max = max(data_max, data(w,h)); + } + const Real data_normInv = 1.0 / (data_max - data_min); + + // compute pixel + for (int h=0; h < data.height(); ++h) + for (int w=0; w < data.width(); ++w) + photo.set_pixel(w, h, (data(w,h) - data_min) * data_normInv); + + photo.write(); + } +}; + +#endif /* SCHLIERENCARTRIDGE_H_AUHX7ILM */