[Insight-users] Creating a spatial object from a binary image

Vincent Chu vwchu at cs.sfu.ca
Thu Jun 3 19:32:25 EDT 2004


Hi Luis,

Thanks for the reply.  I tried SetImage() to an image whose pixel type is
unsigned char, and each pixel has value either 0 or 255.  However,
isInside(PointType x) seems to return true regardless of whether x is a
point where the pixel value is 0 or 255.  This is what I have in code:

/////////////////////////////////////////////////////////////////////

typedef itk::Point<double,3> Point;
  Point insidePoint;
  insidePoint[0]=182;
  insidePoint[1]=256;
  insidePoint[2]=15;
  if( imageSO->IsInside(insidePoint) )
	  std::cout << insidePoint << " is inside the image." <<
std::endl;
  double returnedValue;
  imageSO->ValueAt(insidePoint,returnedValue);
  std::cout << "ValueAt(" << insidePoint << ") = " << returnedValue <<
std::endl;
  insidePoint.Fill(1);
  if( imageSO->IsInside(insidePoint) )
	  std::cout << insidePoint << " is inside the image." <<
std::endl;
  imageSO->ValueAt(insidePoint,returnedValue);
  std::cout << "ValueAt(" << insidePoint << ") = " << returnedValue <<
std::endl;imageSO->ValueAt(insidePoint,returnedValue);

//////////////////////////////////////////////////////////////////////////

And I get the following output:

182  256  15 is inside the image.
ValueAt(182  256  15) = 255
1  1  1 is inside the image.
ValueAt(1  1  1) = 0

Did I setup something wrong?

Thanks,

Vincent




On Thu, 3 Jun 2004, Luis Ibanez wrote:


>
> Hi Vincent,
>
> You are in the right track,
> the class to use is the:
> ImageSpatialObject.
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageSpatialObject.html
>
>
> Just connect your image mask to the ImageSpatialObject
> using its "SetImage()" method.
>
> There is no overload for doing this. At the end,
> the spatial object just need to answers the queries
> for whether a pixel is "inside" of the object (your
> image mask in this case) or not. What the Spatial
> object is doing is simply delegating the quiery to
> the underlying image mask that you provided.
>
>
> Please let us know if you have further questions,
>
>
>     Thanks
>
>
>       Luis
>
>
> ----------------
> Vincent Chu wrote:
>
> > Hi,
> >
> > I am new to ITK and would like to perform registration between two images.
> > The region of interest has arbitrary shapes, and I previously read from
> > the list that we can use SetMovingImageMak() and SetFixedImageMask() in
> > ImageToImageMetrics to set the region in which the metrics will be
> > computed.  However, those two methods expect spatial objects as parameter,
> > and I have trouble converting a binary image into a spatial object.  I
> > have tried ImageSpatialObject, but the entire binary image would be
> > created as one big spatial object.  Which class should I use instead?
> >
> > Thanks,
> >
> > Vincent
> > _______________________________________________
> > 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