Skip to content

Commit 870f1f9

Browse files
committed
BUG: Manually create pixel of proper length
Use the generalized NumericTraits::SetLength method to create a output pixel type of the proper length. The prior approach was producing a segmentation fault with the RLE filter when used with VectorImages and an image with dimension 64x64x1 due to the neighborhood operator exceeding the size of the image in the z-direction. Additionally, this usage in complicated with the C++11 implementation using a "move" assignment/constructor, where the vector may be pointing to the same pixel in the output buffer for the duration of the method.
1 parent 45368ed commit 870f1f9

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.hxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
141141

142142
// Creation of the output pixel type
143143
typename TOutputImage::PixelType outputPixel;
144+
NumericTraits<typename TOutputImage::PixelType>::SetLength(outputPixel, outputPtr->GetNumberOfComponentsPerPixel());
144145

145146
// Separation of the non-boundary region that will be processed in a different way
146147
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< DigitizedImageType > boundaryFacesCalculator;
@@ -150,12 +151,6 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
150151

151152
// Declaration of the variables useful to iterate over the all image region
152153
bool isInImage;
153-
IndexType firstIndex;
154-
for ( unsigned int i = 0; i < this->m_NeighborhoodRadius.Dimension; ++i )
155-
{
156-
firstIndex[i] = 0;
157-
}
158-
outputPixel = outputPtr->GetPixel(firstIndex);
159154
typename OffsetVector::ConstIterator offsets;
160155

161156
// Declaration of the variables useful to iterate over the all the offsets

include/itkRunLengthTextureFeaturesImageFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
145145

146146
// Creation of the output pixel type
147147
typename TOutputImage::PixelType outputPixel;
148+
NumericTraits<typename TOutputImage::PixelType>::SetLength(outputPixel, outputPtr->GetNumberOfComponentsPerPixel());
148149

149150
// Creation of a region with the same size as the neighborhood. This region
150151
// will be used to check if each voxel has already been visited.
@@ -174,7 +175,6 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
174175

175176
// Declaration of the variables useful to iterate over the all image region
176177
bool isInImage;
177-
outputPixel = outputPtr->GetPixel(boolCurentInNeighborhoodIndex);
178178
typename OffsetVector::ConstIterator offsets;
179179

180180
// Declaration of the variables useful to iterate over the all the offsets

0 commit comments

Comments
 (0)