[Insight-users] Re: metrics and image masks
    Christoph Niedermayr 
    niedermayr at trium.de
       
    Mon Aug 21 06:25:56 EDT 2006
    
    
  
Am Donnerstag, den 17.08.2006, 15:13 +0200 schrieb Christoph Niedermayr:
> Am Donnerstag, den 17.08.2006, 08:39 -0400 schrieb Luis Ibanez:
> > What version of ITK are you using ?
> 2.6
> 
> > There are no calls to GetPixel() inside the file
> >     Insight/Code/Algorithms/
> >       itkMattesMutualInformationImageToImageMetric.txx
> > What the metric calls is the method "IsInside" in lines
> > 457 and 526.
> 
> you're right, i got that confused. But "IsInside" then calls "GetPixel",
> if the sample is considered inside the SpacialObject, in my case with an
> invald index.
Hi Luis!
here's whats happening exactly, values are taken from gdb:
the image i use as mask has the following properties:
origin = [-150, -113, -231]
index  = [0, 0, 0]
size   = [60, 42, 60]
spacing= [5, 5, 5]
the point that is given to "IsInside" has the coordinates
[30, -88, 69]
and is considered inside (because the upper z bound of the spacialobject
is 69, and only values exceeding the bound are considered outside)
z-distance between origin and the point is 300.
z-index is then calculated as 60 (invalid), causing SIGSEV when calling
"GetPixel"
below you find a code sample which causes this error. of course, SIGSEV
only occurs if the accessed memory location is indeed off limits to the
program. eg. using a 2D image of size 10x10 queries the image buffer at
110, but did not cause SIGSEV..
best regards,
chris
_____
#include "itkImage.h"
#include "itkImageMaskSpatialObject.h"
  // create 123x123x123 image
  typedef itk::Image<unsigned char,3> ImageType;
  ImageType::Pointer img = ImageType::New();
  ImageType::RegionType region;
  ImageType::SizeType size;
  ImageType::IndexType index;
  ImageType::PointType origin;
  ImageType::SpacingType spacing;
  size.Fill(123);
  index.Fill(0);
  origin.Fill(0);
  spacing.Fill(1);
  region.SetSize(size);
  region.SetIndex(index);
  img->SetRegions(region);
  img->SetOrigin(origin);
  img->SetSpacing(spacing);
  img->Allocate();
  // create mask from image
  itk::ImageMaskSpatialObject<3>::Pointer mask =
itk::ImageMaskSpatialObject<3>::New();
  mask->SetImage(img);
  // check if borderpoint is inside
  ImageType::PointType testPoint;
  testPoint.Fill(123);
  mask->IsInside(testPoint);
    
    
More information about the Insight-users
mailing list