[Insight-users] Image Spatial object bug?

Kim Chuan Lim lim.kim.chuan at gmail.com
Wed Aug 10 05:13:53 EDT 2005


Hi Insight users,

I have install insight toolkit 2.0 and running 
some ImageSpatialObject examples. The following
is part of my test program.

typedef itk::Image<short,2> Image;
  Image::Pointer image = Image::New();
  Image::SizeType size = {{ 5, 5 }};

typedef itk::SpatialObject<2>             SpatialObjectType;
  typedef SpatialObjectType::TransformType  TransformType;
  TransformType::OffsetType imageSOToParentOffset;
  imageSOToParentOffset[0] = 3;
  imageSOToParentOffset[1] = 3;
  imageSO->GetObjectToParentTransform()->SetOffset(imageSOToParentOffset);
  imageSO->ComputeObjectToWorldTransform();

The size of image is 5x5 and i translate it (3,3) away from parent.
My following code surpise me.

for (int j=7; j <10; j++){
    somepoint[0] = j;
    for (int k=7; k<10; k++){
      somepoint[1] = k;
       if( imageSO->IsInside(somepoint) )
       {
         std::cout << somepoint << " is inside the image." << std::endl;
         imageSO->ValueAt(somepoint,returnedValue);
         std::cout << "ValueAt(" << somepoint << ") = " <<
returnedValue << std::endl;
       } else {
         std::cout << somepoint << " is outside the image." << std::endl;
       }
        
    }
  }

Part of my program output.
The index of the image should be from (2,2) to (7,7)
[7, 7] is inside the image. //last pixel on the child image
ValueAt([7, 7]) = 44
[7, 8] is inside the image. //bug??
ValueAt([7, 8]) = 2054

Am i doing something wrong? Is it i shouldn't use the
ImageSpatialObject in that way?


Best Regards,
Kim Chuan.


More information about the Insight-users mailing list