[Insight-users] Image Spatial object bug?

Julien Jomier jjomier at cs.unc.edu
Wed Aug 10 08:44:19 EDT 2005


Hi Kim Chuan,

Your program looks good and has the correct behavior.
Most of the functions in the SpatialObject classes are expecting points 
in physical (world) coordinates.

In your current test, you are translating the image by 3. Therefore the 
image now fill in the range [3,8] in world coordinates.

I hope that makes sense,
Let us know if you have any further questions,

Julien

Kim Chuan Lim wrote:
> 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.
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list