#include <itkInPlaceLabelMapFilter.h>
Base class for filters that takes an image as input and overwrites that image as the output.
InPlaceLabelMapFilter is the base class for all process objects whose output image data is constructed by overwriting the input image data. In other words, the output bulk data is the same block of memory as the input bulk data. This filter provides the mechanisms for in place image processing while maintaining general pipeline mechanics. InPlaceLabelMapFilters use less memory than standard ImageToImageFilters because the input buffer is reused as the output buffer. However, this benefit does not come without a cost. Since the filter overwrites its input, the ownership of the bulk data is transitioned from the input data object to the output data object. When a data object has multiple consumers with one of the consumers being an in place filter, the in place filter effectively destroys the bulk data for the data object. Upstream filters will then have to re-execute to regenerate the data object's bulk data for the remaining consumers.
Since an InPlaceLabelMapFilter reuses the input bulk data memory for the output bulk data memory, the input image type must match the output image type. If the input and output image types are not identical, the filter reverts to a traditional ImageToImageFilter behaviour where an output image is allocated. In place operation can also be controlled (when the input and output image type match) via the methods InPlaceOn() and InPlaceOff().
Subclasses of InPlaceLabelMapFilter must take extra care in how they manage memory using (and perhaps overriding) the implementations of ReleaseInputs() and AllocateOutputs() provided here.
This code was contributed in the Insight Journal paper: "Label object representation and manipulation with ITK" by Lehmann G. https://doi.org/10.54294/q6auw4
Definition at line 83 of file itkInPlaceLabelMapFilter.h.
Public Member Functions | |
bool | CanRunInPlace () const |
virtual::itk::LightObject::Pointer | CreateAnother () const |
const char * | GetNameOfClass () const override |
virtual void | SetInPlace (bool _arg) |
virtual bool | GetInPlace () |
virtual void | InPlaceOn () |
virtual void | InPlaceOff () |
![]() | |
virtual::itk::LightObject::Pointer | CreateAnother () const |
virtual::itk::LightObject::Pointer | CreateAnother () const |
void | EnlargeOutputRequestedRegion (DataObject *output) override |
void | EnlargeOutputRequestedRegion (DataObject *output) override |
void | GenerateInputRequestedRegion () override |
void | GenerateInputRequestedRegion () override |
const char * | GetNameOfClass () const override |
const char * | GetNameOfClass () const override |
![]() | |
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) |
OutputImageType * | GetOutput () |
const OutputImageType * | GetOutput () const |
virtual void | GraftOutput (DataObject *graft) |
virtual void | GraftOutput (const DataObjectIdentifierType &key, DataObject *graft) |
virtual void | GraftNthOutput (unsigned int idx, DataObject *graft) |
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 () |
MultiThreaderType * | GetMultiThreader () const |
const char * | GetNameOfClass () const override |
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 (MultiThreaderType *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 () |
virtual void | SetNumberOfWorkUnits (ThreadIdType _arg) |
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 |
Static Public Attributes | |
static constexpr unsigned int | InputImageDimension = TInputImage::ImageDimension |
static constexpr unsigned int | OutputImageDimension = TOutputImage::ImageDimension |
![]() | |
static constexpr unsigned int | InputImageDimension |
static constexpr unsigned int | InputImageDimension |
static constexpr unsigned int | OutputImageDimension |
static constexpr unsigned int | OutputImageDimension |
![]() | |
static constexpr unsigned int | InputImageDimension |
static constexpr unsigned int | InputImageDimension |
static constexpr unsigned int | OutputImageDimension |
static constexpr unsigned int | OutputImageDimension |
![]() | |
static constexpr unsigned int | OutputImageDimension |
Private Attributes | |
bool | m_InPlace { true } |
Additional Inherited Members | |
![]() | |
using | InputToOutputRegionCopierType |
using | OutputToInputRegionCopierType |
![]() | |
static const ImageRegionSplitterBase * | GetGlobalDefaultSplitter () |
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION | ThreaderCallback (void *arg) |
![]() | |
template<typename TSourceObject> | |
static void | MakeRequiredOutputs (TSourceObject &sourceObject, const DataObjectPointerArraySizeType numberOfRequiredOutputs) |
static constexpr float | progressFixedToFloat (uint32_t fixed) |
static uint32_t | progressFloatToFixed (float f) |
![]() | |
std::mutex | m_LabelObjectContainerLock |
std::mutex | m_LabelObjectContainerLock |
![]() | |
bool | m_DynamicMultiThreading |
![]() | |
TimeStamp | m_OutputInformationMTime {} |
bool | m_Updating {} |
![]() | |
std::atomic< int > | m_ReferenceCount {} |
using itk::InPlaceLabelMapFilter< TInputImage >::ConstPointer = SmartPointer<const Self> |
Definition at line 92 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::IndexType = typename InputImageType::IndexType |
Definition at line 115 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::InputImageConstPointer = typename InputImageType::ConstPointer |
Definition at line 109 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::InputImagePixelType = typename InputImageType::PixelType |
Definition at line 111 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::InputImagePointer = typename InputImageType::Pointer |
Definition at line 108 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::InputImageRegionType = typename InputImageType::RegionType |
Definition at line 110 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::InputImageType = TInputImage |
Some convenient type alias.
Definition at line 107 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::LabelObjectType = typename InputImageType::LabelObjectType |
Definition at line 112 of file itkInPlaceLabelMapFilter.h.
using itk::LabelMapFilter< TInputImage, TInputImage >::OutputImagePixelType |
Definition at line 86 of file itkLabelMapFilter.h.
using itk::LabelMapFilter< TInputImage, TInputImage >::OutputImagePointer |
Definition at line 83 of file itkLabelMapFilter.h.
using itk::LabelMapFilter< TInputImage, TInputImage >::OutputImageRegionType |
Definition at line 85 of file itkLabelMapFilter.h.
using itk::LabelMapFilter< TInputImage, TInputImage >::OutputImageType |
Definition at line 82 of file itkLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::PixelType = typename InputImageType::PixelType |
Definition at line 114 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::Pointer = SmartPointer<Self> |
Definition at line 91 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::RegionType = typename InputImageType::RegionType |
Definition at line 116 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::Self = InPlaceLabelMapFilter |
Standard class type aliases.
Definition at line 89 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::Superclass = LabelMapFilter<TInputImage, TInputImage> |
Definition at line 90 of file itkInPlaceLabelMapFilter.h.
using itk::InPlaceLabelMapFilter< TInputImage >::TOutputImage = TInputImage |
Definition at line 118 of file itkInPlaceLabelMapFilter.h.
|
protecteddefault |
|
overrideprotecteddefault |
|
overrideprotectedvirtual |
The GenerateData method normally allocates the buffers for all of the outputs of a filter. Since InPlaceLabelMapFilter's can use an overwritten version of the input for its output, the output buffer should not be allocated. When possible, we graft the input to the filter to the output. If an InPlaceFilter has multiple outputs, then it would need to override this method to graft one of its outputs and allocate the remaining. If a filter is threaded (i.e. it provides an implementation of ThreadedGenerateData()), this method is called automatically. If an InPlaceFilter is not threaded (i.e. it provides an implementation of GenerateData()), then this method (or equivalent) must be called in GenerateData().
Reimplemented from itk::ImageSource< TInputImage >.
Referenced by itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >::TemplatedGenerateData(), itk::ShapeOpeningLabelMapFilter< LabelMapType >::TemplatedGenerateData(), and itk::ShapeRelabelLabelMapFilter< LabelMapType >::TemplatedGenerateData().
|
inline |
Can the filter run in place? To do so, the filter's first input and output must have the same dimension and pixel type. This method can be used in conjunction with the InPlace ivar to determine whether a particular use of the filter is really running in place. Some filters may be able to optimize their operation if the InPlace is true and CanRunInPlace is true.
Definition at line 138 of file itkInPlaceLabelMapFilter.h.
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::LightObject.
Reimplemented in itk::LabelSelectionLabelMapFilter< TImage >, itk::LabelSelectionLabelMapFilter< LabelMapType >, itk::LabelSelectionLabelMapFilter< LabelMapType >, itk::LabelUniqueLabelMapFilter< TImage >, itk::MergeLabelMapFilter< TImage >, itk::PadLabelMapFilter< TInputImage >, itk::PadLabelMapFilter< LabelMapType >, itk::PadLabelMapFilter< LabelMapType >, itk::RegionFromReferenceLabelMapFilter< TInputImage >, itk::RelabelLabelMapFilter< TImage >, itk::ShapeKeepNObjectsLabelMapFilter< TImage >, itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >, itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >, itk::ShapeLabelMapFilter< TImage, TLabelImage >, itk::ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >, itk::ShapeLabelMapFilter< TOutputImage, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< TOutputImage, ShapeLabelFilterOutput >, itk::ShapeOpeningLabelMapFilter< TImage >, itk::ShapeOpeningLabelMapFilter< LabelMapType >, itk::ShapeOpeningLabelMapFilter< LabelMapType >, itk::ShapePositionLabelMapFilter< TImage >, itk::ShapeRelabelLabelMapFilter< TImage >, itk::ShapeRelabelLabelMapFilter< LabelMapType >, itk::ShapeRelabelLabelMapFilter< LabelMapType >, itk::ShapeUniqueLabelMapFilter< TImage >, itk::ShiftScaleLabelMapFilter< TImage >, itk::StatisticsKeepNObjectsLabelMapFilter< TImage >, itk::StatisticsKeepNObjectsLabelMapFilter< LabelMapType >, itk::StatisticsKeepNObjectsLabelMapFilter< LabelMapType >, itk::StatisticsLabelMapFilter< TImage, TFeatureImage >, itk::StatisticsLabelMapFilter< LabelMapType, FeatureImageType >, itk::StatisticsLabelMapFilter< LabelMapType, FeatureImageType >, itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage >, itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage >, itk::StatisticsLabelMapFilter< OutputImageType, FeatureImageType >, itk::StatisticsLabelMapFilter< OutputImageType, FeatureImageType >, itk::StatisticsOpeningLabelMapFilter< TImage >, itk::StatisticsOpeningLabelMapFilter< LabelMapType >, itk::StatisticsOpeningLabelMapFilter< LabelMapType >, itk::StatisticsPositionLabelMapFilter< TImage >, itk::StatisticsRelabelLabelMapFilter< TImage >, itk::StatisticsRelabelLabelMapFilter< LabelMapType >, itk::StatisticsRelabelLabelMapFilter< LabelMapType >, and itk::StatisticsUniqueLabelMapFilter< TImage >.
|
virtual |
In place operation can be turned on and off. This only has an effect when the input and output image type match.
|
inlineoverrideprotectedvirtual |
Return the output label collection image, instead of the input as in the default implementation
Reimplemented from itk::LabelMapFilter< TInputImage, TInputImage >.
Definition at line 174 of file itkInPlaceLabelMapFilter.h.
|
overridevirtual |
Reimplemented from itk::ImageToImageFilter< TInputImage, TInputImage >.
Reimplemented in itk::LabelSelectionLabelMapFilter< TImage >, itk::LabelSelectionLabelMapFilter< LabelMapType >, itk::LabelSelectionLabelMapFilter< LabelMapType >, itk::LabelUniqueLabelMapFilter< TImage >, itk::MergeLabelMapFilter< TImage >, itk::PadLabelMapFilter< TInputImage >, itk::PadLabelMapFilter< LabelMapType >, itk::PadLabelMapFilter< LabelMapType >, itk::RegionFromReferenceLabelMapFilter< TInputImage >, itk::RelabelLabelMapFilter< TImage >, itk::ShapeKeepNObjectsLabelMapFilter< TImage >, itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >, itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >, itk::ShapeLabelMapFilter< TImage, TLabelImage >, itk::ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >, itk::ShapeLabelMapFilter< TOutputImage, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< TOutputImage, ShapeLabelFilterOutput >, itk::ShapeOpeningLabelMapFilter< TImage >, itk::ShapeOpeningLabelMapFilter< LabelMapType >, itk::ShapeOpeningLabelMapFilter< LabelMapType >, itk::ShapePositionLabelMapFilter< TImage >, itk::ShapeRelabelLabelMapFilter< TImage >, itk::ShapeRelabelLabelMapFilter< LabelMapType >, itk::ShapeRelabelLabelMapFilter< LabelMapType >, itk::ShapeUniqueLabelMapFilter< TImage >, itk::ShiftScaleLabelMapFilter< TImage >, itk::StatisticsKeepNObjectsLabelMapFilter< TImage >, itk::StatisticsKeepNObjectsLabelMapFilter< LabelMapType >, itk::StatisticsKeepNObjectsLabelMapFilter< LabelMapType >, itk::StatisticsLabelMapFilter< TImage, TFeatureImage >, itk::StatisticsLabelMapFilter< LabelMapType, FeatureImageType >, itk::StatisticsLabelMapFilter< LabelMapType, FeatureImageType >, itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage >, itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage >, itk::StatisticsLabelMapFilter< OutputImageType, FeatureImageType >, itk::StatisticsLabelMapFilter< OutputImageType, FeatureImageType >, itk::StatisticsOpeningLabelMapFilter< TImage >, itk::StatisticsOpeningLabelMapFilter< LabelMapType >, itk::StatisticsOpeningLabelMapFilter< LabelMapType >, itk::StatisticsPositionLabelMapFilter< TImage >, itk::StatisticsRelabelLabelMapFilter< TImage >, itk::StatisticsRelabelLabelMapFilter< LabelMapType >, itk::StatisticsRelabelLabelMapFilter< LabelMapType >, and itk::StatisticsUniqueLabelMapFilter< TImage >.
|
virtual |
In place operation can be turned on and off. This only has an effect when the input and output image type match.
|
virtual |
In place operation can be turned on and off. This only has an effect when the input and output image type match.
|
static |
Standard New method.
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::ImageToImageFilter< TInputImage, TInputImage >.
Reimplemented in itk::MergeLabelMapFilter< TImage >, itk::PadLabelMapFilter< TInputImage >, itk::PadLabelMapFilter< LabelMapType >, itk::PadLabelMapFilter< LabelMapType >, itk::RegionFromReferenceLabelMapFilter< TInputImage >, itk::ShapeKeepNObjectsLabelMapFilter< TImage >, itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >, itk::ShapeKeepNObjectsLabelMapFilter< LabelMapType >, itk::ShapeLabelMapFilter< TImage, TLabelImage >, itk::ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >, itk::ShapeLabelMapFilter< TOutputImage, ShapeLabelFilterOutput >, itk::ShapeLabelMapFilter< TOutputImage, ShapeLabelFilterOutput >, itk::ShapeOpeningLabelMapFilter< TImage >, itk::ShapeOpeningLabelMapFilter< LabelMapType >, itk::ShapeOpeningLabelMapFilter< LabelMapType >, itk::ShapePositionLabelMapFilter< TImage >, itk::ShapeRelabelLabelMapFilter< TImage >, itk::ShapeRelabelLabelMapFilter< LabelMapType >, itk::ShapeRelabelLabelMapFilter< LabelMapType >, itk::ShapeUniqueLabelMapFilter< TImage >, itk::ShiftScaleLabelMapFilter< TImage >, itk::StatisticsLabelMapFilter< TImage, TFeatureImage >, itk::StatisticsLabelMapFilter< LabelMapType, FeatureImageType >, itk::StatisticsLabelMapFilter< LabelMapType, FeatureImageType >, itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage >, itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage >, itk::StatisticsLabelMapFilter< OutputImageType, FeatureImageType >, and itk::StatisticsLabelMapFilter< OutputImageType, FeatureImageType >.
|
virtual |
In place operation can be turned on and off. This only has an effect when the input and output image type match.
|
staticconstexpr |
ImageDimension constants
Definition at line 121 of file itkInPlaceLabelMapFilter.h.
|
private |
Definition at line 180 of file itkInPlaceLabelMapFilter.h.
|
staticconstexpr |
Definition at line 122 of file itkInPlaceLabelMapFilter.h.