The Visual Cortex Class. More...
#include <Channels/RawVisualCortex.H>
Public Member Functions | |
virtual void | saveResults (const nub::ref< FrameOstream > &ofs) |
Save our results. | |
const Image< float > | getVCOutput (const Image< PixRGB< byte > > &rgbin) |
Get the output of the vc map from a given image. | |
Constructors/Destructor | |
RawVisualCortex (OptionManager &mgr, const std::string &descrName="Raw Visual Cortex", const std::string &tagName="RawVisualCortex") | |
Construct with no channel; channels must then be added with addSubChan(). | |
virtual | ~RawVisualCortex () |
Virtual destructor for safe inheritance. | |
Protected Member Functions | |
virtual void | doInput (const InputFrame &inframe) |
Implementation of ChannelBase input() functions. | |
virtual Image< float > | combineOutputs () |
Combine the outputs of our subchannels. | |
virtual Image< float > | getChannelOutputMap (const uint idx) const |
get weighted (but not resized) channel output map | |
virtual Image< float > | postProcessOutputMap (const Image< float > &outmap) |
post-process raw weighted sum of channel output maps | |
virtual void | paramChanged (ModelParamBase *const param, const bool valueChanged, ParamClient::ChangeStatus *status) |
Called whenever a ModelParamBase has its value changed. | |
virtual void | start1 () |
start | |
virtual void | stop2 () |
stop | |
Protected Attributes | |
OModelParam< std::string > | itsType |
OModelParam< MaxNormType > | itsNormType |
maxNormalization to use | |
OModelParam< bool > | itsUseRandom |
add random noise to output | |
OModelParam< float > | itsOutputFactor |
output range factor | |
OModelParam< float > | itsNoise |
output noise range | |
OModelParam< bool > | itsUseOlderVersion |
use old version? see Visualcortex.H | |
OModelParam< LevelSpec > | itsLevelSpec |
LevelSpec used by our channels, used to compute output dims. | |
OModelParam< std::string > | itsSaveOutTo |
save our outputs to MGZ file? | |
OModelParam< std::string > | itsLoadOutFrom |
load outputs from MGZ file? | |
OModelParam< bool > | itsSaveOutput |
save our output? | |
OModelParam< bool > | itsUseMax |
use max across features instead of sum? | |
OModelParam< float > | itsWeightThresh |
threshold on channel total weights for last round of maxnorm |
The Visual Cortex Class.
In brief, RawVisualCortex holds a collection of ChannelBase objects, and most of RawVisualCortex's operations are achieved by some kind of iteration over that collection. That is, RawVisualCortex now does little work by itself, but delegates its operations to the channels, accumulating their results if necessary. NOTE: RawVisualCortex has a virtual ModelComponent base which is shared among its inheritance from ModelComponent via the ComplexChannel inheritance path, and its inheritance from ModelComponent via its SimModule inheritance path. Just beware!
Definition at line 69 of file RawVisualCortex.H.
RawVisualCortex::RawVisualCortex | ( | OptionManager & | mgr, | |
const std::string & | descrName = "Raw Visual Cortex" , |
|||
const std::string & | tagName = "RawVisualCortex" | |||
) |
Construct with no channel; channels must then be added with addSubChan().
mgr | our ModelManager (see ModelManager.H) | |
descrName | descriptive name for human usage | |
tagName | name for ParamMap usage |
Definition at line 103 of file RawVisualCortex.C.
RawVisualCortex::~RawVisualCortex | ( | ) | [virtual] |
Virtual destructor for safe inheritance.
Definition at line 127 of file RawVisualCortex.C.
Image< float > RawVisualCortex::combineOutputs | ( | ) | [protected, virtual] |
Combine the outputs of our subchannels.
We do this in a slightly different way than the ComplexChannel base version.
Reimplemented from ComplexChannel.
Definition at line 548 of file RawVisualCortex.C.
References downSizeClean(), FLOAT_NORM_PRESERVE, getChannelOutputMap(), Image< T >::getDims(), ChannelBase::getInputDims(), getMinMax(), OModelParam< T >::getVal(), Dims::h(), Image< T >::initialized(), inplaceAddBGnoise(), itsLevelSpec, itsLoadOutFrom, itsNoise, itsOutputFactor, itsSaveOutTo, itsUseMax, itsUseRandom, LevelSpec::mapLevel(), MYLOGVERB, ComplexChannel::numChans(), postProcessOutputMap(), ComplexChannel::subChan(), takeMax(), Dims::w(), and ZEROS.
void RawVisualCortex::doInput | ( | const InputFrame & | inframe | ) | [protected, virtual] |
Implementation of ChannelBase input() functions.
Implements ChannelBase.
Definition at line 500 of file RawVisualCortex.C.
References buildPyrGaussian(), buildRadialPyrGaussian(), featureHierarchyLevel(), featureHierarchyName(), rutz::shared_ptr< T >::get(), OModelParam< T >::getVal(), NModelParam< T >::getVal(), itsLevelSpec, itsLoadOutFrom, ComplexChannel::itsUseSpaceVariantBoundary, LevelSpec::maxDepth(), ComplexChannel::numChans(), and ComplexChannel::subChan().
get weighted (but not resized) channel output map
Definition at line 419 of file RawVisualCortex.C.
References getMinMax(), ComplexChannel::getSubchanTotalWeight(), OModelParam< T >::getVal(), itsUseOlderVersion, MYLOGVERB, and ComplexChannel::subChan().
Referenced by combineOutputs().
Get the output of the vc map from a given image.
Definition at line 404 of file RawVisualCortex.C.
References InputFrame::fromRgb(), ComplexChannel::getOutput(), ChannelBase::input(), SimTime::MSECS(), and SimTime::ZERO().
void RawVisualCortex::paramChanged | ( | ModelParamBase *const | param, | |
const bool | valueChanged, | |||
ParamClient::ChangeStatus * | status | |||
) | [protected, virtual] |
Called whenever a ModelParamBase has its value changed.
Subclasses of ModelComponent should override this function if they need to do any internal reconfiguration when their parameters change value (whether due to a command-line option, or a setModelParamString(), or a readParamsFrom()). See OrientationChannel::paramChanged() in Channels/OrientationChannel.C for an example; also see SaccadeControllerConfigurator::paramChanged() in Neuro/SaccadeControllers.C for for how to use this to select subcomponents at runtime.
param | the address of the ModelParamBase that changed; subclasses can compare this with the addresses of their model param members to figure out which is the relevant param | |
valueChanged | true if the value actually changed, false if the value was "set" but the new value is the same as the old value; some clients may want to avoid re-doing expensive operations if the value did not actually change | |
status | the subclass that implements paramChanged() should set *status to CHANGE_REJECTED if it wishes to reject a particular parameter change; the caller of paramChanged() is expected to set *status to CHANGE_ACCEPTED prior to calling paramChanged(), so the implentation of paramChanged() does not need to set *status CHANGE_ACCEPTED if it wishes to allow the change since that will already be the default status |
HISTORICAL NOTE: In the past, subclasses would override setModelParamString() for this same purpose, but in the new setup, setModelParamString() is NOT virtual and hence should not be (cannot be) overridden by subclasses. This setup is cleaner (and potentially more efficient) because subclasses don't have to compare string names to figure out which param changed; instead they are passed the address of the param itself. Furthermore, the new setup is more robust, since we can handle param value changes that come from any source (e.g., setModelParamVal(), or ModelParamBase::setValString(), or OModelParam::setVal()), and not just those that come through setModelParamString().
Reimplemented from ModelComponent.
Reimplemented in VisualCortexSurprise.
Definition at line 205 of file RawVisualCortex.C.
References ComplexChannel::addSubChan(), ASSERT, ModelComponent::getManager(), OModelParam< T >::getVal(), ComplexChannel::hasSubChan(), makeContourChannel(), makeSharedComp(), MC_RECURSE, ComplexChannel::numChans(), ComplexChannel::removeAllSubChans(), and ComplexChannel::subChan().
Image< float > RawVisualCortex::postProcessOutputMap | ( | const Image< float > & | outmap | ) | [protected, virtual] |
post-process raw weighted sum of channel output maps
Derived classes may overload this to provide custom post-processing. For example, VisualCortexSurprise may pass the output through a sigmoidal nonlinearity or spatial competition. Default implementation is to treat the special case of VCXNORM_LANDMARK.
Reimplemented in VisualCortexSurprise.
Definition at line 465 of file RawVisualCortex.C.
References OModelParam< T >::getVal(), itsNormType, itsWeightThresh, maxNormalize(), maxNormTypeName(), VCXNORM_LANDMARK, VCXNORM_NONE, and VCXNORM_SURPRISE.
Referenced by combineOutputs().
void RawVisualCortex::saveResults | ( | const nub::ref< FrameOstream > & | ofs | ) | [virtual] |
Save our results.
Reimplemented from ComplexChannel.
Definition at line 659 of file RawVisualCortex.C.
References FLOAT_NORM_PRESERVE, ComplexChannel::getOutput(), OModelParam< T >::getVal(), itsSaveOutput, ComplexChannel::numChans(), SRC_POS, and ComplexChannel::subChan().
void RawVisualCortex::start1 | ( | ) | [protected, virtual] |
start
Reimplemented from ComplexChannel.
Definition at line 170 of file RawVisualCortex.C.
References ModelComponent::descriptiveName(), featureHierarchyLevel(), featureHierarchyName(), featureName(), OModelParam< T >::getVal(), itsLoadOutFrom, itsSaveOutTo, rutz::make_shared(), ComplexChannel::numChans(), ComplexChannel::numSubmaps(), ComplexChannel::subChan(), and ChannelBase::visualFeature().
void RawVisualCortex::stop2 | ( | ) | [protected, virtual] |
stop
Reimplemented from ComplexChannel.
Definition at line 195 of file RawVisualCortex.C.
References rutz::shared_ptr< T >::is_valid().
OModelParam<LevelSpec> RawVisualCortex::itsLevelSpec [protected] |
LevelSpec used by our channels, used to compute output dims.
Definition at line 146 of file RawVisualCortex.H.
Referenced by combineOutputs(), and doInput().
OModelParam<std::string> RawVisualCortex::itsLoadOutFrom [protected] |
load outputs from MGZ file?
Definition at line 149 of file RawVisualCortex.H.
Referenced by combineOutputs(), doInput(), and start1().
OModelParam<float> RawVisualCortex::itsNoise [protected] |
output noise range
Definition at line 123 of file RawVisualCortex.H.
Referenced by combineOutputs().
OModelParam<MaxNormType> RawVisualCortex::itsNormType [protected] |
maxNormalization to use
Reimplemented from ComplexChannel.
Definition at line 120 of file RawVisualCortex.H.
Referenced by postProcessOutputMap(), and VisualCortexSurprise::postProcessOutputMap().
OModelParam<float> RawVisualCortex::itsOutputFactor [protected] |
output range factor
Definition at line 122 of file RawVisualCortex.H.
Referenced by combineOutputs().
OModelParam<bool> RawVisualCortex::itsSaveOutput [protected] |
OModelParam<std::string> RawVisualCortex::itsSaveOutTo [protected] |
save our outputs to MGZ file?
Definition at line 148 of file RawVisualCortex.H.
Referenced by combineOutputs(), and start1().
OModelParam<bool> RawVisualCortex::itsUseMax [protected] |
use max across features instead of sum?
Definition at line 151 of file RawVisualCortex.H.
Referenced by combineOutputs(), and VisualCortexSurprise::postProcessOutputMap().
OModelParam<bool> RawVisualCortex::itsUseOlderVersion [protected] |
use old version? see Visualcortex.H
Reimplemented from ComplexChannel.
Definition at line 143 of file RawVisualCortex.H.
Referenced by getChannelOutputMap().
OModelParam<bool> RawVisualCortex::itsUseRandom [protected] |
add random noise to output
Definition at line 121 of file RawVisualCortex.H.
Referenced by combineOutputs().
OModelParam<float> RawVisualCortex::itsWeightThresh [protected] |
threshold on channel total weights for last round of maxnorm
Definition at line 152 of file RawVisualCortex.H.
Referenced by postProcessOutputMap().