Structural deformable models
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SmoothIntensitySensor Class Reference

#include <SensorSet.h>

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

Public Member Functions

 SmoothIntensitySensor (float _scale=0)
 
bool performUpdate ()
 
std::ostream & print (std::ostream &os) const
 
- Public Member Functions inherited from PPSensor
 PPSensor ()
 
virtual float getValue (int x, int y) const
 
virtual Point getGradient (int x, int y) const
 
Sensorassign (const Sensor &rhs)
 
void togglePP (enum PPState state=PP_DO)
 
dword getPPState () const
 
- Public Member Functions inherited from Sensor
virtual ~Sensor ()
 
sensor_cptr getSource ()
 
virtual void changeSource (sensor_cptr _source)
 
void replaceBy (sensor_ptr target)
 
bool assignRef (sensor_cptr rhs)
 
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...
 
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 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
 
void refSuperSensor (sensor_ptr super)
 
void unrefSuperSensor (sensor_ptr super)
 
void invalidateSource ()
 
template<typename Derived >
std::shared_ptr< Derived > shared_from_base ()
 

Protected Member Functions

void calcAllValues ()
 
float calcValue (int x, int y) const
 
void updateScale ()
 
- Protected Member Functions inherited from PPSensor
void fitSheets ()
 
virtual void calcAllGradients ()
 
- Protected Member Functions inherited from Sensor
 Sensor (dword updateMask)
 
 Sensor ()
 
virtual std::vector< float > calcMValue (int x, int y) const
 
virtual Point calcGradient (int x, int y) const
 
virtual void calcMinMax ()
 

Protected Attributes

Fourier2D m_FT
 
Fourier2D m_FTflt
 
Image< double > m_SData
 
Image< double > m_SFilter
 
Image< std::complex< double > > m_FData
 
Image< std::complex< double > > m_FFilter
 
- Protected Attributes inherited from PPSensor
Image< float > values
 caching sheet for sensed values More...
 
Image< Pointgradients
 caching sheet for gradients More...
 
dword doPP
 do preprocessing? More...
 
- Protected Attributes inherited from Sensor
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
 

Additional Inherited Members

- Public Types inherited from PPSensor
enum  PPState { PP_DONT =0, PP_DO, PP_FORCE }
 
- Public Types inherited from Sensor
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
}
 
- Static Public Member Functions inherited from Sensor
static dword getStringNumber (const char *sid)
 
static void getNumberString (char sid[5], dword id)
 

Detailed Description

Smoothed intensity sensor (using gaussian)

Definition at line 149 of file SensorSet.h.

Constructor & Destructor Documentation

SmoothIntensitySensor::SmoothIntensitySensor ( float  _scale = 0)

Definition at line 20 of file SensorSet.cpp.

21 {
24  setScale(_scale);
25 }
void setScale(float _scale)
Definition: Sensor.cpp:119
void enableUpdate(dword udMask)
Definition: Sensor.h:113
void togglePP(enum PPState state=PP_DO)
Definition: Sensor.h:243

Member Function Documentation

void SmoothIntensitySensor::calcAllValues ( )
protectedvirtual

Reimplemented from PPSensor.

Definition at line 43 of file SensorSet.cpp.

References PPSensor::calcAllValues().

44 {
48  m_FT.transform();
49  m_FData *= m_FFilter;
52  //values = values.convolve(m_SFilter);
53  }
54 }
void transform()
Definition: Fourier.cpp:23
Image< double > m_SData
Definition: SensorSet.h:168
void transformInv()
Definition: Fourier.cpp:28
Image< float > values
caching sheet for sensed values
Definition: Sensor.h:256
virtual void calcAllValues()
Definition: Sensor.cpp:262
bool initialized() const
Definition: Image.h:191
Image< T > & convertFrom(const Image< S > &rhs)
Definition: Image.h:91
Image< std::complex< double > > m_FData
Definition: SensorSet.h:169
Image< std::complex< double > > m_FFilter
Definition: SensorSet.h:169
float SmoothIntensitySensor::calcValue ( int  x,
int  y 
) const
inlineprotectedvirtual

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

Implements Sensor.

Definition at line 162 of file SensorSet.h.

References Sensor::source.

162  {
163  return source->getValue(x,y);
164  }
sensor_cptr source
Definition: Sensor.h:170
bool SmoothIntensitySensor::performUpdate ( )
virtual

clear all data sheets

Reimplemented from PPSensor.

Definition at line 27 of file SensorSet.cpp.

References Fourier2D::complexX(), and PPSensor::performUpdate().

27  {
28  if(!isModified()) return false;
29  if(source->getDim1Size()>0) {
30  if(m_SData.getSizeX() != source->getDim1Size() ||
31  m_SData.getSizeY() != source->getDim2Size()) {
32  m_SData.setSize(source->getDim1Size(), source->getDim2Size());
33  m_FData.setSize(Fourier2D::complexX(source->getDim1Size())/2,
34  source->getDim2Size());
36  m_SData.getData(), (double*)m_FData.getData());
37  }
38  updateScale();
39  }
40  return PPSensor::performUpdate();
41 }
bool isModified(dword mask=UPD_ALL) const
Definition: Sensor.h:108
Image< double > m_SData
Definition: SensorSet.h:168
int getSizeX() const
Definition: Image.h:42
void initTransform(int xsize, int ysize, double *f, double *F)
Definition: Fourier.cpp:53
Image< std::complex< double > > m_FData
Definition: SensorSet.h:169
virtual bool performUpdate()
Definition: Sensor.cpp:306
void setSize(int nx, int ny)
Definition: Image.h:268
const T * getData() const
Definition: Image.h:39
int complexX() const
Definition: Fourier.h:15
sensor_cptr source
Definition: Sensor.h:170
int getSizeY() const
Definition: Image.h:43
std::ostream& SmoothIntensitySensor::print ( std::ostream &  os) const
inlinevirtual

Reimplemented from Sensor.

Definition at line 154 of file SensorSet.h.

References Sensor::getScale(), and Sensor::print().

154  {
155  Sensor::print(os)
156  << "g " << getScale();
157  return os;
158  }
float getScale() const
Definition: Sensor.h:101
virtual std::ostream & print(std::ostream &os) const
Definition: Sensor.cpp:213
void SmoothIntensitySensor::updateScale ( )
protected

Definition at line 56 of file SensorSet.cpp.

References Fourier2D::complexX(), create2DGaussian(), Image< T >::getSize(), and dmutil::stdev().

56  {
57  assert(source->getDim1Size()>0);
58  bool nosizematch = !(m_SFilter.getSizeX() == source->getDim1Size() &&
59  m_SFilter.getSizeY() == source->getDim2Size());
60  if(isModified(UPD_SCALE) || nosizematch) {
62  if(nosizematch) {
63  m_SFilter.setSize(source->getDim1Size(), source->getDim2Size());
68  (double*)m_FFilter.getData());
69  }
70  float ffltsize = pow(2,scale);
71  int fltsize = (int)ffltsize;
72  if(fltsize<1) fltsize=1;
73  m_AddSkip = fltsize/2+1;
74  double stdev = ffltsize*0.5*0.2;
75  create2DGaussian(m_SFilter, stdev, ffltsize,
76  m_SFilter.getSizeX()/2.0f,m_SFilter.getSizeY()/2.0f);
78 //normalize transform and perform shift
79  double factor = 1.0/m_SFilter.getSize();
80  double nfactor = -factor;
81  complex<double>* freq = m_FFilter.getData();
82  for(int j=0; j<m_FFilter.getSizeY(); j++) {
83  for(int i=0; i<m_FFilter.getSizeX(); i++, freq++) {
84  if((i+j)&0x01) *freq *= nfactor;
85  else *freq *= factor;
86  }
87  }
89  }
90 }
void transform()
Definition: Fourier.cpp:23
int getSize() const
Definition: Image.h:44
bool isModified(dword mask=UPD_ALL) const
Definition: Sensor.h:108
static Image< double > & create2DGaussian(Image< double > &flt, double stdev, float clampd, float cx, float cy)
Definition: SensorSet.cpp:418
int m_AddSkip
Definition: Sensor.h:183
int getSizeX() const
Definition: Image.h:42
Image< double > m_SFilter
Definition: SensorSet.h:168
void initTransform(int xsize, int ysize, double *f, double *F)
Definition: Fourier.cpp:53
void setSize(int nx, int ny)
Definition: Image.h:268
const T * getData() const
Definition: Image.h:39
float scale
Definition: Sensor.h:173
int complexX() const
Definition: Fourier.h:15
sensor_cptr source
Definition: Sensor.h:170
Image< std::complex< double > > m_FFilter
Definition: SensorSet.h:169
float stdev
overall mean and stdev
Definition: Sensor.h:177
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
void unsetModified(dword mask=UPD_ALL)
Definition: Sensor.h:111
int getSizeY() const
Definition: Image.h:43

Member Data Documentation

Image< std::complex<double> > SmoothIntensitySensor::m_FData
protected

Definition at line 169 of file SensorSet.h.

Image< std::complex<double> > SmoothIntensitySensor::m_FFilter
protected

Definition at line 169 of file SensorSet.h.

Fourier2D SmoothIntensitySensor::m_FT
protected

Definition at line 167 of file SensorSet.h.

Fourier2D SmoothIntensitySensor::m_FTflt
protected

Definition at line 167 of file SensorSet.h.

Image< double > SmoothIntensitySensor::m_SData
protected

Definition at line 168 of file SensorSet.h.

Image< double > SmoothIntensitySensor::m_SFilter
protected

Definition at line 168 of file SensorSet.h.


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