[Insight-users] Creating a spatial object from a binary image
Luis Ibanez
luis.ibanez at kitware.com
Thu Jun 3 20:30:37 EDT 2004
Hi Vincent,
Thanks for pointing this out.
This looks like a bug in the ImageSpatialObject.
We just entered as Bug # 909
http://www.itk.org/Bug/bug.php?op=show&bugid=909&pos=0
The "IsInside()" method is simply checking if
the point is inside the bounding box of the image.
As a quick and dirty fix please do the following:
1) Go to
Insight/Code/SpatialObjects/
itkImageSpatialObject.txx
2) Search for lines 68 to 78 where the methods
"IsInside()" is defined.
3) Replace the current content of "IsInside()" with
a delegation like
{
this->ValueAt( point, value, depth, name );
return (value != 0);
}
For a long term solution we probably need to
add a explicit class:
ImageMaskSpatialObject
with an IsInside() methods as the one you just
implemented.
Please let us know if you find any other problems,
Thanks
Luis
-------------------
Vincent Chu wrote:
> 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