[Insight-users] RaycastInterpolateImageFunction

Aviv Hurvitz aviv.hurvitz at gmail.com
Tue Jul 1 09:05:53 EDT 2008


Hi Jef,

I used to have problems with this class, however I'm not sure if we have the
same problems.

I solved my problems with two patches. The first originated from Jian Wu, in
this message:
http://public.kitware.com/pipermail/insight-users/2006-March/017265.html
I can't really remember what it fixed, but it worked for me.

The second patch is by me, and it adds support for INPUT images with a
non-zero origin.
What follows is the diff that describes the patches.

Regards,

- Aviv

======================================

726,733c726,730
<   m_CurrentRayPositionInMM[0] =
<     RayPosn[0] + 0.5*m_VoxelDimensionInX*(double)m_NumberOfVoxelsInX;
<
<   m_CurrentRayPositionInMM[1] =
<     RayPosn[1] + 0.5*m_VoxelDimensionInY*(double)m_NumberOfVoxelsInY;
<
<   m_CurrentRayPositionInMM[2] =
<     RayPosn[2] + 0.5*m_VoxelDimensionInZ*(double)m_NumberOfVoxelsInZ;
---
>   // (Aviv) Incorporating a fix by Jian Wu
>   //
http://public.kitware.com/pipermail/insight-users/2006-March/017265.html
>   m_CurrentRayPositionInMM[0] = RayPosn[0];
>   m_CurrentRayPositionInMM[1] = RayPosn[1];
>   m_CurrentRayPositionInMM[2] = RayPosn[2];
1549c1546,1548
<   ray.SetRay(point, direction);
---
>   // (Aviv) Added support for images with non-zero origin
>   ray.SetRay(point - this->m_Image->GetOrigin().GetVectorFromOrigin(),
direction);

======================================



On Tue, Jul 1, 2008 at 3:09 PM, jef vdmb <jvdmb at hotmail.com> wrote:

>
> Hi Luis,
>
> The coordinates of the origin (the coordinates of the pixel with index
> zero) are as they should be.
>
> For example:
> *an input image with origin [0,0,0], ie in the corner
> * an isocenter given by [0,0,0], thus set to the image origin
> *mSourceToScreen=1536; and mSourceToAxis=1000 and (mSourceToScreen -
> mSourceToAxis)=536
>
>
> //I define the focalpoint, in this case [1000,0,0]
> focalpoint[0]= mIsoCenter[0] + mSourceToAxis;
> focalpoint[1]= mIsoCenter[1];
> focalpoint[2]= mIsoCenter[2];
>
> //And the output origin is centered around the projection of the isocenter
> in the YZ plane, in this case  [-536, -204.8 -204.8]  for an output image
> with size 512 and 0.8 pixelsize.
> originOutput[0] = mIsoCenter[0]- (mSourceToScreen - mSourceToAxis);
> originOutput[1] =
> mIsoCenter[1]-(((double)sizeOuput[1]*spacingOutput[1])/2.);
>  originOutput[2] =
> mIsoCenter[2]-((double)sizeOuput[2]*spacingOutput[2]/2.);
>
> Output origin is set correctly, also the point in the middle of the output
> image was projected perpendicularly, as it should, Indicating the focalpoint
> was set correctly with respect to the outputimage. The input image was
> however not set correctly. The point that was projected to the middle of the
> ouputimage is the center of the input volume. It should have been the point
> with coordinates of the isocenter, in this case =[0,0,0] , ie the corner of
> the input image.
>
> The example DigitallyReconstructedRadiograph1.cxx seems to confirm my
> reasoning. The geometry of the projection is also calculated with respect to
> imOrigin, defined to be the input image origin + a shilft to the center of
> the volume.
>
> //.......
>  InputImageType::PointType   imOrigin = image->GetOrigin();
>  InputImageType::SpacingType imRes    = image->GetSpacing();
>
>  typedef InputImageType::RegionType     InputImageRegionType;
>  typedef InputImageRegionType::SizeType InputImageSizeType;
>
>  InputImageRegionType imRegion = image->GetBufferedRegion();
>  InputImageSizeType   imSize   = imRegion.GetSize();
>
>  imOrigin[0] += imRes[0] * static_cast( imSize[0] )/2.0;
>  imOrigin[1] += imRes[1] * static_cast( imSize[1] )/ 2.0;
>  imOrigin[2] += imRes[2] * static_cast( imSize[2] )/ 2.0;
>
> //.......
>
>  InterpolatorType::InputPointType focalpoint;
>
>  focalpoint[0]= imOrigin[0];
>  focalpoint[1]= imOrigin[1];
>  focalpoint[2]= imOrigin[2] - sid/2.;
>
> //....
>
>  double origin[ Dimension ];
>
>  origin[0] = imOrigin[0] + o2Dx - sx*((double) dx - 1.)/2.;
>  origin[1] = imOrigin[1] + o2Dy - sy*((double) dy - 1.)/2.;
>  origin[2] = imOrigin[2] + sid/2.;
>
>  filter->SetOutputOrigin( origin );
>
>
> If I am not mistaken, there seems to be an implicit shift to the center of
> volume in the raycast filter. However I did not find any documentation
> indicating this, and was wondering why?
>
> Thanks for your help,
> jef
> ----------------------------------------
> > Date: Sat, 28 Jun 2008 18:51:44 -0400
> > From: luis.ibanez at kitware.com
> > To: jvdmb at hotmail.com
> > CC: insight-users at itk.org
> > Subject: Re: [Insight-users] RaycastInterpolateImageFunction
> >
> > Hi Jef,
> >
> > What were the coordinates of the origin of the output image ?
> >
> > Please keep in mind that normally those are the coordinates
> > of the first pixel in the image, which means that they relate
> > to a corner (not the center) of the image.
> >
> > Please let us know,
> >
> >
> >     Thanks
> >
> >
> >        Luis
> >
> >
> > ----------------
> > jef vdmb wrote:
> >> Hi,
> >>
> >> I am trying to make a digitally reconstructed radiograph, using  the
> RaycastInterpolateImageFunction. I started with  the example
> DigitallyReconstructedRadiograph1.cxx, but would like to define the geometry
> differently.  I define the focal point and the origin of the output image.
> Sofar so good. The input image is placed in this physical space just by
> using it's origin (which was correctly set in a previous step). However, it
> doesn't seem to be in the right place, ie the point which should be
> projected in the middle of the output image, isn't there. When I calculate
> focalpoint and output origin with respect to the middle of the input volume
> (as you would do if the origin of the physical space were to be defined in
> the center of this volume) the projection is as expected. It seems that by
> default the  center of the input volume is the origin of physical coordinate
> space. The image origin specified in the header of the image is just added
> to this one. Does this make any sens
> > e?
> >>
> >> This is how I define the projection geometry:
> >>
> >>
> >>    focalpoint[0]= mIsoCenter[0] + mSourceToAxis;
> >>   focalpoint[1]= mIsoCenter[1];
> >>   focalpoint[2]= mIsoCenter[2];
> >>   interpolator->SetFocalPoint(focalpoint);
> >>
> >> //projection in the YZ plane
> >>   originOutput[0] = mIsoCenter[0]- (mSourceToScreen - mSourceToAxis);
> >>   originOutput[1] =
> mIsoCenter[1]-(((double)sizeOuput[1]*spacingOutput[1])/2.);
> >>   originOutput[2] =
> mIsoCenter[2]-((double)sizeOuput[2]*spacingOutput[2]/2.);
> >>
> >>
> >> a point in the image whith coordinates of the isocenter should be
> projected in the middle of output image right?
> >>
> >>
> >> Thank you in advance for your help,
> >> Jef
> >> _________________________________________________________________
> >> The other season of giving begins 6/24/08. Check out the i'm Talkathon.
> >> http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving
> >> _______________________________________________
> >> Insight-users mailing list
> >> Insight-users at itk.org
> >> http://www.itk.org/mailman/listinfo/insight-users
> >>
>
> _________________________________________________________________
> Making the world a better place one message at a time.
> http://www.imtalkathon.com/?source=EML_WLH_Talkathon_BetterPlace
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080701/b1d12a02/attachment.htm>


More information about the Insight-users mailing list