Structural deformable models
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Sensor Class Referenceabstract

#include <Sensor.h>

Inheritance diagram for Sensor:
Inheritance graph
[legend]
Collaboration diagram for Sensor:
Collaboration graph
[legend]

Public Types

enum  UpdateParam {
  UPD_NOTHING =0, UPD_DATA =1, UPD_SCALE =2, UPD_CWEIGHTS =4,
  UPD_DIR =8, UPD_MINMAX =16, UPD_LAST =32, UPD_ALL =0xffffffff
}
 

Public Member Functions

virtual ~Sensor ()
 
sensor_cptr getSource ()
 
virtual void changeSource (sensor_cptr _source)
 
void replaceBy (sensor_ptr target)
 
bool assignRef (sensor_cptr rhs)
 
virtual Sensorassign (const Sensor &rhs)
 
virtual float getValue (int x, int y) const
 get value at discrete position More...
 
float getValue (const Point &p) const
 get value at position p using nearest neighbour interpolation More...
 
virtual std::vector< float > getMValue (int x, int y) const
 get multi-channel value More...
 
virtual Point2D getGradient (int x, int y) const
 get gradient at discrete position More...
 
Point2D getGradient (const Point2D &p) const
 get gradient at position p using nearest neighbor interpolation More...
 
float getMax () const
 
float getMin () const
 
float getMinMaxRange () const
 
float getWeightedValue (int x, int y) const
 get max normalized value at discrete position range [0,1] More...
 
Point2D getWeightedGradient (int x, int y) const
 get range weighted gradient at discrete position More...
 
void setCWeights (const std::vector< float > &weights)
 
const std::vector< float > & getCWeights () const
 
void setDirection (const Point &dir)
 
const PointgetDirection () const
 
void setScale (float _scale)
 
float getScale () const
 
bool isModified (dword mask=UPD_ALL) const
 
void setModified (dword mask=UPD_ALL)
 
void unsetModified (dword mask=UPD_ALL)
 
bool isUpdate (dword udMask) const
 
void enableUpdate (dword udMask)
 
void disableUpdate (dword udMask)
 
virtual bool performUpdate ()
 
virtual int getDim1Size () const
 
virtual int getDim2Size () const
 
virtual int getDim3Size () const
 
virtual int getNChannels () const
 
virtual int getSkip () const
 
bool isValid (int x, int y) const
 
virtual Image< float > createSensorImage () const
 
const std::string & getID () const
 
void setID (const std::string &id)
 
virtual std::ostream & hprint (std::ostream &os, SensorCollection *sc) const
 
virtual std::ostream & print (std::ostream &os) const
 
void refSuperSensor (sensor_ptr super)
 
void unrefSuperSensor (sensor_ptr super)
 
void invalidateSource ()
 
template<typename Derived >
std::shared_ptr< Derived > shared_from_base ()
 

Static Public Member Functions

static dword getStringNumber (const char *sid)
 
static void getNumberString (char sid[5], dword id)
 

Protected Member Functions

 Sensor (dword updateMask)
 
 Sensor ()
 
virtual float calcValue (int x, int y) const =0
 
virtual std::vector< float > calcMValue (int x, int y) const
 
virtual Point calcGradient (int x, int y) const
 
virtual void calcMinMax ()
 

Protected Attributes

sensor_cptr source
 
float scale
 
std::vector< float > cweights
 multi-channel weights ('color') More...
 
Point dir
 direction parameter More...
 
float maxval
 
float minval
 overall minimum and maximum More...
 
float mean
 
float stdev
 overall mean and stdev More...
 
dword toupdate
 bitflag for updates More...
 
dword updateMask
 bitflag to mask unimportant updates More...
 
std::string m_ID
 
int m_Skip
 
int m_AddSkip
 

Detailed Description

Sensor calculates filter values from the source.

Definition at line 21 of file Sensor.h.

Member Enumeration Documentation

Enumerator
UPD_NOTHING 
UPD_DATA 
UPD_SCALE 
UPD_CWEIGHTS 
UPD_DIR 
UPD_MINMAX 
UPD_LAST 
UPD_ALL 

Definition at line 26 of file Sensor.h.

Constructor & Destructor Documentation

Sensor::Sensor ( dword  updateMask)
protected

Definition at line 13 of file Sensor.cpp.

References cweights.

14  : source(),
15  scale(0.f),
16  maxval(), minval(), mean(), stdev(),
17  toupdate(), updateMask(_updateMask),
18  m_ID(""), m_Skip(0), m_AddSkip(0)
19 {
20  cweights.resize(1, 1.f);
21 }
float minval
overall minimum and maximum
Definition: Sensor.h:176
int m_AddSkip
Definition: Sensor.h:183
std::vector< float > cweights
multi-channel weights (&#39;color&#39;)
Definition: Sensor.h:174
dword toupdate
bitflag for updates
Definition: Sensor.h:179
float scale
Definition: Sensor.h:173
float mean
Definition: Sensor.h:177
std::string m_ID
Definition: Sensor.h:181
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
sensor_cptr source
Definition: Sensor.h:170
int m_Skip
Definition: Sensor.h:182
float stdev
overall mean and stdev
Definition: Sensor.h:177
float maxval
Definition: Sensor.h:176
Sensor::Sensor ( )
protected

Definition at line 23 of file Sensor.cpp.

References cweights, and setModified().

24  : source(getZeroSensor()),
25  scale(0.f),
26  maxval(), minval(), mean(), stdev(),
28  m_ID(""), m_Skip(0), m_AddSkip(0)
29 {
30  cweights.resize(1, 1.f);
31  setModified();
32 }
float minval
overall minimum and maximum
Definition: Sensor.h:176
int m_AddSkip
Definition: Sensor.h:183
std::vector< float > cweights
multi-channel weights (&#39;color&#39;)
Definition: Sensor.h:174
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
dword toupdate
bitflag for updates
Definition: Sensor.h:179
unsigned long dword
Definition: simpletypes.h:6
float scale
Definition: Sensor.h:173
float mean
Definition: Sensor.h:177
std::string m_ID
Definition: Sensor.h:181
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
sensor_cptr source
Definition: Sensor.h:170
int m_Skip
Definition: Sensor.h:182
float stdev
overall mean and stdev
Definition: Sensor.h:177
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
float maxval
Definition: Sensor.h:176
Sensor::~Sensor ( )
virtual

Destructor

Definition at line 34 of file Sensor.cpp.

References getZeroSensor(), source, and unrefSuperSensor().

35 {
36  if(source && source != getZeroSensor())
37  std::const_pointer_cast<Sensor>(source)->unrefSuperSensor( shared_from_this() );
38  for(set<sensor_ptr>::iterator ss = superSensors.begin();
39  ss != superSensors.end();
40  ss++)
41  (*ss)->invalidateSource();
42 }
Definition: Sensor.h:21
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
void unrefSuperSensor(sensor_ptr super)
Definition: Sensor.cpp:186
sensor_cptr source
Definition: Sensor.h:170

Member Function Documentation

Sensor & Sensor::assign ( const Sensor rhs)
virtual

Reimplemented in MappingSensor, MahalSensor, CombiSensor, and PPSensor.

Definition at line 54 of file Sensor.cpp.

References changeSource(), cweights, dir, m_AddSkip, m_ID, m_Skip, scale, setCWeights(), setDirection(), setScale(), and source.

Referenced by PPSensor::assign(), assignRef(), MahalSensor::getNChannels(), MappingSensor::getNChannels(), getSource(), and CombiSensor::setSource().

55 {
56  if(&rhs != this) {
57  if(source != rhs.source) changeSource(rhs.source);
58  if(scale != rhs.scale) setScale(rhs.scale);
59  if(dir != rhs.dir) setDirection(rhs.dir);
60  if(cweights != rhs.cweights) setCWeights(rhs.cweights);
61  m_ID = rhs.m_ID;
62  m_Skip = rhs.m_Skip;
63  m_AddSkip = rhs.m_AddSkip;
64  //superSensors are not changed here (no sensor fusion)
65  }
66  return *this;
67 }
int m_AddSkip
Definition: Sensor.h:183
virtual void changeSource(sensor_cptr _source)
Definition: Sensor.cpp:96
std::vector< float > cweights
multi-channel weights (&#39;color&#39;)
Definition: Sensor.h:174
void setScale(float _scale)
Definition: Sensor.cpp:119
Point dir
direction parameter
Definition: Sensor.h:175
float scale
Definition: Sensor.h:173
std::string m_ID
Definition: Sensor.h:181
void setCWeights(const std::vector< float > &weights)
Definition: Sensor.cpp:109
sensor_cptr source
Definition: Sensor.h:170
int m_Skip
Definition: Sensor.h:182
void setDirection(const Point &dir)
Definition: Sensor.cpp:115
bool Sensor::assignRef ( sensor_cptr  rhs)

Definition at line 69 of file Sensor.cpp.

References assign().

Referenced by getSource().

69  {
70  if(typeid(*this) != typeid(*rhs)) return false;
71  assign(*rhs);
72  return true;
73 }
virtual Sensor & assign(const Sensor &rhs)
Definition: Sensor.cpp:54
virtual Point Sensor::calcGradient ( int  x,
int  y 
) const
inlineprotectedvirtual

Calculates the gradient using central differencing.

Reimplemented in ZeroSensor, and MCGSensor.

Definition at line 149 of file Sensor.h.

References calcMinMax(), getValue(), invalidateSource(), refSuperSensor(), and unrefSuperSensor().

Referenced by PPSensor::calcAllGradients(), getGradient(), and PPSensor::getGradient().

149  {
150  float v = getValue(x,y);
151  return Point2D(getValue(x+1,y)-v,
152  getValue(x,y+1)-v);
153  }
virtual float getValue(int x, int y) const
get value at discrete position
Definition: Sensor.h:41
Definition: Point.h:16
void Sensor::calcMinMax ( )
protectedvirtual

Reimplemented in Dataset.

Definition at line 152 of file Sensor.cpp.

References dmutil::avg(), getValue(), maxval, mean, minval, source, dmutil::sqrt(), and stdev.

Referenced by calcGradient(), and performUpdate().

152  {
153  if(!source) {
154  minval = maxval = 0;
155  mean = stdev = 0;
156  return;
157  }
158  int i,j;
159  minval=numeric_limits<float>::max();
160  maxval=numeric_limits<float>::min();
161  double avg=0, avg2=0;
162  double size = double(source->getDim1Size()*source->getDim2Size());
163  if(size > 0.) {
164  for(j=0; j<source->getDim2Size(); j++) {
165  for(i=0; i<source->getDim1Size(); i++) {
166  float val = getValue(i,j);
167  if(val>maxval) maxval = val;
168  if(val<minval) minval = val;
169  avg+=double(val);
170  avg2+=double(val*val);
171  }
172  }
173  avg /= size;
174  avg2 /= size;
175  } else {
176  minval = maxval = 0;
177  }
178  mean = float(avg);
179  stdev = float(sqrt(avg2-avg*avg))*1.5;
180 }
float minval
overall minimum and maximum
Definition: Sensor.h:176
virtual float getValue(int x, int y) const
get value at discrete position
Definition: Sensor.h:41
DMatrix< T > avg(const DMatrix< T > &mat)
Definition: DMatrixUtil.h:90
float mean
Definition: Sensor.h:177
sensor_cptr source
Definition: Sensor.h:170
float stdev
overall mean and stdev
Definition: Sensor.h:177
float maxval
Definition: Sensor.h:176
DMatrix< T > & sqrt(DMatrix< T > &mat)
Definition: DMatrixUtil.h:81
virtual std::vector<float> Sensor::calcMValue ( int  x,
int  y 
) const
inlineprotectedvirtual

Calculate a multi-valued sensor result. The size of the returned vector is the same as getNChannels().

Reimplemented in CombiSensor, and Dataset.

Definition at line 145 of file Sensor.h.

References calcValue(), and getNChannels().

Referenced by getMValue().

145  {
146  return std::vector<float>(getNChannels(), calcValue(x,y));
147  }
virtual float calcValue(int x, int y) const =0
virtual int getNChannels() const
Definition: Sensor.h:123
virtual float Sensor::calcValue ( int  x,
int  y 
) const
protectedpure virtual

Compute a sensed value at position x,y. This function is essential for all derived sensors.

Implemented in MappingSensor, MahalSensor, CombiSensor, CornerSensor, ZeroSensor, GradMagSensor, SmoothIntensitySensor, CRSensor, Dataset, MCGSensor, MCIntensitySensor, PPIntensitySensor, and IntensitySensor.

Referenced by PPSensor::calcAllValues(), calcMValue(), getValue(), PPSensor::getValue(), and setID().

void Sensor::changeSource ( sensor_cptr  _source)
virtual

Reimplemented in CombiSensor, and ZeroSensor.

Definition at line 96 of file Sensor.cpp.

References cweights, getZeroSensor(), refSuperSensor(), setModified(), source, unrefSuperSensor(), and UPD_DATA.

Referenced by assign(), CombiSensor::changeSource(), CombiSensor::getSkip(), and getSource().

96  {
97  assert(source);
98  std::const_pointer_cast<Sensor>(source)->unrefSuperSensor( shared_from_this() );
99  if(!_source)
100  source = getZeroSensor();
101  else
102  source = _source;
103  if(cweights.size() != size_t(source->getNChannels()))
104  cweights.resize(source->getNChannels(), 1.f);
105  std::const_pointer_cast<Sensor>(source)->refSuperSensor( shared_from_this() );
107 }
std::vector< float > cweights
multi-channel weights (&#39;color&#39;)
Definition: Sensor.h:174
Definition: Sensor.h:21
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
void unrefSuperSensor(sensor_ptr super)
Definition: Sensor.cpp:186
void refSuperSensor(sensor_ptr super)
Definition: Sensor.cpp:182
sensor_cptr source
Definition: Sensor.h:170
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
Image< float > Sensor::createSensorImage ( ) const
virtual

Definition at line 203 of file Sensor.cpp.

References getDim1Size(), getDim2Size(), getWeightedValue(), and Image< T >::setPixel().

Referenced by getSkip().

203  {
205  int i,j;
206  for(j=0;j<getDim2Size();j++)
207  for(i=0;i<getDim1Size();i++) {
208  img.setPixel(i,j, getWeightedValue(i,j));
209  }
210  return img;
211 }
float getWeightedValue(int x, int y) const
get max normalized value at discrete position range [0,1]
Definition: Sensor.h:76
virtual int getDim1Size() const
Definition: Sensor.h:120
virtual int getDim2Size() const
Definition: Sensor.h:121
void Sensor::disableUpdate ( dword  udMask)
inline

Definition at line 114 of file Sensor.h.

References performUpdate().

114 { updateMask &= ~udMask; }
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
void Sensor::enableUpdate ( dword  udMask)
inline

Definition at line 113 of file Sensor.h.

Referenced by CombiSensor::changeSource(), CombiSensor::CombiSensor(), CornerSensor::CornerSensor(), GradMagSensor::GradMagSensor(), and CombiSensor::setSource().

113 { updateMask |= udMask; }
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
const std::vector<float>& Sensor::getCWeights ( ) const
inline

Definition at line 97 of file Sensor.h.

References cweights, dir, and setDirection().

Referenced by CombiSensor::assign().

97 { return cweights; }
std::vector< float > cweights
multi-channel weights (&#39;color&#39;)
Definition: Sensor.h:174
virtual int Sensor::getDim1Size ( ) const
inlinevirtual

the real dataset will override these

Reimplemented in ZeroSensor, and Dataset.

Definition at line 120 of file Sensor.h.

References source.

Referenced by createSensorImage(), and isValid().

120 { return source->getDim1Size(); }
sensor_cptr source
Definition: Sensor.h:170
virtual int Sensor::getDim2Size ( ) const
inlinevirtual

Reimplemented in ZeroSensor, and Dataset.

Definition at line 121 of file Sensor.h.

References source.

Referenced by createSensorImage(), and isValid().

121 { return source->getDim2Size(); }
sensor_cptr source
Definition: Sensor.h:170
virtual int Sensor::getDim3Size ( ) const
inlinevirtual

Reimplemented in ZeroSensor, and Dataset.

Definition at line 122 of file Sensor.h.

References source.

122 { return source->getDim3Size(); }
sensor_cptr source
Definition: Sensor.h:170
const Point& Sensor::getDirection ( ) const
inline

Definition at line 99 of file Sensor.h.

References dir, and setScale().

99 { return dir; }
Point dir
direction parameter
Definition: Sensor.h:175
virtual Point2D Sensor::getGradient ( int  x,
int  y 
) const
inlinevirtual

get gradient at discrete position

Reimplemented in PPSensor.

Definition at line 53 of file Sensor.h.

References calcGradient().

Referenced by getGradient(), and getWeightedGradient().

53  {
54  return calcGradient(x,y);
55  }
virtual Point calcGradient(int x, int y) const
Definition: Sensor.h:149
Point2D Sensor::getGradient ( const Point2D p) const
inline

get gradient at position p using nearest neighbor interpolation

Definition at line 57 of file Sensor.h.

References getGradient(), Point2D::x, and Point2D::y.

57  {
58 // float v = getValue(p);
59 // return Point2D(getValue(p+Point2D(1,0))-v,
60 // getValue(p+Point2D(0,1))-v);
61  return getGradient((int)p.x, (int)p.y);
62  };
float y
Definition: Point.h:224
virtual Point2D getGradient(int x, int y) const
get gradient at discrete position
Definition: Sensor.h:53
float x
Definition: Point.h:224
const std::string& Sensor::getID ( ) const
inline

Definition at line 128 of file Sensor.h.

References m_ID.

Referenced by CombiSensor::print().

128 { return m_ID; }
std::string m_ID
Definition: Sensor.h:181
float Sensor::getMax ( ) const
inline

Definition at line 63 of file Sensor.h.

References isModified(), and maxval.

63  {
64  if(isModified()) ((Sensor*)this)->performUpdate();
65  return maxval;
66  }
bool isModified(dword mask=UPD_ALL) const
Definition: Sensor.h:108
Definition: Sensor.h:21
float maxval
Definition: Sensor.h:176
float Sensor::getMin ( ) const
inline

Definition at line 67 of file Sensor.h.

References isModified(), and minval.

67  {
68  if(isModified()) ((Sensor*)this)->performUpdate();
69  return minval;
70  }
bool isModified(dword mask=UPD_ALL) const
Definition: Sensor.h:108
float minval
overall minimum and maximum
Definition: Sensor.h:176
Definition: Sensor.h:21
float Sensor::getMinMaxRange ( ) const
inline

Definition at line 71 of file Sensor.h.

References isModified(), maxval, and minval.

Referenced by getWeightedGradient(), and getWeightedValue().

71  {
72  if(isModified()) ((Sensor*)this)->performUpdate();
73  return maxval-minval;
74  }
bool isModified(dword mask=UPD_ALL) const
Definition: Sensor.h:108
float minval
overall minimum and maximum
Definition: Sensor.h:176
Definition: Sensor.h:21
float maxval
Definition: Sensor.h:176
virtual std::vector<float> Sensor::getMValue ( int  x,
int  y 
) const
inlinevirtual

get multi-channel value

Definition at line 49 of file Sensor.h.

References calcMValue().

Referenced by ImageWindow::onKeyPress().

49  {
50  return calcMValue(x,y);
51  }
virtual std::vector< float > calcMValue(int x, int y) const
Definition: Sensor.h:145
virtual int Sensor::getNChannels ( ) const
inlinevirtual

Reimplemented in MappingSensor, MahalSensor, CombiSensor, ZeroSensor, CRSensor, MCGSensor, Dataset, and MCIntensitySensor.

Definition at line 123 of file Sensor.h.

References source.

Referenced by calcMValue(), and CombiSensor::calcMValue().

123 { return source->getNChannels(); }
sensor_cptr source
Definition: Sensor.h:170
void Sensor::getNumberString ( char  sid[5],
dword  id 
)
static

Definition at line 88 of file Sensor.cpp.

Referenced by setID().

89 {
90  int i;
91  for(i=0;i<4 && id!=0;i++,id=id>>8)
92  sid[i] = char(id);
93  sid[i] = 0;
94 }
float Sensor::getScale ( ) const
inline

Definition at line 101 of file Sensor.h.

References scale.

Referenced by SmoothIntensitySensor::print().

101 { return scale; }
float scale
Definition: Sensor.h:173
virtual int Sensor::getSkip ( ) const
inlinevirtual

Reimplemented in CombiSensor.

Definition at line 124 of file Sensor.h.

References createSensorImage(), isValid(), and m_Skip.

124 { return m_Skip; }
int m_Skip
Definition: Sensor.h:182
sensor_cptr Sensor::getSource ( )
inline

Definition at line 34 of file Sensor.h.

References assign(), assignRef(), changeSource(), replaceBy(), and source.

34 {return source;}
sensor_cptr source
Definition: Sensor.h:170
dword Sensor::getStringNumber ( const char *  sid)
static

Definition at line 75 of file Sensor.cpp.

Referenced by setID().

75  {
76  if(!sid) return 0;
77  else {
78  dword val;
79  int i;
80  for(i=0, val=0; i<4 && sid[i]!=0; i++) {
81  if(sid[i]>32)
82  val |= ((dword)(sid[i]))<<(8*i);
83  }
84  return val;
85  }
86 }
unsigned long dword
Definition: simpletypes.h:6
virtual float Sensor::getValue ( int  x,
int  y 
) const
inlinevirtual

get value at discrete position

Reimplemented in PPSensor.

Definition at line 41 of file Sensor.h.

References calcValue().

Referenced by calcGradient(), calcMinMax(), getValue(), and getWeightedValue().

41  {
42  return calcValue( x, y);
43  }
virtual float calcValue(int x, int y) const =0
float Sensor::getValue ( const Point p) const
inline

get value at position p using nearest neighbour interpolation

Definition at line 45 of file Sensor.h.

References getValue(), Point2D::x, and Point2D::y.

45  {
46  return getValue((int)p.x, (int)p.y);
47  }
float y
Definition: Point.h:224
virtual float getValue(int x, int y) const
get value at discrete position
Definition: Sensor.h:41
float x
Definition: Point.h:224
Point2D Sensor::getWeightedGradient ( int  x,
int  y 
) const
inline

get range weighted gradient at discrete position

Definition at line 90 of file Sensor.h.

References getGradient(), getMinMaxRange(), and setCWeights().

90  {
91  float range = getMinMaxRange();
92  if(range==0) range = 1;
93  return getGradient(x,y)/range;
94  }
virtual Point2D getGradient(int x, int y) const
get gradient at discrete position
Definition: Sensor.h:53
float getMinMaxRange() const
Definition: Sensor.h:71
float Sensor::getWeightedValue ( int  x,
int  y 
) const
inline

get max normalized value at discrete position range [0,1]

Definition at line 76 of file Sensor.h.

References getMinMaxRange(), getValue(), minval, SENSOR_GAUSS_NORMALIZATION_RANGE, and stdev.

Referenced by createSensorImage().

76  {
77 #define _USE_MINMAX_NORMALIZATION_
78 #ifdef _USE_MINMAX_NORMALIZATION_
79  float range = getMinMaxRange();
80  if(range==0) return 0.f;
81  return (getValue(x,y)-minval)/range;
82 #else
84  if(range==0) range = 1;
85  float value = (getValue(x,y)-minval)/range;
86  return value > 1.f ? 1.f : value; //(value < 0.f ? 0.f : value);
87 #endif
88  }
float minval
overall minimum and maximum
Definition: Sensor.h:176
float getMinMaxRange() const
Definition: Sensor.h:71
#define SENSOR_GAUSS_NORMALIZATION_RANGE
Definition: Sensor.h:13
virtual float getValue(int x, int y) const
get value at discrete position
Definition: Sensor.h:41
float stdev
overall mean and stdev
Definition: Sensor.h:177
ostream & Sensor::hprint ( std::ostream &  os,
SensorCollection sc 
) const
virtual

Reimplemented in CombiSensor.

Definition at line 222 of file Sensor.cpp.

References getZeroSensor(), SensorCollection::isPrinted(), m_ID, print(), SensorCollection::setPrinted(), and source.

Referenced by CombiSensor::getSkip(), and setID().

223 {
224  if(sc->isPrinted(m_ID)) return os;
225  if(source && source != getZeroSensor()) source->hprint(os, sc);
226  if(sc->isPrinted(m_ID)) return os;
227  sc->setPrinted(m_ID);
228  return (print(os) << endl);
229 }
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
void setPrinted(const std::string &id)
Definition: SensorColl.cpp:80
bool isPrinted(const std::string &id) const
Definition: SensorColl.cpp:75
std::string m_ID
Definition: Sensor.h:181
sensor_cptr source
Definition: Sensor.h:170
virtual std::ostream & print(std::ostream &os) const
Definition: Sensor.cpp:213
void Sensor::invalidateSource ( )

Definition at line 190 of file Sensor.cpp.

References getZeroSensor(), source, and unrefSuperSensor().

Referenced by calcGradient().

190  {
191  if(source && source != getZeroSensor()) {
192  std::const_pointer_cast<Sensor>(source)->unrefSuperSensor( shared_from_this() );
193  source = getZeroSensor();
194  }
195 }
Definition: Sensor.h:21
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
void unrefSuperSensor(sensor_ptr super)
Definition: Sensor.cpp:186
sensor_cptr source
Definition: Sensor.h:170
bool Sensor::isModified ( dword  mask = UPD_ALL) const
inline

Check whether something is marked as modified. enum Sensor::UpdateParam is used. Also, mask is filtered through internal updateMask. So only the properties that matter to the current sensor will take effect.

Definition at line 108 of file Sensor.h.

References toupdate.

Referenced by PPSensor::calcAllGradients(), PPSensor::getGradient(), getMax(), getMin(), getMinMaxRange(), PPSensor::getValue(), performUpdate(), GradMagSensor::performUpdate(), CornerSensor::performUpdate(), PPSensor::performUpdate(), and MappingSensor::performUpdate().

109  { return (toupdate & (mask & updateMask)) != 0; }
dword toupdate
bitflag for updates
Definition: Sensor.h:179
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
bool Sensor::isUpdate ( dword  udMask) const
inline

Definition at line 112 of file Sensor.h.

Referenced by CombiSensor::setSource().

112 { return updateMask & udMask; }
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
bool Sensor::isValid ( int  x,
int  y 
) const

Definition at line 197 of file Sensor.cpp.

References getDim1Size(), getDim2Size(), and m_Skip.

Referenced by GradMagSensor::calcValue(), CornerSensor::calcValue(), and getSkip().

198 {
199  return x>=m_Skip && x<getDim1Size()-m_Skip
200  && y>=m_Skip && y<getDim2Size()-m_Skip;
201 }
virtual int getDim1Size() const
Definition: Sensor.h:120
int m_Skip
Definition: Sensor.h:182
virtual int getDim2Size() const
Definition: Sensor.h:121
bool Sensor::performUpdate ( )
virtual

Perform an update if isModified()

Reimplemented in MappingSensor, PPSensor, CornerSensor, GradMagSensor, and SmoothIntensitySensor.

Definition at line 123 of file Sensor.cpp.

References calcMinMax(), isModified(), m_AddSkip, m_Skip, source, unsetModified(), UPD_DATA, UPD_MINMAX, and updateMask.

Referenced by PPSensor::calcAllGradients(), Dataset::clear(), Dataset::copyData(), disableUpdate(), PPSensor::getGradient(), MappingSensor::getMappingID(), PPSensor::getValue(), GradMagSensor::GradMagSensor(), Dataset::load(), and PPSensor::performUpdate().

123  {
124  bool modified = false;
125  if(isModified()) {
126  if(isModified(UPD_DATA)) {
127  m_Skip = source->getSkip()+m_AddSkip;
128  //if(cweights.size() != source->getNChannels()) {
129  // cweights.resize(source->getNChannels(),1.f);
130  //modified = true;
131  //}
132  }
133  unsetModified();
134  if(updateMask&UPD_MINMAX) {
135  calcMinMax();
136  }
137  // do nothing for this sensor, but for the others...
138  for(set<sensor_ptr>::iterator ss = superSensors.begin();
139  ss != superSensors.end(); ss++)
140  {
141  (*ss)->setModified(Sensor::UPD_DATA);
142  }
143  for(set<sensor_ptr>::iterator ss = superSensors.begin();
144  ss != superSensors.end(); ss++)
145  {
146  (*ss)->performUpdate();
147  }
148  }
149  return modified; // no modification to *this
150 }
bool isModified(dword mask=UPD_ALL) const
Definition: Sensor.h:108
int m_AddSkip
Definition: Sensor.h:183
virtual void calcMinMax()
Definition: Sensor.cpp:152
dword updateMask
bitflag to mask unimportant updates
Definition: Sensor.h:180
sensor_cptr source
Definition: Sensor.h:170
int m_Skip
Definition: Sensor.h:182
void unsetModified(dword mask=UPD_ALL)
Definition: Sensor.h:111
ostream & Sensor::print ( std::ostream &  os) const
virtual

Reimplemented in MappingSensor, MahalSensor, CombiSensor, ZeroSensor, CornerSensor, GradMagSensor, SmoothIntensitySensor, CRSensor, MCGSensor, Dataset, MCIntensitySensor, and IntensitySensor.

Definition at line 213 of file Sensor.cpp.

References getZeroSensor(), m_ID, and source.

Referenced by hprint(), IntensitySensor::print(), MCIntensitySensor::print(), MCGSensor::print(), CRSensor::print(), SmoothIntensitySensor::print(), GradMagSensor::print(), CornerSensor::print(), ZeroSensor::print(), MahalSensor::print(), MappingSensor::print(), and setID().

214 {
215  os << "s " << m_ID << " ";
216  if(source && source->getID() != "d0" && source != getZeroSensor()) {
217  os << "source " << source->getID() << " ";
218  }
219  return os;
220 }
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
std::string m_ID
Definition: Sensor.h:181
sensor_cptr source
Definition: Sensor.h:170
void Sensor::refSuperSensor ( sensor_ptr  super)

Definition at line 182 of file Sensor.cpp.

References getZeroSensor().

Referenced by calcGradient(), and changeSource().

182  {
183  if(super != getZeroSensor())
184  superSensors.insert(super);
185 }
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
void Sensor::replaceBy ( sensor_ptr  target)

Definition at line 44 of file Sensor.cpp.

Referenced by getSource(), and SensorCollection::merge().

44  {
45  for(set<sensor_ptr>::iterator ss = superSensors.begin();
46  ss != superSensors.end();)
47  {
48  set<sensor_ptr>::iterator last = ss;
49  ss++;
50  (*last)->changeSource(target);
51  }
52 }
void Sensor::setCWeights ( const std::vector< float > &  weights)

Definition at line 109 of file Sensor.cpp.

References cweights, setModified(), and UPD_CWEIGHTS.

Referenced by assign(), and getWeightedGradient().

109  {
110  //if((int)weights.size() == source->getNChannels()) {
111  cweights = weights;
113  //}
114 }
std::vector< float > cweights
multi-channel weights (&#39;color&#39;)
Definition: Sensor.h:174
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
void Sensor::setDirection ( const Point dir)

Definition at line 115 of file Sensor.cpp.

References dir, setModified(), and UPD_DIR.

Referenced by assign(), and getCWeights().

115  {
116  this->dir = dir;
118 }
Point dir
direction parameter
Definition: Sensor.h:175
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
void Sensor::setID ( const std::string &  id)
inline

Definition at line 129 of file Sensor.h.

References calcValue(), getNumberString(), getStringNumber(), hprint(), m_ID, and print().

Referenced by Dataset::Dataset(), and ZeroSensor::ZeroSensor().

129 { m_ID = id; }
std::string m_ID
Definition: Sensor.h:181
void Sensor::setModified ( dword  mask = UPD_ALL)
inline
void Sensor::setScale ( float  _scale)

Definition at line 119 of file Sensor.cpp.

References scale, setModified(), and UPD_SCALE.

Referenced by assign(), and getDirection().

119  {
120  scale = _scale;
122 }
float scale
Definition: Sensor.h:173
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
template<typename Derived >
std::shared_ptr<Derived> Sensor::shared_from_base ( )
inline

Definition at line 162 of file Sensor.h.

163  {
164  return std::static_pointer_cast<Derived>(shared_from_this());
165  }
void Sensor::unrefSuperSensor ( sensor_ptr  super)

Definition at line 186 of file Sensor.cpp.

References getZeroSensor().

Referenced by calcGradient(), changeSource(), invalidateSource(), and ~Sensor().

186  {
187  if(super != getZeroSensor())
188  superSensors.erase(super);
189 }
sensor_ptr getZeroSensor()
Definition: Sensor.cpp:234
void Sensor::unsetModified ( dword  mask = UPD_ALL)
inline

Definition at line 111 of file Sensor.h.

References toupdate.

Referenced by PPSensor::calcAllGradients(), performUpdate(), and ZeroSensor::ZeroSensor().

111 { toupdate &= ~mask; }
dword toupdate
bitflag for updates
Definition: Sensor.h:179

Member Data Documentation

std::vector<float> Sensor::cweights
protected
Point Sensor::dir
protected

direction parameter

Definition at line 175 of file Sensor.h.

Referenced by assign(), getCWeights(), getDirection(), and setDirection().

int Sensor::m_AddSkip
protected
std::string Sensor::m_ID
protected

Definition at line 181 of file Sensor.h.

Referenced by assign(), getID(), hprint(), CombiSensor::hprint(), print(), and setID().

int Sensor::m_Skip
protected
float Sensor::maxval
protected

Definition at line 176 of file Sensor.h.

Referenced by Dataset::calcMinMax(), calcMinMax(), getMax(), and getMinMaxRange().

float Sensor::mean
protected
float Sensor::minval
protected

overall minimum and maximum

Definition at line 176 of file Sensor.h.

Referenced by Dataset::calcMinMax(), calcMinMax(), getMin(), getMinMaxRange(), and getWeightedValue().

float Sensor::scale
protected

Scale of filter (log2 scale –> 0 means 'full' resolution)

Definition at line 173 of file Sensor.h.

Referenced by assign(), getScale(), and setScale().

sensor_cptr Sensor::source
protected
float Sensor::stdev
protected

overall mean and stdev

Definition at line 177 of file Sensor.h.

Referenced by calcMinMax(), and getWeightedValue().

dword Sensor::toupdate
protected

bitflag for updates

Definition at line 179 of file Sensor.h.

Referenced by PPSensor::calcAllGradients(), isModified(), setModified(), and unsetModified().

dword Sensor::updateMask
protected

bitflag to mask unimportant updates

Definition at line 180 of file Sensor.h.

Referenced by performUpdate(), and ZeroSensor::ZeroSensor().


The documentation for this class was generated from the following files: