[Insight-users] GetPixel() strange behavior

Antonio Calabrese calantoanto at gmail.com
Mon Jun 17 17:56:12 EDT 2013


Hi Everyone,
I have encountered some problems in the my implementation of the method
"GetPixel()".
I have to use it because do I need to get a list of all pixels values
belonging to an LabelObject.
It isn't my first time that i use the "GetPixel" method, but unfortunately,
this time i can't understand because when i call this method, it give me
back an insignificant result.
If i have an image with an unsigned char PixelType, why my code returns me
as result for example "D" (the letter)???
Here below there's my code:
for(unsigned int i = 0; (i <
binaryImageToStatisticsLabelMapFilterTypePointer->GetOutput()->GetNumberOfLabelObjects());
++i)
{

BinaryImageToStatisticsLabelMapFilterType::OutputImageType::LabelObjectType*
statisticsLabelObjectPointer =
binaryImageToStatisticsLabelMapFilterTypePointer->GetOutput()->GetNthLabelObject(i);

for(unsigned int pixelId = 0; pixelId <
statisticsLabelObjectPointer->Size(); pixelId++)
{
                        typedef ImageType::PixelType TypePixel;
                        typedef itk::VectorContainer<int, TypePixel>
VectorContainerPixelsType;
                        VectorContainerPixelsType::Pointer pixelValueList =
VectorContainerPixelsType::New();
                       
pixelValueList->Reserve(statisticsLabelObjectPointer->Size());
                        
                        ImageType::Pointer image =
intensityWindowingImageFilterPointer_2->GetOutput();
                        image->GetLargestPossibleRegion();
                        image->Update();
                        
                        ImageType::IndexType index_image =
statisticsLabelObjectPointer->GetIndex(pixelId);
                        unsigned char test;
                        test = image->GetPixel(index_image);
                        pixelValueList -> SetElement(pixelId,
image->GetPixel(index_image));
                        std::cout << " "<<
pixelValueList->GetElement(pixelId) << std::endl;
}
}

To be more specific:
-intensityWindowingImageFilterPointer_2 is a pointer to an
IntensityWindowingImageFIlter class that returns an unsigned char image.
- "test" is a simple ceck.
- I chose to use "VectorContainer class" because I need it later. I have
also tried without, but the result is always the same.

Thanks,

hi Antonio. 



--
View this message in context: http://itk-users.7.n7.nabble.com/GetPixel-strange-behavior-tp31719.html
Sent from the ITK - Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list