It seems that using == to compare FP numbers for equality leads to disaster. Also, compounding the problem is that FP behavior apparently deviates between RelWithDebInfo and Debug modes. The previous message that I sent was run in RelWithDebInfo.<br>
<br>Here is the Debug call stack:<br><br> msvcp90d.dll!std::_Debug_message(const wchar_t * message=0x000000014159a668, const wchar_t * file=0x000000014159a6b0, unsigned int line=779) Line 24 C++<br> MicrogliaRegionTracer.exe!std::vector<itk::ContinuousIndex<double,3>,std::allocator<itk::ContinuousIndex<double,3> > >::operator[](unsigned __int64 _Pos=2) Line 780 C++<br>
MicrogliaRegionTracer.exe!itk::VectorContainer<unsigned int,itk::ContinuousIndex<double,3> >::ElementAt(<b>unsigned int id=2</b>) Line 41 C++ <b><--Array location 2 doesn't exist because I only have 2 vertices</b><br>
MicrogliaRegionTracer.exe!itk::PolyLineParametricPath<3>::Evaluate(const double & input=<b>0.99999999999999989</b>) Line 44 + 0x37 bytes C++<br> MicrogliaRegionTracer.exe!itk::ParametricPath<3>::EvaluateToIndex(const double & input=0.99999999999999989) Line 43 + 0x26 bytes C++<br>
MicrogliaRegionTracer.exe!itk::ParametricPath<3>::IncrementInput(double & input=0.79999999999999993) Line 87 + 0x44 bytes C++<br> MicrogliaRegionTracer.exe!itk::PathConstIterator<itk::Image<float,3>,itk::PolyLineParametricPath<3> >::operator++() Line 94 + 0x49 bytes C++<br>
...<br><br>RelWithDebInfo:<br><br>...<br> MicrogliaRegionTracer.exe!itk::VectorContainer<unsigned int,itk::ContinuousIndex<double,3> >::ElementAt(<b>unsigned int id=1309149262</b>) Line 40 + 0x2e bytes C++<br>
MicrogliaRegionTracer.exe!itk::PolyLineParametricPath<3>::Evaluate(const double & input=) Line 44 + 0x1d bytes C++<br> MicrogliaRegionTracer.exe!itk::ParametricPath<3>::EvaluateToIndex(const double & input=9.851802020072e-315#DEN) Line 43 + 0x11 bytes C++<br>
MicrogliaRegionTracer.exe!itk::ParametricPath<3>::IncrementInput(double & input=<b>2.658998863925e-314#DEN</b>) Line 87 + 0x2b bytes C++ <b><-- DEN results in ElementAt getting a nonsensical number</b><br>
MicrogliaRegionTracer.exe!itk::PathConstIterator<itk::Image<float,3>,itk::PolyLineParametricPath<3> >::operator++() Line 94 + 0x19 bytes C++<br>...<br><br>The problem is that at itkPolyLineParametricPath.hxx:38: The input was
0.99999999999999989, which should have become 1 and then the check at 38 to see if this was the last vertex
should have gone through and returned the last index.<br><br>I believe the fix is to change line 38 from this:<br><br> if ( input >= InputType(m_VertexList->Size() - 1) )<br><br>to this:<br><br> if ( input >= InputType(m_VertexList->Size() - 1) - 0.0001 ) //Basically 0.0001 needs to be significantly bigger than the precision of InputType not so large to introduce errors into the check.<br>
<br><br>Regards,<br clear="all"><br>Ho Cheung<br>Research Assistant<br>Bio-Image Analytics Lab - University of Houston<br><a href="mailto:hocheung20@gmail.com" target="_blank">hocheung20@gmail.com</a><br>Cell: (832) 215-6347<br>
<br><br><div class="gmail_quote">On Fri, Feb 24, 2012 at 3:59 PM, Ho Cheung <span dir="ltr"><<a href="mailto:hocheung20@gmail.com">hocheung20@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br><br>I am currently using a PathIterator to try to move through some pixels between two indices. My iterator moves successfully most of the way and then decides to calculate a very small step size, so small that it becomes #DEN when I look at it with the debugger.<br>
Here is the relevant code:<br><br><br> ImageType::IndexType node1 = cell->critical_points_queue[node_from];<br> ImageType::IndexType node2 = cell->critical_points_queue[node_to];<br><br> typedef itk::PolyLineParametricPath< 3 > PathType;<br>
PathType::Pointer path = PathType::New();<br> path->Initialize();<br><br> std::cout << "Start Index: " << start_index << " " << "End Index: " << end_index << std::endl;<br>
<br> path->AddVertex(node1);<br> path->AddVertex(node2);<br><br> typedef itk::PathConstIterator< VesselnessImageType, PathType > PathIteratorType;<br> PathIteratorType path_iter(cell->vesselness_image, path);<br>
<br> double sum_of_vesselness_values = 0;<br> itk::uint64_t path_length = 0;<br> path_iter.GoToBegin();<br> while (!path_iter.IsAtEnd())<br> {<br> std::cout << "Path iterator position: " << path_iter.GetPathPosition() << std::endl;<br>
std::cout << "Path iterator index: " << path_iter.GetIndex() << std::endl;<br> sum_of_vesselness_values += path_iter.Get();<br> ++path_iter;<br> }<br><br><br>And here is the relevant output:<br>
<br>Start Index: [100, 81, 17] End Index: [114, 81, 17]<br>Path iterator position: 0<br>Path iterator index: [100, 81, 17]<br>Path iterator position: 0.0888889<br>Path iterator index: [101, 81, 17]<br>Path iterator position: 0.177778<br>
Path iterator index: [102, 81, 17]<br>Path iterator position: 0.237037<br>Path iterator index: [103, 81, 17]<br>Path iterator position: 0.296296<br>Path iterator index: [104, 81, 17]<br>Path iterator position: 0.385185<br>
Path iterator index: [105, 81, 17]<br>Path iterator position: 0.444444<br>Path iterator index: [106, 81, 17]<br>Path iterator position: 0.533333<br>Path iterator index: [107, 81, 17]<br>Path iterator position: 0.592593<br>
Path iterator index: [108, 81, 17]<br>Path iterator position: 0.651852<br>Path iterator index: [109, 81, 17]<br>Path iterator position: 0.740741<br>Path iterator index: [110, 81, 17]<br>Path iterator position: 0.8<br>Path iterator index: [111, 81, 17]<br>
<Crash><br><br>Thanks,<br><br clear="all">Ho Cheung<br>Research Assistant<br>Bio-Image Analytics Lab - University of Houston<br><a href="mailto:hocheung20@gmail.com" target="_blank">hocheung20@gmail.com</a><br>Cell: <a href="tel:%28832%29%20215-6347" value="+18322156347" target="_blank">(832) 215-6347</a><br>
</blockquote></div><br>