[Insight-users] Help with Shaped Neighborhood Iterators: Setting and Retrieving Offsets - mismatches
Neal R. Harvey
harve at lanl.gov
Tue Aug 4 18:33:42 EDT 2009
Sorry to keep posting, but this problem is vexing - I just can't
understand why I am seeing the
strange behavior that I am.
Further analysis shows that, no matter what values of offset I set, the
retrieved offsets are always
from the entire neighborhood, making it seemingly impossible to activate
any other "stencil" than
a rectangle. For the example I was trying to implement, I wanted to
activate the line of pixels around
the edge of a 7x7 square for the neighborhood stencil (i.e. there are 24
pixels to be activated). But, what
seems to happen, in spite of my being careful to define the precise
offsets to be activated for the line
around the edge of the box, is that the offsets that I retrieve are the
first 24 places in a raster scan order
of the 7x7 box.
i.e. what I want (and thought I was setting) is, w.r.t. offset and pixel
weights:
MissOffset[0] = -3: MissOffset[1] = -3: MissSEPixelValue = 1
MissOffset[0] = -2: MissOffset[1] = -3: MissSEPixelValue = 2
MissOffset[0] = -1: MissOffset[1] = -3: MissSEPixelValue = 3
MissOffset[0] = 0: MissOffset[1] = -3: MissSEPixelValue = 4
MissOffset[0] = 1: MissOffset[1] = -3: MissSEPixelValue = 5
MissOffset[0] = 2: MissOffset[1] = -3: MissSEPixelValue = 6
MissOffset[0] = 3: MissOffset[1] = -3: MissSEPixelValue = 7
MissOffset[0] = -3: MissOffset[1] = -2: MissSEPixelValue = 8
MissOffset[0] = 3: MissOffset[1] = -2: MissSEPixelValue = 14
MissOffset[0] = -3: MissOffset[1] = -1: MissSEPixelValue = 15
MissOffset[0] = 3: MissOffset[1] = -1: MissSEPixelValue = 21
MissOffset[0] = -3: MissOffset[1] = 0: MissSEPixelValue = 22
MissOffset[0] = 3: MissOffset[1] = 0: MissSEPixelValue = 28
MissOffset[0] = -3: MissOffset[1] = 1: MissSEPixelValue = 29
MissOffset[0] = 3: MissOffset[1] = 1: MissSEPixelValue = 35
MissOffset[0] = -3: MissOffset[1] = 2: MissSEPixelValue = 36
MissOffset[0] = 3: MissOffset[1] = 2: MissSEPixelValue = 42
MissOffset[0] = -3: MissOffset[1] = 3: MissSEPixelValue = 43
MissOffset[0] = -2: MissOffset[1] = 3: MissSEPixelValue = 44
MissOffset[0] = -1: MissOffset[1] = 3: MissSEPixelValue = 45
MissOffset[0] = 0: MissOffset[1] = 3: MissSEPixelValue = 46
MissOffset[0] = 1: MissOffset[1] = 3: MissSEPixelValue = 47
MissOffset[0] = 2: MissOffset[1] = 3: MissSEPixelValue = 48
MissOffset[0] = 3: MissOffset[1] = 3: MissSEPixelValue = 49
But, what I retrieve is:
Offset[0] = -3; OffSet[1] = -3; PixelValue = 1
Offset[0] = -2; OffSet[1] = -3; PixelValue = 2
Offset[0] = -1; OffSet[1] = -3; PixelValue = 3
Offset[0] = 0; OffSet[1] = -3; PixelValue = 4
Offset[0] = 1; OffSet[1] = -3; PixelValue = 5
Offset[0] = 2; OffSet[1] = -3; PixelValue = 6
Offset[0] = 3; OffSet[1] = -3; PixelValue = 7
Offset[0] = -3; OffSet[1] = -2; PixelValue = 8
Offset[0] = -2; OffSet[1] = -2; PixelValue = 14
Offset[0] = -1; OffSet[1] = -2; PixelValue = 15
Offset[0] = 0; OffSet[1] = -2; PixelValue = 21
Offset[0] = 1; OffSet[1] = -2; PixelValue = 22
Offset[0] = 2; OffSet[1] = -2; PixelValue = 28
Offset[0] = 3; OffSet[1] = -2; PixelValue = 29
Offset[0] = -3; OffSet[1] = -1; PixelValue = 35
Offset[0] = -2; OffSet[1] = -1; PixelValue = 36
Offset[0] = -1; OffSet[1] = -1; PixelValue = 42
Offset[0] = 0; OffSet[1] = -1; PixelValue = 43
Offset[0] = 1; OffSet[1] = -1; PixelValue = 44
Offset[0] = 2; OffSet[1] = -1; PixelValue = 45
Offset[0] = 3; OffSet[1] = -1; PixelValue = 46
Offset[0] = -3; OffSet[1] = 0; PixelValue = 47
Offset[0] = -2; OffSet[1] = 0; PixelValue = 48
Offset[0] = -1; OffSet[1] = 0; PixelValue = 49
Am I missing something here or doing something so obviously wrong?
I have based what I have done on the example that Luis sent for the
grayscale shaped
value iterator and the example in the book that shows how to create a
shaped
neighborhood (the book example is supposed to create a circular
neighborhood): i.e.
Examples/Iterators/ShapedNeighborhoodIterators1.cxx
Neal R. Harvey wrote:
> 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