24#ifndef VIGRA_EXT_VIGNETTING_CORRECTION_H
25#define VIGRA_EXT_VIGNETTING_CORRECTION_H
29#include "hugin_config.h"
31#include <vigra/stdimage.hxx>
32#include <vigra/transformimage.hxx>
33#include <vigra/inspectimage.hxx>
34#include <vigra/combineimages.hxx>
35#include <vigra/functorexpression.hxx>
45template <
class VT1,
class VT2,
class InvResp,
class Adjust>
59 typedef typename vigra::NumericTraits<VT1>::RealPromote
result_type;
62 typedef typename vigra::NumericTraits<VT2>::RealPromote
RVT2;
85template <
class VT1,
class InvResp,
class VigFunc,
class Adjust>
95 typedef typename vigra::NumericTraits<VT1>::RealPromote
result_type;
118template <
class VT1,
class VT2,
class InvResp,
class Adjust>
132 typedef typename vigra::NumericTraits<VT1>::RealPromote
result_type;
135 typedef typename vigra::NumericTraits<VT2>::RealPromote
RVT2;
154template <
class VT1,
class InvResp,
class VigFunc,
class Adjust>
164 typedef typename vigra::NumericTraits<VT1>::RealPromote
result_type;
187template <
int NTERMS=4>
200 double r2 = x*x + y*y;
202 for (
unsigned int i = 1;
i <
NTERMS;
i++) {
221 typedef typename vigra::NumericTraits<T>::isIntegral
is_integral;
245 std::mt19937 &mt =
const_cast<std::mt19937 &
>(
Twister);
262 T
dither(
const T &
v, vigra::VigraFalseType)
const
265 for (
size_t i=0;
i <
v.size();
i++) {
272 T
dither(
const T &
v, vigra::VigraTrueType)
const
279 typedef typename vigra::NumericTraits<T>::isScalar
is_scalar;
296 typename vigra::NumericTraits<T>::RealPromote
operator()(T p)
const
298 typedef typename vigra::NumericTraits<T>::RealPromote
RT;
331 vigra::pair<DestImageIterator, DestAccessor>
dest,
332 double cx,
double cy,
345 double cx,
double cy,
355 typename SrcImageIterator::row_iterator
s(
src_upperleft.rowIterator());
357 typename DestImageIterator::row_iterator
d(
dest_upperleft.rowIterator());
375 vigra::pair<DestImageIterator, DestAccessor>
dest,
376 double cx,
double cy,
377 Functor const & f,
bool dither)
400 vigra::pair<FFIter, FFAccessor>
ffImg,
401 vigra::pair<DestIter, DestAccessor>
destImg,
402 Functor const & f,
bool dither)
415template <
class ImgIter,
class ImgAccessor,
class FFIter,
class FFAccessor,
class DestIter,
class DestAccessor>
417 vigra::pair<FFIter, FFAccessor>
ffImg,
418 vigra::pair<DestIter, DestAccessor>
destImg,
420 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote a,
421 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote b,
424 typedef typename ImgAccessor::value_type
PT;
425 typedef typename vigra::NumericTraits<PT>::RealPromote
RPT;
426 typedef typename FFAccessor::value_type
FFT;
427 typedef typename vigra::NumericTraits<FFT>::RealPromote
RFFT;
436 vigra::FindAverage<FFT>
average;
467template <
class ImgIter,
class ImgAccessor,
class DestIter,
class DestAccessor>
471 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote a,
472 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote b,
475 typedef typename ImgAccessor::value_type
PT;
476 typedef typename vigra::NumericTraits<PT>::RealPromote
RPT;
512template <
class ImgIter,
class ImgAccessor,
class DestIter,
class DestAccessor>
514 vigra::pair<DestIter, DestAccessor>
destImg,
515 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote a,
516 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote b)
518 typedef typename ImgAccessor::value_type
PT;
519 typedef typename vigra::NumericTraits<PT>::RealPromote
RPT;
525template <
class ImgIter,
class ImgAccessor,
class DestIter,
class DestAccessor>
527 vigra::pair<DestIter, DestAccessor>
destImg,
529 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote a,
530 typename vigra::NumericTraits<typename ImgAccessor::value_type>::RealPromote b)
532 typedef typename ImgAccessor::value_type
PT;
533 typedef typename vigra::NumericTraits<PT>::RealPromote
RPT;
541template <
class ImgIter,
class ImgAccessor,
class DestIter,
class DestAccessor>
543 vigra::pair<DestIter, DestAccessor>
destImg,
result_type operator()(first_argument_type const &v1, float x, float y) const
calculate transform.
VigCorrAddFunctor(const InvResp &fr, const VigFunc &vf, const Adjust &adj)
VT1 first_argument_type
the functor's first argument type
vigra::NumericTraits< VT1 >::RealPromote result_type
the functor's result type
VT1 first_argument_type
the functor's first argument type
result_type operator()(first_argument_type const &v1, float x, float y) const
calculate transform.
vigra::NumericTraits< VT1 >::RealPromote result_type
the functor's result type
VigCorrDivFunctor(const InvResp &fr, const VigFunc &vf, const Adjust &adj)
VT2 second_argument_type
the functor's second argument type
VigCorrFlatAddFunctor(const InvResp &fr, const Adjust &adj)
VT1 first_argument_type
the functor's first argument type
result_type operator()(first_argument_type const &v1, second_argument_type const &v2) const
calculate transform.
vigra::NumericTraits< VT2 >::RealPromote RVT2
vigra::NumericTraits< VT1 >::RealPromote result_type
the functor's result type
result_type operator()(first_argument_type const &v1, second_argument_type const &v2) const
calculate transform.
vigra::NumericTraits< VT2 >::RealPromote RVT2
VigCorrFlatDivFunctor(RVT2 mean, const InvResp &fr, const Adjust &adj)
VT1 first_argument_type
the functor's first argument type
VT2 second_argument_type
the functor's second argument type
vigra::NumericTraits< VT1 >::RealPromote result_type
the functor's result type
void flatfieldVigCorrection(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra::pair< FFIter, FFAccessor > ffImg, vigra::pair< DestIter, DestAccessor > destImg, double gamma, double gammaMaxVal, bool division, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote a, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote b, bool dither)
bool isTrueType(vigra::VigraFalseType)
void applyRadialVigCorrectionDither(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, vigra::pair< DestImageIterator, DestAccessor > dest, double cx, double cy, Functor const &f, bool dither)
Apply flatfield correction with dithering.
void applyBrightnessCorrection(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra::pair< DestIter, DestAccessor > destImg, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote a, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote b)
bool ditheringNeeded(T const &)
float pow(float a, double b)
void radialVigCorrection(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra::pair< DestIter, DestAccessor > destImg, double gamma, double gammaMaxVal, const std::vector< double > &radCoeff, hugin_utils::FDiff2D center, bool division, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote a, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote b, bool dither)
void applyRadialVigCorrection(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, vigra::pair< DestImageIterator, DestAccessor > dest, double cx, double cy, Functor const &f)
void applyGammaAndBrightCorrection(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra::pair< DestIter, DestAccessor > destImg, double gamma, double maxGVal, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote a, typename vigra::NumericTraits< typename ImgAccessor::value_type >::RealPromote b)
void applyGammaCorrection(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra::pair< DestIter, DestAccessor > destImg, double gamma, double maxGVal)
void combineTwoImagesDither(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra::pair< FFIter, FFAccessor > ffImg, vigra::pair< DestIter, DestAccessor > destImg, Functor const &f, bool dither)
Apply combine two images.
Dither code taken from enblend and adapted to a standalone functor.
T dither(const T &v, vigra::VigraFalseType) const
double dither(const double &v) const
T operator()(const T &v) const
T dither(const T &v, vigra::VigraTrueType) const
vigra::NumericTraits< T >::RealPromote operator()(T p) const
GammaFunctor(double g, double m)
functor to combine two functors: result = f1( f2(v) )
PolySqDistFunctor(const std::vector< double > &coeff)
double operator()(double x, double y) const
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
functions to manage ROI's