24#ifndef _VIGRA_EXT_LUT_H
25#define _VIGRA_EXT_LUT_H
32#include <vigra/stdimage.hxx>
33#include <vigra/numerictraits.hxx>
37#include <vigra/array_vector.hxx>
49template <
class VECTOR>
52 typedef typename VECTOR::value_type
VT;
56 for (
size_t i=0;
i<lut.size(); ++
i) {
57 double x =
i*1.0/(lut.size() -1);
58 lut[
i] = vigra::NumericTraits<VT>::fromRealPromote(
pow(x, gamma)*
s);
63template <
class VEC,
class VEC2>
89 typedef typename LUT::value_type lut_type;
93 lut_type max = lut.back();
98 }
else if (lut[
j+1] < lut[
j]) {
117template <
class VTIn,
class LUT>
158 double x=
v/m*(
m_lut.size()-1);
161 if ( x != 0 &&
i+1 <
m_lut.size()) {
173 if (
v > 1)
return m_lut.back();
175 double x=
v*(
m_lut.size()-1);
179 if (
i+1 <
m_lut.size()) {
181 return vigra::NumericTraits<lut_type>::fromRealPromote((1-x)*
m_lut[
i]+x*
m_lut[
i+1]);
188 vigra::RGBValue<lut_type>
applyVector( vigra::RGBValue<VT1>
v, vigra::VigraFalseType)
const
190 vigra::RGBValue<VT1>
ret;
191 for (
size_t i=0;
i <
v.size();
i++) {
198 vigra::RGBValue<lut_type>
applyVector(vigra::RGBValue<VT1>
v, vigra::VigraTrueType)
const
201 vigra::RGBValue<lut_type>
ret;
202 for (
size_t i=0;
i <
v.size();
i++) {
222 typedef typename vigra::NumericTraits<VT1>::isIntegral isIntegral;
226 vigra::RGBValue<lut_type>
apply(vigra::RGBValue<VT1>
v, vigra::VigraFalseType)
const
228 typedef typename vigra::NumericTraits<VT1>::isIntegral isIntegral;
233 typename vigra::NumericTraits<T>::RealPromote
operator()(T
v)
const
235 typedef typename vigra::NumericTraits<T>::isScalar
is_scalar;
251template <
class VT1,
class LUT>
279 if (
v <
m_lut[0])
return 0;
282 typename LUT::const_iterator p = lower_bound(
m_lut.begin(),
m_lut.end(),
v);
285 int x = p-
m_lut.begin();
294 }
else if (
v == *p) {
295 return x/(
m_lut.size()-1.0);
299 double lower = *(p-1);
316 vigra::RGBValue<lut_type>
applyVector( vigra::RGBValue<T>
v, vigra::VigraFalseType)
const
318 vigra::RGBValue<VT1>
ret;
319 for (
size_t i=0;
i <
v.size();
i++) {
326 vigra::RGBValue<lut_type>
applyVector(vigra::RGBValue<T>
v, vigra::VigraTrueType)
const
328 vigra::RGBValue<lut_type>
ret;
329 for (
size_t i=0;
i <
v.size();
i++) {
352 typedef typename vigra::NumericTraits<T>::isIntegral isIntegral;
357 vigra::RGBValue<lut_type>
apply(vigra::RGBValue<T>
v, vigra::VigraFalseType)
const
359 typedef typename vigra::NumericTraits<T>::isIntegral isIntegral;
364 typename vigra::NumericTraits<T>::RealPromote
operator()(T
v)
const
366 typedef typename vigra::NumericTraits<T>::isScalar
is_scalar;
388 typename vigra::NumericTraits<VT>::RealPromote
misc math function & classes used by other parts of the program
void resizeLUT(const VEC &iLUT, VEC2 &oLUT)
float pow(float a, double b)
void createGammaLUT(double gamma, VECTOR &lut)
void enforceMonotonicity(LUT &lut)
enforce monotonicity of an array (mostly used for lookup tables)
just apply exposure and response to linear data
ExposureResponseFunctor(double exposure, OP &operation)
vigra::NumericTraits< VT >::RealPromote operator()(VT v)
functor to apply a LUT to gray and color images.
vigra::NumericTraits< T >::RealPromote operator()(T v) const
LUT::value_type lut_type
the functor's first argument type
vigra::RGBValue< lut_type > apply(vigra::RGBValue< T > v, vigra::VigraFalseType) const
InvLUTFunctor()
the functor's result type
lut_type applyLutFloat(lut_type v) const
InvLUTFunctor(LUT &lut)
create a LUT functor.
lut_type applyScalar(T v, vigra::VigraFalseType) const
lut_type applyLutInteger(T i) const
lut_type apply(T v, vigra::VigraTrueType) const
vigra::RGBValue< lut_type > applyVector(vigra::RGBValue< T > v, vigra::VigraTrueType) const
lut_type applyScalar(T v, vigra::VigraTrueType) const
vigra::RGBValue< lut_type > applyVector(vigra::RGBValue< T > v, vigra::VigraFalseType) const
functor to apply a LUT to gray and color images.
vigra::RGBValue< lut_type > applyVector(vigra::RGBValue< VT1 > v, vigra::VigraFalseType) const
LUTFunctor()
the functor's result type
lut_type applyScalar(VT1 v, vigra::VigraFalseType) const
vigra::RGBValue< lut_type > apply(vigra::RGBValue< VT1 > v, vigra::VigraFalseType) const
LUTFunctor(LUT &lut)
create a LUT functor.
LUT::value_type lut_type
the functor's first argument type
lut_type applyLutInteger(VT1 v) const
lut_type applyScalar(VT1 v, vigra::VigraTrueType) const
vigra::RGBValue< lut_type > applyVector(vigra::RGBValue< VT1 > v, vigra::VigraTrueType) const
lut_type apply(VT1 v, vigra::VigraTrueType) const
vigra::NumericTraits< T >::RealPromote operator()(T v) const
vigra_ext::ValueTypeTraits< VTIn >::value_type VT1
lut_type applyLutFloat(double v) const
T1::value_type value_type
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