Glad to hear it.<br><br>I hope an ITK developer would consider inserting these patches to the main ITK branch. Others are destined to run into this problem, like you and me and Jian Wu before us.<br><br>Backwards compatibility may be an issue though --- I haven't considered it.<br>
<br>- Aviv<br><br><div class="gmail_quote">On Wed, Jul 2, 2008 at 5:15 PM, jef vdmb <<a href="mailto:jvdmb@hotmail.com">jvdmb@hotmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Thanks Aviv,<br>
<br>
This is exactly what was needed. Instead of by default being shifted to the center of the input volume, the ray are calculated with respect to the origin of the physical coordinate system (patch 1); and the input origin is taken into account (patch 2)!<br>
<br>
Thanks for your help,<br>
Jef<br>
________________________________<br>
> Date: Tue, 1 Jul 2008 16:05:53 +0300<br>
> From: <a href="mailto:aviv.hurvitz@gmail.com">aviv.hurvitz@gmail.com</a><br>
> To: <a href="mailto:jvdmb@hotmail.com">jvdmb@hotmail.com</a>; <a href="mailto:insight-users@itk.org">insight-users@itk.org</a><br>
<div class="Ih2E3d">> Subject: Re: [Insight-users] RaycastInterpolateImageFunction<br>
><br>
> Hi Jef,<br>
><br>
</div><div class="Ih2E3d">> I used to have problems with this class, however I'm not sure if we have the same problems.<br>
><br>
> I solved my problems with two patches. The first originated from Jian Wu, in this message:<br>
> <a href="http://public.kitware.com/pipermail/insight-users/2006-March/017265.html" target="_blank">http://public.kitware.com/pipermail/insight-users/2006-March/017265.html</a><br>
> I can't really remember what it fixed, but it worked for me.<br>
><br>
> The second patch is by me, and it adds support for INPUT images with a non-zero origin.<br>
> What follows is the diff that describes the patches.<br>
><br>
> Regards,<br>
><br>
> - Aviv<br>
><br>
> ======================================<br>
><br>
> 726,733c726,730<br>
> < m_CurrentRayPositionInMM[0] =<br>
> < RayPosn[0] + 0.5*m_VoxelDimensionInX*(double)m_NumberOfVoxelsInX;<br>
> <<br>
> < m_CurrentRayPositionInMM[1] =<br>
> < RayPosn[1] + 0.5*m_VoxelDimensionInY*(double)m_NumberOfVoxelsInY;<br>
> <<br>
> < m_CurrentRayPositionInMM[2] =<br>
> < RayPosn[2] + 0.5*m_VoxelDimensionInZ*(double)m_NumberOfVoxelsInZ;<br>
> ---<br>
>> // (Aviv) Incorporating a fix by Jian Wu<br>
>> // <a href="http://public.kitware.com/pipermail/insight-users/2006-March/017265.html" target="_blank">http://public.kitware.com/pipermail/insight-users/2006-March/017265.html</a><br>
>> m_CurrentRayPositionInMM[0] = RayPosn[0];<br>
>> m_CurrentRayPositionInMM[1] = RayPosn[1];<br>
>> m_CurrentRayPositionInMM[2] = RayPosn[2];<br>
> 1549c1546,1548<br>
> < ray.SetRay(point, direction);<br>
> ---<br>
>> // (Aviv) Added support for images with non-zero origin<br>
>> ray.SetRay(point - this->m_Image->GetOrigin().GetVectorFromOrigin(), direction);<br>
><br>
> ======================================<br>
><br>
><br>
><br>
</div><div><div></div><div class="Wj3C7c">> On Tue, Jul 1, 2008 at 3:09 PM, jef vdmb wrote:<br>
><br>
> Hi Luis,<br>
><br>
> The coordinates of the origin (the coordinates of the pixel with index zero) are as they should be.<br>
><br>
> For example:<br>
> *an input image with origin [0,0,0], ie in the corner<br>
> * an isocenter given by [0,0,0], thus set to the image origin<br>
> *mSourceToScreen=1536; and mSourceToAxis=1000 and (mSourceToScreen - mSourceToAxis)=536<br>
><br>
><br>
> //I define the focalpoint, in this case [1000,0,0]<br>
> focalpoint[0]= mIsoCenter[0] + mSourceToAxis;<br>
> focalpoint[1]= mIsoCenter[1];<br>
> focalpoint[2]= mIsoCenter[2];<br>
><br>
> //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.<br>
> originOutput[0] = mIsoCenter[0]- (mSourceToScreen - mSourceToAxis);<br>
> originOutput[1] = mIsoCenter[1]-(((double)sizeOuput[1]*spacingOutput[1])/2.);<br>
> originOutput[2] = mIsoCenter[2]-((double)sizeOuput[2]*spacingOutput[2]/2.);<br>
><br>
> 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.<br>
><br>
> 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.<br>
><br>
> //.......<br>
> InputImageType::PointType imOrigin = image->GetOrigin();<br>
> InputImageType::SpacingType imRes = image->GetSpacing();<br>
><br>
> typedef InputImageType::RegionType InputImageRegionType;<br>
> typedef InputImageRegionType::SizeType InputImageSizeType;<br>
><br>
> InputImageRegionType imRegion = image->GetBufferedRegion();<br>
> InputImageSizeType imSize = imRegion.GetSize();<br>
><br>
> imOrigin[0] += imRes[0] * static_cast( imSize[0] )/2.0;<br>
> imOrigin[1] += imRes[1] * static_cast( imSize[1] )/ 2.0;<br>
> imOrigin[2] += imRes[2] * static_cast( imSize[2] )/ 2.0;<br>
><br>
> //.......<br>
><br>
> InterpolatorType::InputPointType focalpoint;<br>
><br>
> focalpoint[0]= imOrigin[0];<br>
> focalpoint[1]= imOrigin[1];<br>
> focalpoint[2]= imOrigin[2] - sid/2.;<br>
><br>
> //....<br>
><br>
> double origin[ Dimension ];<br>
><br>
> origin[0] = imOrigin[0] + o2Dx - sx*((double) dx - 1.)/2.;<br>
> origin[1] = imOrigin[1] + o2Dy - sy*((double) dy - 1.)/2.;<br>
> origin[2] = imOrigin[2] + sid/2.;<br>
><br>
> filter->SetOutputOrigin( origin );<br>
><br>
><br>
> 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?<br>
><br>
> Thanks for your help,<br>
> jef<br>
> ----------------------------------------<br>
>> Date: Sat, 28 Jun 2008 18:51:44 -0400<br>
>> From: <a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a><br>
>> To: <a href="mailto:jvdmb@hotmail.com">jvdmb@hotmail.com</a><br>
>> CC: <a href="mailto:insight-users@itk.org">insight-users@itk.org</a><br>
>> Subject: Re: [Insight-users] RaycastInterpolateImageFunction<br>
>><br>
>> Hi Jef,<br>
>><br>
>> What were the coordinates of the origin of the output image ?<br>
>><br>
>> Please keep in mind that normally those are the coordinates<br>
>> of the first pixel in the image, which means that they relate<br>
>> to a corner (not the center) of the image.<br>
>><br>
>> Please let us know,<br>
>><br>
>><br>
>> Thanks<br>
>><br>
>><br>
>> Luis<br>
>><br>
>><br>
>> ----------------<br>
>> jef vdmb wrote:<br>
>>> Hi,<br>
>>><br>
>>> 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<br>
>> e?<br>
>>><br>
>>> This is how I define the projection geometry:<br>
>>><br>
>>><br>
>>> focalpoint[0]= mIsoCenter[0] + mSourceToAxis;<br>
>>> focalpoint[1]= mIsoCenter[1];<br>
>>> focalpoint[2]= mIsoCenter[2];<br>
>>> interpolator->SetFocalPoint(focalpoint);<br>
>>><br>
>>> //projection in the YZ plane<br>
>>> originOutput[0] = mIsoCenter[0]- (mSourceToScreen - mSourceToAxis);<br>
>>> originOutput[1] = mIsoCenter[1]-(((double)sizeOuput[1]*spacingOutput[1])/2.);<br>
>>> originOutput[2] = mIsoCenter[2]-((double)sizeOuput[2]*spacingOutput[2]/2.);<br>
>>><br>
>>><br>
>>> a point in the image whith coordinates of the isocenter should be projected in the middle of output image right?<br>
>>><br>
>>><br>
>>> Thank you in advance for your help,<br>
>>> Jef<br>
>>> _________________________________________________________________<br>
>>> The other season of giving begins 6/24/08. Check out the i'm Talkathon.<br>
>>> <a href="http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving" target="_blank">http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving</a><br>
>>> _______________________________________________<br>
>>> Insight-users mailing list<br>
>>> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
>>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>>><br>
><br>
> _________________________________________________________________<br>
> Making the world a better place one message at a time.<br>
> <a href="http://www.imtalkathon.com/?source=EML_WLH_Talkathon_BetterPlace" target="_blank">http://www.imtalkathon.com/?source=EML_WLH_Talkathon_BetterPlace</a><br>
> _______________________________________________<br>
> Insight-users mailing list<br>
> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
</div></div>_________________________________________________________________<br>
Do more with your photos with Windows Live Photo Gallery.<br>
<a href="http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_photos_022008" target="_blank">http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_photos_022008</a></blockquote></div><br>