31#ifndef FUNCTOR_PACK_H_
32#define FUNCTOR_PACK_H_
62 this->getParameters().link(
"scale", this->
scale);
63 this->getParameters().link(
"bias", this->
bias);
68 this->parameters.
copyStruct(ftor.getParameters(), ftor, *
this);
74 double operator()(
double s)
const {
80 ScalingFunctor(
const std::string & name,
const std::string & description,
double scale = 1.0,
double bias = 0.0) :
121 RemappingFunctor(
double fromValue = 0.0,
double toValue = 0.0) :
UnaryFunctor(__FUNCTION__,
"Rescales intensities linerarly") , fromValue(fromValue), toValue(toValue) {
122 this->getParameters().link(
"fromValue", this->fromValue = fromValue);
123 this->getParameters().link(
"toValue", this->toValue = toValue);
127 parameters.
copyStruct(ftor.parameters, ftor, *
this);
132 double operator()(
double s)
const {
140 double fromValue = 0.0;
141 double toValue = 0.0;
160 ThresholdFunctor(
double threshold = 0.5,
double replace = 0.0) :
UnaryFunctor(__FUNCTION__,
"Resets values lower than a threshold") , threshold(threshold), replace(replace) {
161 this->getParameters().link(
"threshold", this->threshold = threshold);
162 this->getParameters().link(
"replace", this->replace = replace);
166 parameters.
copyStruct(ftor.parameters, ftor, *
this);
171 double operator()(
double s)
const override {
178 double threshold = 0.5;
179 double replace = 0.0;
198 BinaryThresholdFunctor(
double threshold = 0.5,
double replaceLow = 0.0,
double replaceHigh = 1.0) :
UnaryFunctor(__FUNCTION__,
"Resets values lower and higher than a threshold") {
199 this->getParameters().link(
"threshold", this->threshold.tuple(threshold,threshold),
"min[:max]").fillArray =
true;
200 this->getParameters().link(
"replace", this->replace.tuple(replaceLow, replaceHigh),
"min[:max]");
204 parameters.
copyStruct(ftor.parameters, ftor, *
this);
208 double operator()(
double s)
const override {
209 if (s < threshold.min)
211 else if (s > threshold.max)
256 this->getParameters().link(
"gamma", this->gamma = gamma,
"0.0...");
260 this->getParameters().link(
"gamma", this->gamma = ftor.gamma,
"0.0..");
266 double operator()(
double s)
const {
267 return this->
scale * pow(s, 1.0/gamma);
292 this->getParameters().link(
"scale", this->
scale);
293 this->getParameters().link(
"bias", this->
bias);
297 double operator()(
double s1,
double s2)
const {
317 this->getParameters().link(
"scale", this->
scale);
318 this->getParameters().link(
"bias", this->
bias);
322 double operator()(
double s1,
double s2)
const {
355 this->getParameters().link(
"scale", this->
scale);
356 this->getParameters().link(
"bias", this->
bias);
361 double operator()(
double s1,
double s2)
const {
379 this->getParameters().link(
"scale", this->
scale);
380 this->getParameters().link(
"bias", this->
bias);
385 double operator()(
double s1,
double s2)
const {
424 this->getParameters().link(
"coeff", this->coeff);
425 this->getParameters().link(
"scale", this->
scale);
426 this->getParameters().link(
"bias", this->
bias);
432 parameters.
copyStruct(ftor.parameters, ftor, *
this);
438 double operator()(
double s1,
double s2)
const {
444 void updateScale()
const {
446 this->scaleFinal2 = this->
scale*(1.0-this->coeff);
455 double scaleFinal2 = 1.0;
480 double operator()(
double s1,
double s2)
const {
481 return this->
scale * std::max(
static_cast<double>(s1),
static_cast<double>(s2)) + this->
bias;
505 double operator()(
double s1,
double s2)
const {
506 return this->
scale * std::min(
static_cast<double>(s1),
static_cast<double>(s2)) + this->
bias;
Adds a intensity values .
Definition FunctorPack.h:287
Thresholds intensity values.
Definition FunctorPack.h:194
Divides image by another image.
Definition FunctorPack.h:374
double scale
Relative scale, typically 1. Optional.
Definition Functor.h:99
double scaleFinal
Scaling factor after encodings of src and dst images are known.
Definition Functor.h:106
double bias
"Relative" bias, typically 0. Optional.
Definition Functor.h:102
virtual void updateBean() const override
Called after setParameters()
Definition Functor.h:65
double biasFinal
Scaling factor after encodings of src and dst images are known.
Definition Functor.h:110
Gamma correction. Intensity is mapped as f' = f^(gamma)
Definition FunctorPack.h:251
Definition FunctorPack.h:471
Minimum intensity. Prescaled input.
Definition FunctorPack.h:496
Blends an image to another with given proportion.
Definition FunctorPack.h:419
Multiplies two images, with optional post scaling and offset.
Definition FunctorPack.h:350
Inverts intensities: f' = f_max - f.
Definition FunctorPack.h:97
void copyStruct(const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
Experimental. Copies references and values of a structure to another.
Definition ReferenceMap.h:407
Maps a single intensity value to another value.
Definition FunctorPack.h:117
Rescales intensities linearly: f' = scale*f + offset.
Definition FunctorPack.h:57
Subtracts image from another image.
Definition FunctorPack.h:312
Thresholds intensity values.
Definition FunctorPack.h:156
Definition DataSelector.cpp:1277