template<typename TInputImage, typename TOutputImage, typename TMaskImage = TInputImage>
class itk::MaskedFFTNormalizedCorrelationImageFilter< TInputImage, TOutputImage, TMaskImage >
Calculate masked normalized cross correlation using FFTs.
This filter calculates the masked normalized cross correlation (NCC) of two images under masks using FFTs instead of spatial correlation. It is much faster than spatial correlation for reasonably large structuring elements. This filter is not equivalent to simply masking the images first and then correlating them; the latter approach yields incorrect results because the zeros in the images still affect the metric in the correlation process. This filter implements the masked NCC correctly so that the masked-out regions are completely ignored. The fundamental difference is described in detail in the references below. If the masks are set to images of all ones, the result of this filter is the same as standard NCC.
Inputs: Two images are required as inputs, fixedImage and movingImage, and two are optional, fixedMask and movingMask. In the context of correlation, inputs are often defined as: "image" and "template". In this filter, the fixedImage plays the role of the image, and the movingImage plays the role of the template. However, this filter is capable of correlating any two images and is not restricted to small movingImages (templates). In the fixedMask and movingMask, non-zero positive values indicate locations of useful information in the corresponding image, whereas zero and negative values indicate locations that should be masked out (ignored). Internally, the masks are converted to have values of only 0 and 1. For each optional mask that is not set, the filter internally creates an image of ones, which is equivalent to not masking the image. Thus, if both masks are not set, the result will be equivalent to unmasked NCC. For example, if only a mask for the fixed image is needed, the movingMask can either not be set or can be set to an image of ones.
Optional parameters: The RequiredNumberOfOverlappingPixels enables the user to specify the minimum number of voxels of the two masks that must overlap; any location in the correlation map that results from fewer than this number of voxels will be set to zero. Larger values zero-out pixels on a larger border around the correlation image. Thus, larger values remove less stable computations but also limit the capture range. If RequiredNumberOfOverlappingPixels is set to 0, the default, no zeroing will take place.
The RequiredFractionOfOverlappingPixels enables the user to specify a fraction of the maximum number of overlapping pixels that need to overlap; any location in the correlation map that results from fewer than the product of this fraction and the internally computed maximum number of overlapping pixels will be set to zero. The value ranges between 0.0 and 1.0. This is very useful when the user does does not know beforehand the maximum number of pixels of the masks that will overlap. For example, when the masks have strange shapes, it is difficult to predict how the correlation of the masks will interact and what the maximum overlap will be. It is also useful when the mask shapes or sizes change because it is relative to the internally computed maximum of the overlap. Larger values zero-out pixels on a larger border around the correlation image. Thus, larger values remove less stable computations but also limit the capture range. Experiments have shown that a value between 0.1 and 0.6 works well for images with significant overlap and between 0.05 and 0.1 for images with little overlap (such as in stitching applications). If RequiredFractionOfOverlappingPixels is set to 0, the default, no zeroing will take place.
The user can either specify RequiredNumberOfOverlappingPixels or RequiredFractionOfOverlappingPixels (or both or none). Internally, the number of required pixels resulting from both of these methods is calculated and the one that gives the largest number of pixels is chosen. Since these both default to 0, if a user only sets one, the other is ignored.
Image size: fixedImage and movingImage need not be the same size, but fixedMask must be the same size as fixedImage, and movingMask must be the same size as movingImage. Furthermore, whereas some algorithms require that the "template" be smaller than the "image" because of errors in the regions where the two are not fully overlapping, this filter has no such restriction.
Image spacing: Since the computations are done in the pixel domain, all input images must have the same spacing.
Outputs; The output is an image of RealPixelType that is the masked NCC of the two images and its values range from -1.0 to 1.0. The size of this NCC image is, by definition, size(fixedImage) + size(movingImage) - 1.
Example filter usage:
filter->SetFixedImage( fixedImage );
filter->SetMovingImage( movingImage );
filter->SetFixedImageMask( fixedMask );
filter->SetMovingImageMask( movingMask );
filter->SetRequiredNumberOfOverlappingPixels(20);
filter->Update();
Calculate masked normalized cross correlation using FFTs.
- Warning
- The pixel type of the output image must be of real type (float or double). ConceptChecking is used to enforce the output pixel type. You will get a compilation error if the pixel type of the output image is not float or double.
References: 1) D. Padfield. "Masked object registration in the Fourier domain." Transactions on Image Processing. 2) D. Padfield. "Masked FFT registration". In Proc. Computer Vision and Pattern Recognition, 2010.
- Author
- : Dirk Padfield, GE Global Research, padfield@research.ge.com
- ITK Sphinx Examples:
-
Definition at line 144 of file itkMaskedFFTNormalizedCorrelationImageFilter.h.
|
virtual SizeValueType | GetMaximumNumberOfOverlappingPixels () |
|
const char * | GetNameOfClass () const override |
|
|
| itkSetInputMacro (FixedImage, InputImageType) |
|
| itkGetInputMacro (FixedImage, InputImageType) |
|
|
| itkSetInputMacro (MovingImage, InputImageType) |
|
| itkGetInputMacro (MovingImage, InputImageType) |
|
|
| itkSetInputMacro (FixedImageMask, MaskImageType) |
|
| itkGetInputMacro (FixedImageMask, MaskImageType) |
|
|
| itkSetInputMacro (MovingImageMask, MaskImageType) |
|
| itkGetInputMacro (MovingImageMask, MaskImageType) |
|
|
virtual void | SetRequiredNumberOfOverlappingPixels (SizeValueType _arg) |
|
virtual SizeValueType | GetRequiredNumberOfOverlappingPixels () |
|
|
virtual RealPixelType | GetRequiredFractionOfOverlappingPixels () |
|
virtual void | SetRequiredFractionOfOverlappingPixels (RealPixelType _arg) |
|
const InputImageType * | GetInput () const |
|
const InputImageType * | GetInput (unsigned int idx) const |
|
const char * | GetNameOfClass () const override |
|
void | PopBackInput () override |
|
void | PopFrontInput () override |
|
virtual void | PushBackInput (const InputImageType *input) |
|
virtual void | PushFrontInput (const InputImageType *input) |
|
virtual void | SetInput (const DataObjectIdentifierType &key, DataObject *input) |
|
virtual void | SetInput (const InputImageType *input) |
|
virtual void | SetInput (unsigned int, const TInputImage *image) |
|
virtual void | SetCoordinateTolerance (double _arg) |
|
virtual double | GetCoordinateTolerance () const |
|
virtual void | SetDirectionTolerance (double _arg) |
|
virtual double | GetDirectionTolerance () const |
|
const char * | GetNameOfClass () const override |
|
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 | AbortGenerateDataOn () |
|
virtual void | EnlargeOutputRequestedRegion (DataObject *) |
|
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 DataObjectPointer | MakeOutput (const DataObjectIdentifierType &) |
|
virtual DataObjectPointer | MakeOutput (DataObjectPointerArraySizeType idx) |
|
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 | 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 |
|
const char * | GetNameOfClass () const override |
|
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 Pointer | CreateAnother () const |
|
virtual void | Delete () |
|
virtual const char * | GetNameOfClass () const |
|
virtual int | GetReferenceCount () const |
|
void | Print (std::ostream &os, Indent indent=0) const |
|
virtual void | Register () const |
|
virtual void | SetReferenceCount (int) |
|
virtual void | UnRegister () const noexcept |
|
|
template<typename LocalInputImageType , typename LocalOutputImageType > |
LocalOutputImageType::Pointer | CalculateForwardFFT (LocalInputImageType *inputImage, InputSizeType &FFTImageSize) |
|
template<typename LocalInputImageType , typename LocalOutputImageType > |
LocalOutputImageType::Pointer | CalculateInverseFFT (LocalInputImageType *inputImage, RealSizeType &combinedImageSize) |
|
template<typename LocalInputImageType > |
double | CalculatePrecisionTolerance (LocalInputImageType *inputImage) |
|
template<typename LocalInputImageType > |
LocalInputImageType::Pointer | ElementPositive (LocalInputImageType *inputImage) |
|
template<typename LocalInputImageType , typename LocalOutputImageType > |
LocalOutputImageType::Pointer | ElementProduct (LocalInputImageType *inputImage1, LocalInputImageType *inputImage2) |
|
template<typename LocalInputImageType > |
LocalInputImageType::Pointer | ElementQuotient (LocalInputImageType *inputImage1, LocalInputImageType *inputImage2) |
|
template<typename LocalInputImageType , typename LocalOutputImageType > |
LocalOutputImageType::Pointer | ElementRound (LocalInputImageType *inputImage) |
|
template<typename LocalInputImageType > |
LocalInputImageType::Pointer | ElementSubtraction (LocalInputImageType *inputImage1, LocalInputImageType *inputImage2) |
|
void | EnlargeOutputRequestedRegion (DataObject *output) override |
|
int | FactorizeNumber (int n) |
|
int | FindClosestValidDimension (int n) |
|
void | GenerateData () override |
|
void | GenerateInputRequestedRegion () override |
|
void | GenerateOutputInformation () override |
|
| MaskedFFTNormalizedCorrelationImageFilter () |
|
TInputImage::Pointer | PreProcessImage (const InputImageType *inputImage, const MaskImageType *inputMask) |
|
TMaskImage::Pointer | PreProcessMask (const InputImageType *inputImage, const MaskImageType *inputMask) |
|
void | PrintSelf (std::ostream &os, Indent indent) const override |
|
template<typename LocalInputImageType > |
LocalInputImageType::Pointer | RotateImage (LocalInputImageType *inputImage) |
|
void | VerifyInputInformation () const override |
|
| ~MaskedFFTNormalizedCorrelationImageFilter () override=default |
|
virtual void | CallCopyInputRegionToOutputRegion (OutputImageRegionType &destRegion, const InputImageRegionType &srcRegion) |
|
virtual void | CallCopyOutputRegionToInputRegion (InputImageRegionType &destRegion, const OutputImageRegionType &srcRegion) |
|
void | GenerateInputRequestedRegion () override |
|
| ImageToImageFilter () |
|
void | PrintSelf (std::ostream &os, Indent indent) const override |
|
void | VerifyInputInformation () const override |
|
| ~ImageToImageFilter () override=default |
|
virtual void | PushBackInput (const DataObject *input) |
|
virtual void | PushFrontInput (const DataObject *input) |
|
virtual void | AfterThreadedGenerateData () |
|
virtual void | AllocateOutputs () |
|
virtual void | BeforeThreadedGenerateData () |
|
void | ClassicMultiThread (ThreadFunctionType callbackFunction) |
|
void | GenerateData () override |
|
virtual const ImageRegionSplitterBase * | GetImageRegionSplitter () const |
|
| ImageSource () |
|
void | PrintSelf (std::ostream &os, Indent indent) const override |
|
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 | 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 | GenerateData () |
|
virtual void | GenerateInputRequestedRegion () |
|
virtual void | GenerateOutputInformation () |
|
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 |
|
virtual void | PopBackInput () |
|
virtual void | PopFrontInput () |
|
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 | VerifyInputInformation () const |
|
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 | SetThreaderUpdateProgress (bool arg) |
|
| Object () |
|
bool | PrintObservers (std::ostream &os, Indent indent) const |
|
void | PrintSelf (std::ostream &os, Indent indent) const override |
|
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 | PrintSelf (std::ostream &os, Indent indent) const |
|
virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
|
virtual | ~LightObject () |
|