[Insight-users] Help with Shaped Neighborhood Iterators: Setting and Retrieving Offsets - mismatches

Neal R. Harvey harve at lanl.gov
Tue Aug 4 17:21:57 EDT 2009


To show the problem more simply:

Here's a short snippet of code where I set offsets for a shaped 
neighborhood and then immediately retrieve this offset. I then print the 
value of the offset I thought
I was setting and the value that I retrieved:

        MissOffset[0] = static_cast<int>(x);
        MissOffset[1] = static_cast<int>(y);
        MissNeighborhoodIterator.ActivateOffset(MissOffset);
        MissNeighborhoodIterator.SetPixelWeight(z, 
static_cast<InputPixelType>((MissSEPixelValue)));

        std::cout << "   x = " << x << ": y = " << y << std::endl;
        std::cout << "   MissOffset[0] = " << MissOffset[0] << ": 
MissOffset[1] = " << MissOffset[1] << ": MissSEPixelValue = " << 
static_cast<int>(MissSEPixelValue) << std::endl;

        std::cout << "   Retrieved:MissOffset[0] = " << 
MissNeighborhoodIterator.GetOffset(z)[0] << ": Retrieved:MissOffset[1] = 
" << MissNeighborhoodIterator.GetOffset(z)[1] << ": 
Retrieved:MissSEPixelValue = " << 
MissNeighborhoodIterator.GetPixelWeight(z) << std::endl;

I often get outputs such as the following:

   x = 3: y = -2
   MissOffset[0] = 3: MissOffset[1] = -2: MissSEPixelValue = 14
   Retrieved:MissOffset[0] = -2: Retrieved:MissOffset[1] = -2: 
Retrieved:MissSEPixelValue = 14

    Here, we can see that the retrieved value of the offsets do not 
match those just set! However, the set values for the PixelWeights are
    always in agreement with those retrieved.


More information about the Insight-users mailing list