SingleChannel Class Reference

SingleChannel represents a single stream of processing. More...

#include <Channels/SingleChannel.H>

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

List of all members.

Classes

struct  TPyr
 a time-stamped pyramid More...

Public Member Functions

 SingleChannel (OptionManager &mgr, const std::string &descrName, const std::string &tagName, const VisualFeature vs, rutz::shared_ptr< PyrBuilder< float > > pyr)
 Constructor. See ChannelBase.H.
virtual ~SingleChannel ()
 destructor
virtual void reset1 ()
 Reset SingleChannel.
virtual void accept (ChannelVisitor &v)
 Calls visitSingleChannel() on the ChannelVisitor.
virtual void paramChanged (ModelParamBase *const param, const bool valueChanged, ParamClient::ChangeStatus *status)
 Overload so that we can reconfigure when our params get changed.
void inputPyramid (const ImageSet< float > &pyramid, const SimTime &t, const Image< byte > &clipMask=Image< byte >())
 Send an already computed pyramid as input to the channel.
virtual ImageSet< float > computePyramid (const Image< float > &bwimg, const rutz::shared_ptr< PyramidCache< float > > &cache)
 Computes the channel's pyramid but doesn't store it.
virtual void readFrom (const ParamMap &pmap)
 Read params from the ParamMap.
virtual void writeTo (ParamMap &pmap) const
 Write params to the ParamMap.
void setTempl (const uint cntr, const uint surr, Image< float > &templ)
 Set the template that will be applied to the submap.
void setBiasMask (Image< float > &biasMask)
 Set the mask that will be applied to the submap.
Image< float > getBiasMask () const
 Set the mask that will be applied to the submap.
Image< float > getTempl (const uint cntr, const uint surr) const
 Get the template that is beeing applied to the submap.
virtual bool outputAvailable () const
 Query whether the channel is ready to give yield valid output.
bool hasPyramid () const
 do we have any input pyramids in our queue?
bool hasOutputCache () const
 have we already computed and cached the current output?
virtual Dims getMapDims () const
 Return the dimensions of the output image.
virtual const Image< float > & getImage (const uint lev) const
 Get the image from the given level of the internal pyramid.
virtual Image< float > centerSurround (const uint cntr, const uint surr) const
 Get the center/surround image for the given levels.
virtual void centerSurround (const uint cntr, const uint surr, Image< float > &pos, Image< float > &neg) const
 Get the center/surround, split into positive and negative parts.
virtual uint numSubmaps () const
 Return the number of feature maps represented by this channel.
virtual Image< float > getSubmap (const uint index) const
 This is just a caching wrapper around computeSubmap().
virtual std::string getSubmapName (const uint index) const
 Get the name/description of the feature map at the given index.
virtual std::string getSubmapNameShort (const uint index) const
 Get the name/description of the feature map at the given index, short version.
virtual void getFeatures (const Point2D< int > &locn, std::vector< float > &mean) const
virtual void getFeaturesBatch (std::vector< Point2D< int > * > *locn, std::vector< std::vector< float > > *mean, int *count) const
void saveStats (const Image< float > img, const short idx)
 save basic stats for single channel
virtual Image< float > getOutput ()
 This is just a caching wrapper around combineSubMaps().
virtual Image< float > combineSubMaps ()
 Combine all feature maps into a single output map.
virtual void saveResults (const nub::ref< FrameOstream > &ofs)
 Save our various maps using an FrameOstream.
size_t numPyramids () const
 Get the number of pyramids in our queue.
const ImageSet< float > & pyramid (const uint index) const
 Access to the underlying pyramid is provided for completeness.
SimTime pyramidTime (const uint index) const
 Access to the underlying pyramid times is provided for completeness.
const ImageSet< float > & clipPyramid () const
 Access to the underlying clipPyramid.
virtual LevelSpec getLevelSpec () const
 get our the LevelSpec
int getNormType () const
 get our NormType:
virtual void killCaches ()
 SingleChannel implements this to clear its cached output.
void storeOutputCache (const Image< float > &m)
 Store m as the output map.
virtual void storePyramid (const ImageSet< float > &p, const SimTime &t)
 Stores p as the channel's pyramid at time t.
void storeClipPyramid (const ImageSet< float > &p)
 Store p as the channel's clip pyramid.
virtual void setClipPyramid (const Image< byte > &clipMask)
 make the clipping pyramid from the clip mask
void storeSubmapCache (const ImageSet< float > &p)
 Store p as the channel's submap cache.
void setInputHandler (rutz::shared_ptr< InputHandler > h)
 Install an input handler.
rutz::shared_ptr< InputHandlercloneInputHandler () const
 Get a cloned copy of our input handler.
virtual Image< float > getRawCSmap (const uint idx) const
 get raw CS map; part of getSubmap()
Image< float > postProcessMap (const Image< float > &smap, const uint idx) const
 rescale and post-process raw CS map; part of default getSubMap()
void setSubmapAlgorithm (nub::ref< SubmapAlgorithm > algo)
 Install a new submap algorithm.
void setComputeFullPyramid (bool v)
virtual int getMinPyrLevel () const
virtual int getMaxPyrLevel () const

Protected Member Functions

virtual void doInput (const InputFrame &inframe)
 SingleChannel requires only luminance input.
void setPyramid (rutz::shared_ptr< PyrBuilder< float > > pyr)
 Change to use a different pyramid object.
ImageSet< float > & pyrMut (const uint index)
 Mutable access to underlying pyramid.
virtual void start1 ()
virtual void stop2 ()
virtual uint csToIndex (uint centerlev, uint surroundlev) const
virtual void indexToCS (const uint index, uint &centerlev, uint &surroundlev) const
virtual uint maxIndex () const

Protected Attributes

NModelParam< bool > itsTakeAbs
NModelParam< bool > itsNormalizeOutput
NModelParam< bool > itsScaleNoiseToMax
NModelParam< float > itsLowThresh
NModelParam< bool > itsRectifyPyramid
NModelParam< bool > itsComputeFullPyramid
OModelParam< bool > itsUseRandom
OModelParam< bool > itsUseSplitCS
OModelParam< LevelSpecitsLevelSpec
OModelParam< MaxNormTypeitsNormType
OModelParam< int > itsQlen
OModelParam< bool > itsUseOlderVersion
OModelParam< double > itsTimeDecay
 Time decay for the contribution of differences in the pyramid queue.
OModelParam< bool > itsSaveRawMaps
 Save our raw pyramid levels?
OModelParam< bool > itsComputeFullPyramidForGist
 save our raw pyramid levels for the gist computation?
OModelParam< bool > itsSaveFeatureMaps
 Save our center-surround feature maps?
OModelParam< bool > itsSaveOutputMap
 Save our output map?
OModelParam< std::stringitsSubmapAlgoType
 Type name for our SubmapAlgorithm.
OModelParam< bool > itsGetSingleChannelStats
 Save basic single channel stats after combineSubMaps.
OModelParam< bool > itsSaveStatsPerChannel
 If saving stats, should we put each feature in its own file?
OModelParam< bool > itsSaveStatsPerChannelFreq
 Should we save frequency information per channel?
OModelParam< std::stringitsGetSingleChannelStatsFile
 File name for single channel stats after combineSubMaps.
OModelParam< std::stringitsGetSingleChannelStatsTag
 Tag name for single channel stats after combineSubMaps.
OModelParam< float > itsOutputRangeMin
 Set a fixed range of values for the raw output.
OModelParam< float > itsOutputRangeMax

Friends

class OrientationChannel
class RGBConvolveChannel

Detailed Description

SingleChannel represents a single stream of processing.

The processing is implemented by an internal PyrBuilder object of some kind.

Definition at line 58 of file SingleChannel.H.


Constructor & Destructor Documentation

SingleChannel::SingleChannel ( OptionManager mgr,
const std::string descrName,
const std::string tagName,
const VisualFeature  vs,
rutz::shared_ptr< PyrBuilder< float > >  pyr 
)

Constructor. See ChannelBase.H.

Parameters:
mgr our ModelManager (see ModelManager.H)
descrName descriptive name for human usage
tagName name for ParamMap usage
vs The VisualFeature implemented by the channel
pyr The type of pyramid that should be used.

Definition at line 71 of file SingleChannel.C.

References ModelComponent::addSubComponent(), OModelParam< T >::getVal(), rutz::factory< nub::ref< P > >::is_valid_key(), and itsSubmapAlgoType.

SingleChannel::~SingleChannel (  )  [virtual]

destructor

Definition at line 122 of file SingleChannel.C.


Member Function Documentation

void SingleChannel::accept ( ChannelVisitor v  )  [virtual]

Calls visitSingleChannel() on the ChannelVisitor.

Reimplemented from ChannelBase.

Definition at line 176 of file SingleChannel.C.

References ChannelVisitor::visitSingleChannel().

void SingleChannel::centerSurround ( const uint  cntr,
const uint  surr,
Image< float > &  pos,
Image< float > &  neg 
) const [virtual]

Get the center/surround, split into positive and negative parts.

Reimplemented in SingleOpponentChannel.

Definition at line 328 of file SingleChannel.C.

References ASSERT, centerSurround(), centerSurroundDiff(), LevelSpec::csOK(), exp(), OModelParam< T >::getVal(), and itsTimeDecay.

Image< float > SingleChannel::centerSurround ( const uint  cntr,
const uint  surr 
) const [virtual]

Get the center/surround image for the given levels.

Reimplemented in DummyChannel, and SingleOpponentChannel.

Definition at line 296 of file SingleChannel.C.

References ASSERT, centerSurroundDiff(), LevelSpec::csOK(), exp(), OModelParam< T >::getVal(), NModelParam< T >::getVal(), and itsTimeDecay.

Referenced by centerSurround(), and getRawCSmap().

const ImageSet< float > & SingleChannel::clipPyramid (  )  const

Access to the underlying clipPyramid.

Definition at line 785 of file SingleChannel.C.

Referenced by SingleOpponentChannel::centerSurround().

rutz::shared_ptr< InputHandler > SingleChannel::cloneInputHandler (  )  const

Get a cloned copy of our input handler.

Definition at line 1084 of file SingleChannel.C.

References InputHandler::clone().

Image< float > SingleChannel::combineSubMaps (  )  [virtual]
ImageSet< float > SingleChannel::computePyramid ( const Image< float > &  bwimg,
const rutz::shared_ptr< PyramidCache< float > > &  cache 
) [virtual]

Computes the channel's pyramid but doesn't store it.

Reimplemented in DirectionChannel, and DirectionSpatioTemporalChannel.

Definition at line 678 of file SingleChannel.C.

References doLowThresh(), doLowThreshAbs(), doRectify(), and NModelParam< T >::getVal().

Referenced by doInput().

void SingleChannel::doInput ( const InputFrame inframe  )  [protected, virtual]
Image< float > SingleChannel::getBiasMask (  )  const

Set the mask that will be applied to the submap.

Definition at line 237 of file SingleChannel.C.

const Image< float > & SingleChannel::getImage ( const uint  lev  )  const [virtual]

Get the image from the given level of the internal pyramid.

Definition at line 288 of file SingleChannel.C.

Referenced by HueChannel::combineSubMaps(), MichelsonChannel::doInput(), and TemplateMatchChannel::findBestMatch().

LevelSpec SingleChannel::getLevelSpec (  )  const [virtual]
Dims SingleChannel::getMapDims (  )  const [virtual]
int SingleChannel::getNormType (  )  const

get our NormType:

Definition at line 799 of file SingleChannel.C.

References OModelParam< T >::getVal().

Image< float > SingleChannel::getOutput (  )  [virtual]
Image< float > SingleChannel::getRawCSmap ( const uint  idx  )  const [virtual]
Image< float > SingleChannel::getSubmap ( const uint  index  )  const [virtual]

This is just a caching wrapper around computeSubmap().

Implements ChannelBase.

Reimplemented in ForegroundDetectionChannel, and HueChannel.

Definition at line 367 of file SingleChannel.C.

Referenced by DescriptorVec::buildParticleCountDV(), DescriptorVec::buildSingleChannelFV(), combineSubMaps(), saveResults(), and OptimalGainsFinder::visitSingleChannel().

std::string SingleChannel::getSubmapName ( const uint  index  )  const [virtual]

Get the name/description of the feature map at the given index.

This function is intended to be implemented by subclasses so that it recurses into any nested channels, mapping nested submaps into a linear sequence of indices. The output of this function is intended only to be human-readable (e.g. for labeling image displays), and does not have to follow any particular parseable syntax.

Implements ChannelBase.

Reimplemented in ForegroundDetectionChannel, and HueChannel.

Definition at line 505 of file SingleChannel.C.

References ASSERT, ModelComponent::descriptiveName(), OModelParam< T >::getVal(), LevelSpec::indexOK(), and sformat().

std::string SingleChannel::getSubmapNameShort ( const uint  index  )  const [virtual]

Get the name/description of the feature map at the given index, short version.

Implements ChannelBase.

Definition at line 518 of file SingleChannel.C.

References ASSERT, OModelParam< T >::getVal(), LevelSpec::indexOK(), sformat(), and ModelComponent::tagName().

Image< float > SingleChannel::getTempl ( const uint  cntr,
const uint  surr 
) const

Get the template that is beeing applied to the submap.

Definition at line 244 of file SingleChannel.C.

bool SingleChannel::hasOutputCache (  )  const

have we already computed and cached the current output?

Definition at line 271 of file SingleChannel.C.

References Image< T >::initialized().

Referenced by SingleChannelBeo::waitForOutput().

bool SingleChannel::hasPyramid (  )  const

do we have any input pyramids in our queue?

Definition at line 264 of file SingleChannel.C.

Referenced by SingleOpponentChannel::centerSurround().

void SingleChannel::inputPyramid ( const ImageSet< float > &  pyramid,
const SimTime t,
const Image< byte > &  clipMask = Image<byte>() 
)

Send an already computed pyramid as input to the channel.

Definition at line 665 of file SingleChannel.C.

References killCaches(), setClipPyramid(), and storePyramid().

void SingleChannel::killCaches (  )  [virtual]
size_t SingleChannel::numPyramids (  )  const

Get the number of pyramids in our queue.

Definition at line 760 of file SingleChannel.C.

Referenced by JetFiller::visitSingleChannel().

uint SingleChannel::numSubmaps (  )  const [virtual]
bool SingleChannel::outputAvailable (  )  const [virtual]

Query whether the channel is ready to give yield valid output.

In some cases (e.g. with motion channels), it may take several input frames before the channel is fully initialized.

Implements ChannelBase.

Reimplemented in DirectionOpticalFlowChannel, DummyChannel, EntropyChannel, ForegroundDetectionChannel, InformationChannel, MichelsonChannel, PN03contrastChannel, ScorrChannel, SIFTChannel, SobelChannel, TcorrChannel, and VarianceChannel.

Definition at line 252 of file SingleChannel.C.

References Image< T >::initialized(), and rutz::shared_ptr< T >::is_valid().

Referenced by getOutput().

void SingleChannel::paramChanged ( ModelParamBase *const   param,
const bool  valueChanged,
ParamClient::ChangeStatus status 
) [virtual]

Overload so that we can reconfigure when our params get changed.

Reimplemented from ModelComponent.

Definition at line 183 of file SingleChannel.C.

References OModelParam< T >::getVal(), itsSubmapAlgoType, MC_RECURSE, and setSubmapAlgorithm().

Image< float > SingleChannel::postProcessMap ( const Image< float > &  smap,
const uint  idx 
) const
const ImageSet< float > & SingleChannel::pyramid ( const uint  index  )  const

Access to the underlying pyramid is provided for completeness.

However, it probably shouldn't need to be used except for testing, debugging, etc. Instead, the Channel interface should be used or extended to fill the specific need.

Parameters:
index The index in the queue (0 = newest, qlen-1 = oldest).

Definition at line 767 of file SingleChannel.C.

References ASSERT.

Referenced by SingleOpponentChannel::centerSurround(), JunctionChannel::doInput(), MSTChannel::doInput(), and JetFiller::visitSingleChannel().

SimTime SingleChannel::pyramidTime ( const uint  index  )  const

Access to the underlying pyramid times is provided for completeness.

However, it probably shouldn't need to be used except for testing, debugging, etc. Instead, the Channel interface should be used or extended to fill the specific need.

Parameters:
index The index in the queue (0 = newest, qlen-1 = oldest).

Definition at line 776 of file SingleChannel.C.

References ASSERT, and SimTime::ZERO().

Referenced by SingleOpponentChannel::centerSurround().

ImageSet< float > & SingleChannel::pyrMut ( const uint  index  )  [protected]

Mutable access to underlying pyramid.

Definition at line 1000 of file SingleChannel.C.

References ASSERT.

void SingleChannel::readFrom ( const ParamMap pmap  )  [virtual]

Read params from the ParamMap.

Reimplemented from ChannelBase.

Reimplemented in GaborChannel.

Definition at line 202 of file SingleChannel.C.

References ChannelFacetMap::readFacetsFrom().

void SingleChannel::reset1 (  )  [virtual]

Reset SingleChannel.

See the base function in ModelComponent.H for info.

Reimplemented from ChannelBase.

Reimplemented in FlickerChannel, FlickerNBackChannel, and SingleOpponentChannel.

Definition at line 163 of file SingleChannel.C.

References ImageSet< T >::clear(), and rutz::shared_ptr< T >::reset().

void SingleChannel::saveResults ( const nub::ref< FrameOstream > &  ofs  )  [virtual]

Save our various maps using an FrameOstream.

Depending on our ModelParam settings, we can save raw pyramid levels (with name prefix "SR<tagname>-<level>-"), center-surround feature maps ("SF<tagname>-<ctr>-<surr>-"), and output map ("SO<tagname>-")

Reimplemented from ChannelBase.

Definition at line 1031 of file SingleChannel.C.

References ModelComponent::descriptiveName(), FLOAT_NORM_0_255, getOutput(), getSubmap(), OModelParam< T >::getVal(), itsSaveFeatureMaps, itsSaveOutputMap, itsSaveRawMaps, numSubmaps(), sformat(), ImageSet< T >::size(), SRC_POS, and ModelComponent::tagName().

void SingleChannel::saveStats ( const Image< float >  img,
const short  idx 
)
void SingleChannel::setBiasMask ( Image< float > &  biasMask  ) 

Set the mask that will be applied to the submap.

Definition at line 229 of file SingleChannel.C.

References killCaches().

Referenced by MaskBiaser::visitSingleChannel().

void SingleChannel::setClipPyramid ( const Image< byte > &  clipMask  )  [virtual]
void SingleChannel::setInputHandler ( rutz::shared_ptr< InputHandler h  ) 

Install an input handler.

Definition at line 1077 of file SingleChannel.C.

References InputHandler::clone().

void SingleChannel::setPyramid ( rutz::shared_ptr< PyrBuilder< float > >  pyr  )  [protected]

Change to use a different pyramid object.

Definition at line 991 of file SingleChannel.C.

References ASSERT.

Referenced by ConvolveChannel::setFilter(), RGBConvolveChannel::setFilters(), and GaussianPyrChannel::start1().

void SingleChannel::setSubmapAlgorithm ( nub::ref< SubmapAlgorithm algo  ) 
void SingleChannel::setTempl ( const uint  cntr,
const uint  surr,
Image< float > &  templ 
)

Set the template that will be applied to the submap.

Definition at line 220 of file SingleChannel.C.

References killCaches().

void SingleChannel::start1 (  )  [protected, virtual]

If you overload this, make sure you call SingleChannel::start1() at the beginning of your overload

Reimplemented from ModelComponent.

Reimplemented in DirectionOpticalFlowChannel, DirectionSpatioTemporalChannel, DisparityChannel, GaborChannel, GaussianPyrChannel, PedestrianChannel, and TemplateMatchChannel.

Definition at line 128 of file SingleChannel.C.

References OModelParam< T >::getVal(), itsOutputRangeMin, OModelParam< T >::setVal(), and VCXNORM_MAXNORM.

void SingleChannel::stop2 (  )  [protected, virtual]

If you overload this, make sure you call SingleChannel::start1() at the beginning of your overload

Reimplemented from ModelComponent.

Definition at line 156 of file SingleChannel.C.

void SingleChannel::storeClipPyramid ( const ImageSet< float > &  p  ) 

Store p as the channel's clip pyramid.

Definition at line 726 of file SingleChannel.C.

Referenced by SingleChannelBeo::waitForOutput().

void SingleChannel::storeOutputCache ( const Image< float > &  m  ) 

Store m as the output map.

Definition at line 704 of file SingleChannel.C.

Referenced by SingleChannelBeo::waitForOutput().

void SingleChannel::storePyramid ( const ImageSet< float > &  p,
const SimTime t 
) [virtual]
void SingleChannel::storeSubmapCache ( const ImageSet< float > &  p  ) 

Store p as the channel's submap cache.

Definition at line 750 of file SingleChannel.C.

References ASSERT, numSubmaps(), and ImageSet< T >::size().

Referenced by SingleChannelBeo::waitForOutput().

void SingleChannel::writeTo ( ParamMap pmap  )  const [virtual]

Write params to the ParamMap.

Reimplemented from ChannelBase.

Reimplemented in GaborChannel.

Definition at line 211 of file SingleChannel.C.

References ChannelFacetMap::writeFacetsTo().

Referenced by SingleChannelBeo::handleInput().


Member Data Documentation

save our raw pyramid levels for the gist computation?

Definition at line 280 of file SingleChannel.H.

Save basic single channel stats after combineSubMaps.

Definition at line 292 of file SingleChannel.H.

Referenced by combineSubMaps().

File name for single channel stats after combineSubMaps.

Definition at line 301 of file SingleChannel.H.

Referenced by saveStats().

Tag name for single channel stats after combineSubMaps.

Definition at line 304 of file SingleChannel.H.

Referenced by saveStats().

Set a fixed range of values for the raw output.

By default, the range is set to [MAXNORMMIN .. MAXNORMMAX] at construction. If non-zero values are provided here, in getOutput() we will cumulate our various submaps, apply the provided range, apply spatial competition for salience, apply our total weight, and return the result. If a range [0.0 .. 0.0] is provided here, only spatial competition and weights will be applied, but the first step of applying the range will be skipped. This must be called before start().

Definition at line 315 of file SingleChannel.H.

Referenced by HueChannel::combineSubMaps(), combineSubMaps(), and start1().

Save our center-surround feature maps?

Definition at line 283 of file SingleChannel.H.

Referenced by saveResults().

Save our output map?

Definition at line 286 of file SingleChannel.H.

Referenced by saveResults().

Save our raw pyramid levels?

Definition at line 277 of file SingleChannel.H.

Referenced by RGBConvolveChannel::computePyramid(), and saveResults().

If saving stats, should we put each feature in its own file?

Definition at line 295 of file SingleChannel.H.

Referenced by saveStats().

Should we save frequency information per channel?

Definition at line 298 of file SingleChannel.H.

Referenced by saveStats().

Type name for our SubmapAlgorithm.

Definition at line 289 of file SingleChannel.H.

Referenced by paramChanged(), and SingleChannel().

Time decay for the contribution of differences in the pyramid queue.

This decay will yield a factor fac = exp( (t2 - t) * decay) applied to the difference image between t (current time, in seconds) and t2 (time of previous image, in seconds):

Definition at line 274 of file SingleChannel.H.

Referenced by SingleOpponentChannel::centerSurround(), and centerSurround().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:49 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3