<br>Hi Dženan<br><br>You may want to report this problem to <br>the OpenSceneGraph developers as well.<br><br>There might be a more stable way of computing<br>the Cos(angle) between two vectors.<br><br><br> Regards,<br>
<br><br> Luis<br><br><br>------------------------------------------------------<br><div class="gmail_quote">2010/6/17 Dženan Zukić <span dir="ltr"><<a href="mailto:dzenanz@gmail.com">dzenanz@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Luis,<br><br>vec1 and vec2 are osg::Vec3f classes from <a href="http://openscenegraph.org" target="_blank">openscenegraph.org</a>. And it occurs rarely, maybe once every few million executions.<br>
<br>Regards,<br>Dženan<br><br><div class="gmail_quote">
2010/6/17 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Dženan,<br><br>Thanks for sharing your findings.<br><br>This is quite interesting.<br><br>Did you log a bug entry for this problem ?<br><br>I'm trying to find the exact place with this<br>conversion of:<div>
<br><br><span style="font-family: courier new,monospace;">double cosFi=vec1*vec2/(vec1.length()*vec2.length());</span><br>
<br></div>Is this something that you found in ITK ?<br>or is this part or your application's code ?<br><br><br> Please let us know,<br><br><br> Thanks<br><br><br> Luis<br><br><br>------------------------------------------------------<br>
<div class="gmail_quote">2010/6/16 Dženan Zukić <span dir="ltr"><<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>></span><div><div></div><div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Luis,<br><br>I found out what the problem is.<br><br>The way I call evaluate is OK:<br><br><span style="font-family: courier new,monospace;">image->TransformPointFromPhysicalToContinouosIndex(p, ind, ok);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">if (ok)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> pixel=interpolator->EvaluateAtContinuousIndex(ind);</span><br>
<br>but my original point p had NaN values in it, which were caused by code which looked something like this:<br><br><span style="font-family: courier new,monospace;">double cosFi=vec1*vec2/(vec1.length()*vec2.length());<br>
//cosine of angle between vectors</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">p+=acos(cosFi)*...;</span><br><br>Due to numerical round-off errors it would rarely occur that cosFi>1 (something like 1.00000002534), and acos would produce NaN, which would then propagate all the way to poor interpolator which would then complain. Shortly after starting to use interpolator I also started using different sort of input files, which made my program do much more iterations of the above numerically unstable vector code and made manifestations of that problem more often.<br>
<br>Since the problem was manifesting itself in interpolator, and just before calling interpolator I was getting its input data from TransformPhysicalPointToContinuousIndex, and code for this transformation is very convoluted, I suspected it might be wrong and I had to ask.<br>
<br>I am also quite busy these last few weeks (I barely managed to find time to fix that bug which I adopted :D), so I soon forgot I asked this question, and of course didn't write that I found out the problem (which was quite far, in calculation of normals and curvatures of the mesh).<br>
<br>Thanks for the answer,<br>Dženan<br><br><div class="gmail_quote">2010/6/16 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span><div><div></div>
<div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Dženan,<br><br>We did quite a heavy testing when we fixed<br>the problem of centered pixel coordinates.<br><br>The Dashboard was green when we released<br>ITK 3.18, which give us some confidence on<br>the correctness of the code.<br>
<br>--<br><br>Please note that it is your responsibility to call<br><br> interpolator->IsInsideBuffer( point )<br><br>before you call<br><br> interpolator->Evaluate( point );<br><br><br>That is, your code should take the form:<br>
<br><br> if( interpolator->IsInsideBuffer( p1 ) )<br> {<br> p2 = interpolator->Evaluate( p1 );<br> }<br><br><br>--<br><br>If you still find run-time errors, please<br>post to the list a minimal code example<br>
that displays the problem.<br><br><br> Thanks<br><br><br> Luis<br><br><br>----------------------------------------------------------<br><div class="gmail_quote">2010/6/11 Dženan Zukić <span dir="ltr"><<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>Hi everyone,<div><br></div><div>I am running into some crashes in \InsightToolkit-3.18.0\Code\Common\itkLinearInterpolateImageFunction.txx (line 150), and I wonder could it be due to recent move to consistent use of centered pixels (physical coordinates going from -spacing/2 to (n-1)*spacing+spacing/2, instead of 0 to n*spacing). Did anyone have encounters with similar problems? More specifically, does TransformPhysicalPointToContinuousIndex in \InsightToolkit-3.18.0\Code\Common\itkImageBase.h honor the centered pixel coordinates?</div>
<div><br></div><div>Regards,</div><div>Dženan</div>
<br></div></div>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>
</blockquote></div></div></div><br>
</blockquote></div></div></div><br>
</blockquote></div></div></div><br>
</blockquote></div><br>