24#ifndef _FUNCTORACCESSOR_H
25#define _FUNCTORACCESSOR_H
27#include <vigra/numerictraits.hxx>
40template <
class Functor,
class Accessor>
57 template <
typename ITERATOR_,
typename DIFFERENCE_>
65 template <
class ITERATOR>
83template <
class Functor,
class Accessor,
class ValueType>
97 template <
class Value,
class ITERATOR>
105 template <
class Value,
class ITERATOR_,
class DIFFERENCE_>
145template <
class Iter1,
class Acc1,
class Iter2,
class Acc2>
151 typedef vigra::TinyVector<typename Acc1::value_type, 2>
value_type;
161 template <
class V,
class ITERATOR>
172 vigra_fail(
"too many components in input value");
177 template <
class ITERATOR>
199template <
class Iter1,
class Acc1,
class Iter2,
class Acc2,
int SIZE>
205 typedef vigra::TinyVector<typename Acc1::value_type, SIZE>
value_type;
215 template <
class V,
class ITERATOR>
218 if (
idx < SIZE - 1 ) {
220 }
else if (
idx == SIZE - 1 ) {
223 vigra_fail(
"too many components in input value");
228 template <
class ITERATOR>
245template <
class Iter1,
class Acc1,
class Iter2,
class Acc2>
251 typedef vigra::TinyVector<typename Acc1::value_type, 2>
value_type;
262 template <
class DIFFERENCE_>
269 template <
class ITERATOR>
278 vigra_fail(
"too many components in input value");
285 template <
class ITERATOR,
class DIFFERENCE_>
295 vigra_fail(
"too many components in input value");
300 template <
class ITERATOR>
321template <
class Iter1,
class Acc1,
class Iter2,
class Acc2,
int SIZE>
342 template <
class DIFFERENCE_>
346 typename value_type::iterator
it =
ret.begin();
348 for (
typename image1_type::const_iterator
it1 = i1.begin();
359 template <
class ITERATOR>
362 if (
idx < SIZE - 1 ) {
364 }
else if (
idx == SIZE - 1 ) {
367 vigra_fail(
"too many components in input value");
376 template <
class ITERATOR,
class DIFFERENCE_>
380 if (
idx < SIZE - 1 ) {
382 }
else if (
idx == SIZE - 1 ) {
385 vigra_fail(
"too many components in input value");
395 template <
class ITERATOR>
440template <
class Iter1,
class Acc1,
class Iter2,
class Acc2,
int SIZE>
465 template <
class V,
class ITERATOR>
469 vigra::NumericTraits<image_type1>::isScalar() );
484 template <
class V,
class ITERATOR>
493 typename V::iterator
vIt = value.begin();
494 typename image_type1::iterator
v1It =
v1.begin();
495 while (
v1It !=
v1.end() &&
vIt != value.end()) {
496 *
v1It = detail::RequiresExplicitCast<VALUETYPE>::cast(*
vIt);
501 typename image_type2::iterator
v2It =
v2.begin();
502 while (
v2It !=
v1.end() &&
vIt != value.end()) {
503 *
v2It = detail::RequiresExplicitCast<VALUETYPE>::cast(*
vIt);
510 for (
int i=0;
i < value.size();
i++) {
513 *
i = detail::RequiresExplicitCast<VALUETYPE>::cast(value); }
520 template <
class V,
class ITERATOR,
class DIFFERENCE_>
523 i[
diff]= detail::RequiresExplicitCast<VALUETYPE>::cast(value);
530 template <
class V,
class ITERATOR>
532 vigra::VigraTrueType)
const
535 vigra::NumericTraits<image_type2>::isScalar() );
539 template <
class V,
class ITERATOR>
541 vigra::VigraFalseType)
const
544 vigra::NumericTraits<image_type2>::isScalar() );
548 template <
class V,
class ITERATOR>
550 vigra::VigraTrueType)
const
560 vigra_fail(
"too many components in input value");
565 template <
class V,
class ITERATOR>
567 vigra::VigraTrueType)
const
569 vigra_fail(
"vector -> scalar, vector accessor not implemented");
573 template <
class V,
class ITERATOR>
575 vigra::VigraTrueType)
const
578 typename image_type1::size_type
s1 =
v1.size();
580 a1_.setComponent(value,
i,
idx);
581 }
else if (
idx ==
s1) {
584 vigra_fail(
"too many components in input value");
589 template <
class V,
class ITERATOR>
591 vigra::VigraTrueType)
const
593 vigra_fail(
"vector -> vector, vector accessor not implemented");
612 template <
class PixelType>
615 return vigra::NumericTraits<result_type>::fromRealPromote(
v * m_factor);
An accessor to encapsulate write access to a multiband image, and move divide it into two images.
Acc2::value_type image_type2
value type of image 2
void setComponent(V const &value, ITERATOR const &i, int idx) const
write value V into the two images.
ImageSplittingAccessor(Iter1 i1, Acc1 a1, Iter2 i2, Acc2 a2)
Construct from two image iterators and associated accessors.
void setComponentIsScalar(V const &value, ITERATOR const &i, int idx, vigra::VigraFalseType) const
if first dest image is vector image
void setComponentScalarIsScalar(V const &value, ITERATOR const &i, int idx, vigra::VigraTrueType) const
if scalar & scalar image
void setComponentVectorIsVector(V const &value, ITERATOR const &i, int idx, vigra::VigraTrueType) const
if vector & vector image
Acc1::value_type image_type1
value type of image 1
void setComponentScalarIsVector(V const &value, ITERATOR const &i, int idx, vigra::VigraTrueType) const
if scalar & vector image
void setComponentVectorIsScalar(V const &value, ITERATOR const &i, int idx, vigra::VigraTrueType) const
if vector & scalar image
void setComponentIsScalar(V const &value, ITERATOR const &i, int idx, vigra::VigraTrueType) const
if first dest image is scalar
merge two scalar images into a vector image.
value_type operator()(DIFFERENCE_ const &d) const
read the current data item
MergeScalarScalar2VectorAccessor(Iter1 i1, Acc1 a1, Iter2 i2, Acc2 a2)
Construct from two image iterators and associated accessors.
unsigned int size(ITERATOR const &i) const
return the size (Number of Bands)
component_type const & getComponent(ITERATOR const &i, DIFFERENCE_ const &d, int idx) const
read one component, with offset
component_type getComponent(ITERATOR const &i, int idx) const
read one component
vigra::TinyVector< typename Acc1::value_type, 2 > value_type
the vector's value_type
value_type::value_type component_type
merge a vector and a scalar image into a vector image.
image1_type::value_type component_type
MergeVectorScalar2VectorAccessor(Iter1 i1, Acc1 a1, Iter2 i2, Acc2 a2)
Construct from two image iterators and associated accessors.
component_type const getComponent(ITERATOR i, DIFFERENCE_ const &d, int idx) const
read one component, with offset
vigra::TinyVector< component_type, SIZE > value_type
unsigned int size(ITERATOR const &i) const
return the size (Number of Bands)
component_type getComponent(ITERATOR const &i, int idx) const
read one component
Acc2::value_type image2_type
Acc1::value_type image1_type
the vector's value_type
value_type operator()(DIFFERENCE_ const &d) const
read the current data item
This class can be used to apply a function when reading the input image.
Functor::result_type operator()(ITERATOR const &i) const
Get functor result.
ReadFunctorAccessor(Functor f, Accessor a)
Functor::result_type operator()(ITERATOR_ const &i, DIFFERENCE_ d) const
Get functor result template <class A, class B> void function(A a, B b) { };.
Functor::result_type value_type
define a write only accessor for a virtual Image<TinyVector<Acc1::value_type>, 2> image,...
value_type::value_type component_type
SplitVector2Accessor(Iter1 i1, Acc1 a1, Iter2 i2, Acc2 a2)
Construct from two image iterators and associated accessors.
void setComponent(V const &value, ITERATOR const &i, int idx) const
scalar & scalar image
unsigned int size(ITERATOR const &i) const
return the size (Number of Bands)
vigra::TinyVector< typename Acc1::value_type, 2 > value_type
the vector's value_type
split a vector image into a vector and a scalar image
void setComponent(V const &value, ITERATOR const &i, int idx) const
vector & scalar image
vigra::TinyVector< typename Acc1::value_type, SIZE > value_type
the vector's value_type
unsigned int size(ITERATOR const &i) const
return the size (Number of Bands)
value_type::value_type component_type
SplitVectorNAccessor(Iter1 i1, Acc1 a1, Iter2 i2, Acc2 a2)
Construct from two image iterators and associated accessors.
This class can be used to apply a function when writing to an image.
WriteFunctorAccessor(Functor f, Accessor a)
void set(Value const &v, ITERATOR_ const &i, DIFFERENCE_ d) const
Set functor result.
void set(Value const &v, ITERATOR const &i) const
Set functor result.
a sample functor that can be used to multiply pixel values with a constant
PixelType operator()(PixelType const &v) 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.