Skip to content

Commit 95705f5

Browse files
committed
ENH: Make the MaskedInput image an optional named input
Make use of the macros to set named input. This reuses the code in the macro. By making this input a named input it clarifies the information printed by the filter when printed.
1 parent a68d857 commit 95705f5

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
128128
itkGetConstMacro(NeighborhoodRadius, NeighborhoodRadiusType);
129129

130130
/** Method to set the mask image */
131-
void SetMaskImage( const InputImageType *image );
131+
itkSetInputMacro(MaskImage, InputImageType);
132132

133133
/** Method to get the mask image */
134-
const InputImageType * GetMaskImage() const;
134+
itkGetInputMacro(MaskImage, InputImageType);
135+
135136

136137
/** Specify the default number of bins per axis */
137138
itkStaticConstMacro( DefaultBinsPerAxis, unsigned int, 256 );

include/itkCoocurrenceTextureFeaturesImageFilter.hxx

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ CoocurrenceTextureFeaturesImageFilter< TInputImage, TOutputImage >
3838
this->SetNumberOfRequiredInputs( 1 );
3939
this->SetNumberOfRequiredOutputs( 1 );
4040

41+
// Mark the "MaskImage" as an optional named input. First it has to
42+
// be added to the list of named inputs then removed from the
43+
// required list.
44+
Self::AddRequiredInputName("MaskImage");
45+
Self::RemoveRequiredInputName("MaskImage");
46+
4147
// Set the offset directions to their defaults: half of all the possible
4248
// directions 1 pixel away. (The other half is included by symmetry.)
4349
// We use a neighborhood iterator to calculate the appropriate offsets.
@@ -256,26 +262,6 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
256262
}
257263
}
258264

259-
template<typename TInputImage, typename TOutputImage>
260-
void
261-
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
262-
::SetMaskImage(const InputImageType *image )
263-
{
264-
// Process object is not const-correct so the const_cast is required here
265-
this->ProcessObject::SetNthInput( 1, const_cast<InputImageType *>( image ) );
266-
}
267-
268-
template<typename TInputImage, typename TOutputImage>
269-
const TInputImage *
270-
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
271-
::GetMaskImage() const
272-
{
273-
if( this->GetNumberOfInputs() < 2 )
274-
{
275-
return ITK_NULLPTR;
276-
}
277-
return static_cast<const InputImageType *>( this->ProcessObject::GetInput( 1 ) );
278-
}
279265

280266
template<typename TInputImage, typename TOutputImage>
281267
void

0 commit comments

Comments
 (0)