Skip to content
Snippets Groups Projects
Commit 4356dff9 authored by Sebastien Harasse's avatar Sebastien Harasse
Browse files

BUG: region merging : fixed InputLabelType instead of OutputLabelType

parent b49a2697
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,7 @@ protected:
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Method to build a map of adjacent regions */
RegionAdjacencyMapType LabelImageToRegionAdjacencyMap(typename InputLabelImageType::Pointer inputLabelImage);
RegionAdjacencyMapType LabelImageToRegionAdjacencyMap(typename OutputLabelImageType::Pointer inputLabelImage);
private:
LabelImageRegionMergingFilter(const Self &); //purposely not implemented
......
......@@ -178,7 +178,7 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
++outputIt;
}
RegionAdjacencyMapType regionAdjacencyMap = LabelImageToRegionAdjacencyMap(inputLabelImage);
RegionAdjacencyMapType regionAdjacencyMap = LabelImageToRegionAdjacencyMap(outputLabelImage);
unsigned int regionCount = regionAdjacencyMap.size() - 1;
// Initialize arrays for mode information
......@@ -409,13 +409,13 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage, class TOutputClusteredImage>
typename LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabelImage, TOutputClusteredImage>::RegionAdjacencyMapType
LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabelImage, TOutputClusteredImage>
::LabelImageToRegionAdjacencyMap(typename InputLabelImageType::Pointer inputLabelImage)
::LabelImageToRegionAdjacencyMap(typename OutputLabelImageType::Pointer labelImage)
{
// declare the output map
RegionAdjacencyMapType ram;
// Find the maximum label value
itk::ImageRegionConstIterator<InputLabelImageType> it(inputLabelImage, inputLabelImage->GetRequestedRegion());
itk::ImageRegionConstIterator<OutputLabelImageType> it(labelImage, labelImage->GetRequestedRegion());
it.GoToBegin();
LabelType maxLabel = 0;
while(!it.IsAtEnd())
......@@ -430,11 +430,11 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
// set the image region without bottom and right borders so that bottom and
// right neighbors always exist
RegionType regionWithoutBottomRightBorders = inputLabelImage->GetRequestedRegion();
RegionType regionWithoutBottomRightBorders = labelImage->GetRequestedRegion();
SizeType size = regionWithoutBottomRightBorders.GetSize();
for(unsigned int d = 0; d < ImageDimension; ++d) size[d] -= 1;
regionWithoutBottomRightBorders.SetSize(size);
itk::ImageRegionConstIteratorWithIndex<InputLabelImageType> inputIt(inputLabelImage, regionWithoutBottomRightBorders);
itk::ImageRegionConstIteratorWithIndex<OutputLabelImageType> inputIt(labelImage, regionWithoutBottomRightBorders);
inputIt.GoToBegin();
while(!inputIt.IsAtEnd())
......@@ -448,7 +448,7 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
InputIndexType neighborIndex = index;
neighborIndex[d]++;
LabelType neighborLabel = inputLabelImage->GetPixel(neighborIndex);
LabelType neighborLabel = labelImage->GetPixel(neighborIndex);
// add adjacency if different labels
if(neighborLabel != label)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment