template<typename TInputImage, typename TClassifiedImage>
class itk::MRFImageFilter< TInputImage, TClassifiedImage >
Implementation of a labeler object that uses Markov Random Fields to classify pixels in an image data set.
This object classifies pixels based on a Markov Random Field (MRF) model. This implementation uses the maximum a posteriori (MAP) estimates for modeling the MRF. The object traverses the data set and uses the model generated by the Mahalanobis distance classifier to get the distance between each pixel in the data set to a set of known classes, updates the distances by evaluating the influence of its neighboring pixels (based on a MRF model) and finally, classifies each pixel to the class which has the minimum distance to that pixel (taking the neighborhood influence under consideration). DoNeighborhoodOperation is the function that can be modified to achieve different flavors of MRF filters in derived classes.
The classified initial labeled image is needed. It is important that the number of expected classes be set before calling the classifier. In our case we have used the ImageClassifier using a Gaussian model to generate the initial labels. This classifier requires the user to ensure that an appropriate membership function is provided. See the documentation of the image classifier class for more information.
The influence of a neighborhood on a given pixel's classification (the MRF term) is computed by calculating a weighted sum of number of class labels in a three dimensional neighborhood. The basic idea of this neighborhood influence is that if a large number of neighbors of a pixel are of one class, then the current pixel is likely to be of the same class.
The dimensions of the neighborhood are the same as the input image dimensions, and values of the weighting parameters are either specified by the user or through the beta matrix parameter. The default weighting table is generated during object construction. The following table shows an example of a 3 x 3 x 3 neighborhood and the weighting values used. A 3 x 3 x 3 kernel is used where each value is a nonnegative parameter, which encourages neighbors to be of the same class. In this example, the influence of the pixels in the same slice is assigned a weight 1.7. The influence of the pixels in the same location in the previous and next slice is assigned a weight 1.5. A weight of 1.3 is assigned to the influence of the north, south, east, west, and diagonal pixels in the previous and next slices.
\[\begin{array}{ccc}
\begin{array}{|c|c|c|}
1.3 & 1.3 & 1.3 \\
1.3 & 1.5 & 1.3 \\
1.3 & 1.3 & 1.3 \\
\end{array} &
\begin{array}{|c|c|c|}
1.7 & 1.7 & 1.7 \\
1.7 & 0 & 1.7 \\
1.7 & 1.7 & 1.7 \\
\end{array} &
\begin{array}{|c|c|c|}
1.3 & 1.3 & 1.3 \\
1.5 & 1.5 & 1.3 \\
1.3 & 1.3 & 1.3 \\
\end{array} \\
\end{array}\]
The user needs to set the neighborhood size using the SetNeighborhoodRadius function. The details on the semantics of a neighborhood can be found in the documentation associated with the itkNeighborhood and related objects. NOTE: The size of the neighborhood must match the size of the neighborhood weighting parameters set by the user.
For minimization of the MRF labeling function the MinimizeFunctional virtual method is called. For our current implementation we use the iterated conditional modes (ICM) algorithm described in [10].
In each iteration, the algorithm visits each pixel in turn and determines whether to update its classification by computing the influence of the classification of the pixel's neighbors and of the intensity data. On each iteration after the first, we reexamine the classification of a pixel only if the classification of some of its neighbors has changed in the previous iteration. The pixels' classification is updated using a synchronous scheme (iteration by iteration) until the error reaches less than the threshold or the number of iteration exceed the maximum set number of iterations. Note: The current implementation supports betaMatrix default weight for two and three dimensional images only. The default for higher dimension is set to unity. This should be overridden by custom weights after filter initialization.
- See also
- Neighborhood
-
ImageIterator
-
NeighborhoodIterator
-
Classifier
- Examples
- Examples/Statistics/ScalarImageMarkovRandomField1.cxx.
Definition at line 148 of file itkMRFImageFilter.h.
|
| virtual::itk::LightObject::Pointer | CreateAnother () const |
| |
| virtual std::vector< double > | GetMRFNeighborhoodWeight () |
| |
| virtual const char * | GetNameOfClass () const |
| |
| const NeighborhoodRadiusType | GetNeighborhoodRadius () const |
| |
| virtual const unsigned int & | GetNumberOfIterations () const |
| |
| virtual const MRFStopEnum & | GetStopCondition () const |
| |
| void | SetClassifier (typename ClassifierType::Pointer ptrToClassifier) |
| |
| virtual void | SetMRFNeighborhoodWeight (std::vector< double > betaMatrix) |
| |
| void | SetNeighborhoodRadius (const NeighborhoodRadiusType &) |
| |
| void | SetNeighborhoodRadius (const SizeValueType *radiusArray) |
| |
| void | SetNeighborhoodRadius (const SizeValueType) |
| |
|
| virtual void | SetNumberOfClasses (unsigned int _arg) |
| |
| virtual unsigned int | GetNumberOfClasses () const |
| |
|
| virtual void | SetMaximumNumberOfIterations (unsigned int _arg) |
| |
| virtual unsigned int | GetMaximumNumberOfIterations () const |
| |
|
| virtual void | SetErrorTolerance (double _arg) |
| |
| virtual double | GetErrorTolerance () const |
| |
|
| virtual void | SetSmoothingFactor (double _arg) |
| |
| virtual double | GetSmoothingFactor () const |
| |
| const InputImageType * | GetInput () const |
| |
| const InputImageType * | GetInput () const |
| |
| const InputImageType * | GetInput (unsigned int idx) const |
| |
| const InputImageType * | GetInput (unsigned int idx) const |
| |
| void | PopBackInput () override |
| |
| void | PopBackInput () override |
| |
| void | PopFrontInput () override |
| |
| void | PopFrontInput () override |
| |
| virtual void | PushBackInput (const InputImageType *input) |
| |
| virtual void | PushBackInput (const InputImageType *input) |
| |
| virtual void | PushFrontInput (const InputImageType *input) |
| |
| virtual void | PushFrontInput (const InputImageType *input) |
| |
| virtual void | SetInput (const InputImageType *input) |
| |
| virtual void | SetInput (const InputImageType *input) |
| |
| virtual void | SetInput (unsigned int, const TInputImage *image) |
| |
| virtual void | SetInput (unsigned int, const TInputImage *image) |
| |
| virtual void | SetCoordinateTolerance (double _arg) |
| |
| virtual double | GetCoordinateTolerance () const |
| |
| virtual void | SetCoordinateTolerance (double _arg) |
| |
| virtual double | GetCoordinateTolerance () const |
| |
| virtual void | SetDirectionTolerance (double _arg) |
| |
| virtual double | GetDirectionTolerance () const |
| |
| virtual void | SetDirectionTolerance (double _arg) |
| |
| virtual double | GetDirectionTolerance () const |
| |
| OutputImageType * | GetOutput (unsigned int idx) |
| |
| virtual void | GraftNthOutput (unsigned int idx, DataObject *graft) |
| |
| virtual void | GraftOutput (const DataObjectIdentifierType &key, DataObject *graft) |
| |
| virtual void | GraftOutput (DataObject *graft) |
| |
| OutputImageType * | GetOutput () |
| |
| const OutputImageType * | GetOutput () const |
| |
| ProcessObject::DataObjectPointer | MakeOutput (ProcessObject::DataObjectPointerArraySizeType idx) override |
| |
| ProcessObject::DataObjectPointer | MakeOutput (const ProcessObject::DataObjectIdentifierType &) override |
| |
| virtual void | AbortGenerateDataOff () |
| |
| virtual void | AbortGenerateDataOn () |
| |
| virtual const bool & | GetAbortGenerateData () const |
| |
| DataObjectPointerArray | GetIndexedInputs () |
| |
| DataObjectPointerArray | GetIndexedOutputs () |
| |
| NameArray | GetInputNames () const |
| |
| DataObjectPointerArray | GetInputs () |
| |
| MultiThreaderBase * | GetMultiThreader () const |
| |
| DataObjectPointerArraySizeType | GetNumberOfIndexedInputs () const |
| |
| DataObjectPointerArraySizeType | GetNumberOfIndexedOutputs () const |
| |
| DataObjectPointerArraySizeType | GetNumberOfInputs () const |
| |
| DataObjectPointerArraySizeType | GetNumberOfOutputs () const |
| |
| virtual DataObjectPointerArraySizeType | GetNumberOfValidRequiredInputs () const |
| |
| NameArray | GetOutputNames () const |
| |
| DataObjectPointerArray | GetOutputs () |
| |
| virtual float | GetProgress () const |
| |
| NameArray | GetRequiredInputNames () const |
| |
| bool | HasInput (const DataObjectIdentifierType &key) const |
| |
| bool | HasOutput (const DataObjectIdentifierType &key) const |
| |
| void | IncrementProgress (float increment) |
| |
| virtual void | PrepareOutputs () |
| |
| virtual void | PropagateRequestedRegion (DataObject *output) |
| |
| virtual void | ResetPipeline () |
| |
| virtual void | SetAbortGenerateData (bool _arg) |
| |
| void | SetMultiThreader (MultiThreaderBase *threader) |
| |
| virtual void | Update () |
| |
| virtual void | UpdateLargestPossibleRegion () |
| |
| virtual void | UpdateOutputData (DataObject *output) |
| |
| virtual void | UpdateOutputInformation () |
| |
| void | UpdateProgress (float progress) |
| |
| virtual void | SetReleaseDataFlag (bool val) |
| |
| virtual bool | GetReleaseDataFlag () const |
| |
| void | ReleaseDataFlagOn () |
| |
| void | ReleaseDataFlagOff () |
| |
| virtual void | SetReleaseDataBeforeUpdateFlag (bool _arg) |
| |
| virtual const bool & | GetReleaseDataBeforeUpdateFlag () const |
| |
| virtual void | ReleaseDataBeforeUpdateFlagOn () |
| |
| virtual void | ReleaseDataBeforeUpdateFlagOff () |
| |
| | itkVirtualSetClampMacro (NumberOfWorkUnits, ThreadIdType, 1, ITK_MAX_THREADS) |
| |
| virtual const ThreadIdType & | GetNumberOfWorkUnits () const |
| |
| unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
| |
| unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
| |
| LightObject::Pointer | CreateAnother () const override |
| |
| virtual void | DebugOff () const |
| |
| virtual void | DebugOn () const |
| |
| Command * | GetCommand (unsigned long tag) |
| |
| bool | GetDebug () const |
| |
| MetaDataDictionary & | GetMetaDataDictionary () |
| |
| const MetaDataDictionary & | GetMetaDataDictionary () const |
| |
| virtual ModifiedTimeType | GetMTime () const |
| |
| virtual const TimeStamp & | GetTimeStamp () const |
| |
| bool | HasObserver (const EventObject &event) const |
| |
| void | InvokeEvent (const EventObject &) |
| |
| void | InvokeEvent (const EventObject &) const |
| |
| virtual void | Modified () const |
| |
| void | Register () const override |
| |
| void | RemoveAllObservers () |
| |
| void | RemoveObserver (unsigned long tag) const |
| |
| void | SetDebug (bool debugFlag) const |
| |
| void | SetReferenceCount (int) override |
| |
| void | UnRegister () const noexcept override |
| |
| void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
| |
| void | SetMetaDataDictionary (MetaDataDictionary &&rrhs) |
| |
| virtual void | SetObjectName (std::string _arg) |
| |
| virtual const std::string & | GetObjectName () const |
| |
| Pointer | Clone () const |
| |
| virtual void | Delete () |
| |
| virtual int | GetReferenceCount () const |
| |
| void | Print (std::ostream &os, Indent indent=0) const |
| |
|
| void | Allocate () |
| |
| virtual void | ApplyMRFImageFilter () |
| |
| virtual void | DoNeighborhoodOperation (const InputImageNeighborhoodIterator &imageIter, LabelledImageNeighborhoodIterator &labelledIter, LabelStatusImageNeighborhoodIterator &labelStatusIter) |
| |
| void | EnlargeOutputRequestedRegion (DataObject *) override |
| |
| void | GenerateData () override |
| |
| void | GenerateInputRequestedRegion () override |
| |
| void | GenerateOutputInformation () override |
| |
| virtual void | MinimizeFunctional () |
| |
| | MRFImageFilter () |
| |
| void | PrintSelf (std::ostream &os, Indent indent) const override |
| |
| | ~MRFImageFilter () override=default |
| |
| virtual void | CallCopyInputRegionToOutputRegion (OutputImageRegionType &destRegion, const InputImageRegionType &srcRegion) |
| |
| virtual void | CallCopyInputRegionToOutputRegion (OutputImageRegionType &destRegion, const InputImageRegionType &srcRegion) |
| |
| virtual void | CallCopyOutputRegionToInputRegion (InputImageRegionType &destRegion, const OutputImageRegionType &srcRegion) |
| |
| virtual void | CallCopyOutputRegionToInputRegion (InputImageRegionType &destRegion, const OutputImageRegionType &srcRegion) |
| |
| | ImageToImageFilter () |
| |
| | ImageToImageFilter () |
| |
| void | VerifyInputInformation () const override |
| |
| void | VerifyInputInformation () const override |
| |
| | ~ImageToImageFilter () override=default |
| |
| | ~ImageToImageFilter () override=default |
| |
| virtual void | AfterThreadedGenerateData () |
| |
| virtual void | AllocateOutputs () |
| |
| virtual void | BeforeThreadedGenerateData () |
| |
| void | ClassicMultiThread (ThreadFunctionType callbackFunction) |
| |
| virtual const ImageRegionSplitterBase * | GetImageRegionSplitter () const |
| |
| | ImageSource () |
| |
| virtual unsigned int | SplitRequestedRegion (unsigned int i, unsigned int pieces, OutputImageRegionType &splitRegion) |
| |
| | ~ImageSource () override=default |
| |
| virtual void | ThreadedGenerateData (const OutputImageRegionType ®ion, ThreadIdType threadId) |
| |
| virtual void | DynamicThreadedGenerateData (const OutputImageRegionType &outputRegionForThread) |
| |
| virtual bool | GetDynamicMultiThreading () const |
| |
| virtual void | SetDynamicMultiThreading (bool _arg) |
| |
| virtual void | DynamicMultiThreadingOn () |
| |
| virtual void | DynamicMultiThreadingOff () |
| |
| virtual void | AddInput (DataObject *input) |
| |
| void | AddOptionalInputName (const DataObjectIdentifierType &) |
| |
| void | AddOptionalInputName (const DataObjectIdentifierType &, DataObjectPointerArraySizeType idx) |
| |
| virtual void | AddOutput (DataObject *output) |
| |
| bool | AddRequiredInputName (const DataObjectIdentifierType &) |
| |
| bool | AddRequiredInputName (const DataObjectIdentifierType &, DataObjectPointerArraySizeType idx) |
| |
| virtual void | CacheInputReleaseDataFlags () |
| |
| virtual void | GenerateOutputRequestedRegion (DataObject *output) |
| |
| DataObject * | GetInput (const DataObjectIdentifierType &key) |
| |
| const DataObject * | GetInput (const DataObjectIdentifierType &key) const |
| |
| virtual const DataObjectPointerArraySizeType & | GetNumberOfRequiredInputs () const |
| |
| virtual const DataObjectPointerArraySizeType & | GetNumberOfRequiredOutputs () const |
| |
| bool | IsIndexedInputName (const DataObjectIdentifierType &) const |
| |
| bool | IsIndexedOutputName (const DataObjectIdentifierType &) const |
| |
| bool | IsRequiredInputName (const DataObjectIdentifierType &) const |
| |
| DataObjectPointerArraySizeType | MakeIndexFromInputName (const DataObjectIdentifierType &name) const |
| |
| DataObjectPointerArraySizeType | MakeIndexFromOutputName (const DataObjectIdentifierType &name) const |
| |
| DataObjectIdentifierType | MakeNameFromInputIndex (DataObjectPointerArraySizeType idx) const |
| |
| DataObjectIdentifierType | MakeNameFromOutputIndex (DataObjectPointerArraySizeType idx) const |
| |
| void | PrintSelf (std::ostream &os, Indent indent) const override |
| |
| | ProcessObject () |
| |
| virtual void | PropagateResetPipeline () |
| |
| virtual void | PushBackInput (const DataObject *input) |
| |
| virtual void | PushFrontInput (const DataObject *input) |
| |
| virtual void | ReleaseInputs () |
| |
| virtual void | RemoveInput (const DataObjectIdentifierType &key) |
| |
| virtual void | RemoveInput (DataObjectPointerArraySizeType) |
| |
| virtual void | RemoveOutput (const DataObjectIdentifierType &key) |
| |
| virtual void | RemoveOutput (DataObjectPointerArraySizeType idx) |
| |
| bool | RemoveRequiredInputName (const DataObjectIdentifierType &) |
| |
| virtual void | RestoreInputReleaseDataFlags () |
| |
| virtual void | SetInput (const DataObjectIdentifierType &key, DataObject *input) |
| |
| virtual void | SetNthInput (DataObjectPointerArraySizeType idx, DataObject *input) |
| |
| virtual void | SetNthOutput (DataObjectPointerArraySizeType idx, DataObject *output) |
| |
| void | SetNumberOfIndexedInputs (DataObjectPointerArraySizeType num) |
| |
| void | SetNumberOfIndexedOutputs (DataObjectPointerArraySizeType num) |
| |
| virtual void | SetNumberOfRequiredInputs (DataObjectPointerArraySizeType) |
| |
| virtual void | SetNumberOfRequiredOutputs (DataObjectPointerArraySizeType _arg) |
| |
| virtual void | SetOutput (const DataObjectIdentifierType &name, DataObject *output) |
| |
| virtual void | SetPrimaryInput (DataObject *object) |
| |
| virtual void | SetPrimaryOutput (DataObject *object) |
| |
| void | SetRequiredInputNames (const NameArray &) |
| |
| virtual void | VerifyPreconditions () const |
| |
| | ~ProcessObject () override |
| |
| DataObject * | GetInput (DataObjectPointerArraySizeType idx) |
| |
| const DataObject * | GetInput (DataObjectPointerArraySizeType idx) const |
| |
| DataObject * | GetPrimaryInput () |
| |
| const DataObject * | GetPrimaryInput () const |
| |
| virtual void | SetPrimaryInputName (const DataObjectIdentifierType &key) |
| |
| virtual const char * | GetPrimaryInputName () const |
| |
| DataObject * | GetOutput (const DataObjectIdentifierType &key) |
| |
| const DataObject * | GetOutput (const DataObjectIdentifierType &key) const |
| |
| virtual void | SetPrimaryOutputName (const DataObjectIdentifierType &key) |
| |
| virtual const char * | GetPrimaryOutputName () const |
| |
| DataObject * | GetOutput (DataObjectPointerArraySizeType i) |
| |
| const DataObject * | GetOutput (DataObjectPointerArraySizeType i) const |
| |
| DataObject * | GetPrimaryOutput () |
| |
| const DataObject * | GetPrimaryOutput () const |
| |
| virtual bool | GetThreaderUpdateProgress () const |
| |
| virtual void | ThreaderUpdateProgressOn () |
| |
| virtual void | ThreaderUpdateProgressOff () |
| |
| virtual void | SetThreaderUpdateProgress (bool arg) |
| |
| | Object () |
| |
| bool | PrintObservers (std::ostream &os, Indent indent) const |
| |
| virtual void | SetTimeStamp (const TimeStamp &timeStamp) |
| |
| | ~Object () override |
| |
| virtual LightObject::Pointer | InternalClone () const |
| |
| | LightObject () |
| |
| virtual void | PrintHeader (std::ostream &os, Indent indent) const |
| |
| virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
| |
| virtual | ~LightObject () |
| |