Skip to content

Commit 74af5b5

Browse files
committed
BUG: Use proper GenerateOutputInformation method to set vector length
The GernerateOutputInformation method is the correct method to overrride when specifying image information and meta-data. Remove extraneous setting of the image's number of components. The filter will now throw an exception if the improper fixed number of components is set for the output image type.
1 parent 9139ca9 commit 74af5b5

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
227227
virtual void GenerateOutputInformation() ITK_OVERRIDE;
228228

229229
private:
230-
typename DigitizedImageType::Pointer m_DigitalizedInputImage;
230+
typename DigitizedImageType::Pointer m_DigitizedInputImage;
231231

232232
NeighborhoodRadiusType m_NeighborhoodRadius;
233233
OffsetVectorPointer m_Offsets;

include/itkRunLengthTextureFeaturesImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class ITK_TEMPLATE_EXPORT RunLengthTextureFeaturesImageFilter:public ImageToImag
243243
virtual void AfterThreadedGenerateData() ITK_OVERRIDE;
244244
virtual void ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
245245
ThreadIdType threadId) ITK_OVERRIDE;
246-
virtual void UpdateOutputInformation() ITK_OVERRIDE;
246+
virtual void GenerateOutputInformation() ITK_OVERRIDE;
247247

248248
private:
249249
typename InputImageType::Pointer m_DigitizedInputImage;

include/itkRunLengthTextureFeaturesImageFilter.hxx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
9191
this->m_DigitizedInputImage->CopyInformation(this->GetInput());
9292
this->m_DigitizedInputImage->Allocate();
9393
typedef itk::ImageRegionIterator< InputImageType> IteratorType;
94-
IteratorType digitIt( this->m_DigitizedInputImage, this->m_DigitalizedInputImage->GetLargestPossibleRegion() );
94+
IteratorType digitIt( this->m_DigitizedInputImage, this->m_DigitizedInputImage->GetLargestPossibleRegion() );
9595
typedef itk::ImageRegionConstIterator< InputImageType> ConstIteratorType;
9696
ConstIteratorType inputIt( this->GetInput(), this->GetInput()->GetLargestPossibleRegion() );
9797
unsigned int binNumber;
@@ -312,16 +312,19 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
312312
template<typename TInputImage, typename TOutputImage>
313313
void
314314
RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
315-
::UpdateOutputInformation()
315+
::GenerateOutputInformation()
316316
{
317-
// Call superclass's version
318-
Superclass::UpdateOutputInformation();
319-
320-
if ( strcmp(this->GetOutput()->GetNameOfClass(), "VectorImage") == 0 )
321-
{
322-
typedef typename TOutputImage::AccessorFunctorType AccessorFunctorType;
323-
AccessorFunctorType::SetVectorLength( this->GetOutput(), 10 );
324-
}
317+
Superclass::GenerateOutputInformation();
318+
319+
OutputImageType* output = this->GetOutput();
320+
// If the output image type is a VectorImage the number of
321+
// components will be properly sized if before allocation, if the
322+
// output is a fixed width vector and the wrong number of
323+
// components, then an exception will be thrown.
324+
if ( output->GetNumberOfComponentsPerPixel() != 10 )
325+
{
326+
output->SetNumberOfComponentsPerPixel( 10 );
327+
}
325328
}
326329

327330
template<typename TInputImage, typename TOutputImage>

0 commit comments

Comments
 (0)