[Insight-developers] PathIterator choosing a step size that is too small?
Ho Cheung
hocheung20 at gmail.com
Fri Feb 24 18:29:28 EST 2012
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.
Here is the Debug call stack:
msvcp90d.dll!std::_Debug_message(const wchar_t *
message=0x000000014159a668, const wchar_t * file=0x000000014159a6b0,
unsigned int line=779) Line 24 C++
MicrogliaRegionTracer.exe!std::vector<itk::ContinuousIndex<double,3>,std::allocator<itk::ContinuousIndex<double,3>
> >::operator[](unsigned __int64 _Pos=2) Line 780 C++
MicrogliaRegionTracer.exe!itk::VectorContainer<unsigned
int,itk::ContinuousIndex<double,3> >::ElementAt(*unsigned int id=2*) Line
41 C++ *<--Array location 2 doesn't exist because I only have 2 vertices
*
MicrogliaRegionTracer.exe!itk::PolyLineParametricPath<3>::Evaluate(const
double & input=*0.99999999999999989*) Line 44 + 0x37 bytes C++
MicrogliaRegionTracer.exe!itk::ParametricPath<3>::EvaluateToIndex(const
double & input=0.99999999999999989) Line 43 + 0x26 bytes C++
MicrogliaRegionTracer.exe!itk::ParametricPath<3>::IncrementInput(double &
input=0.79999999999999993) Line 87 + 0x44 bytes C++
MicrogliaRegionTracer.exe!itk::PathConstIterator<itk::Image<float,3>,itk::PolyLineParametricPath<3>
>::operator++() Line 94 + 0x49 bytes C++
...
RelWithDebInfo:
...
MicrogliaRegionTracer.exe!itk::VectorContainer<unsigned
int,itk::ContinuousIndex<double,3> >::ElementAt(*unsigned int id=1309149262*)
Line 40 + 0x2e bytes C++
MicrogliaRegionTracer.exe!itk::PolyLineParametricPath<3>::Evaluate(const
double & input=) Line 44 + 0x1d bytes C++
MicrogliaRegionTracer.exe!itk::ParametricPath<3>::EvaluateToIndex(const
double & input=9.851802020072e-315#DEN) Line 43 + 0x11 bytes C++
MicrogliaRegionTracer.exe!itk::ParametricPath<3>::IncrementInput(double &
input=*2.658998863925e-314#DEN*) Line 87 + 0x2b bytes C++ *<-- DEN
results in ElementAt getting a nonsensical number*
MicrogliaRegionTracer.exe!itk::PathConstIterator<itk::Image<float,3>,itk::PolyLineParametricPath<3>
>::operator++() Line 94 + 0x19 bytes C++
...
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.
I believe the fix is to change line 38 from this:
if ( input >= InputType(m_VertexList->Size() - 1) )
to this:
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.
Regards,
Ho Cheung
Research Assistant
Bio-Image Analytics Lab - University of Houston
hocheung20 at gmail.com
Cell: (832) 215-6347
On Fri, Feb 24, 2012 at 3:59 PM, Ho Cheung <hocheung20 at gmail.com> wrote:
> Hi all,
>
> 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.
> Here is the relevant code:
>
>
> ImageType::IndexType node1 = cell->critical_points_queue[node_from];
> ImageType::IndexType node2 = cell->critical_points_queue[node_to];
>
> typedef itk::PolyLineParametricPath< 3 > PathType;
> PathType::Pointer path = PathType::New();
> path->Initialize();
>
> std::cout << "Start Index: " << start_index << " " << "End Index: " <<
> end_index << std::endl;
>
> path->AddVertex(node1);
> path->AddVertex(node2);
>
> typedef itk::PathConstIterator< VesselnessImageType, PathType >
> PathIteratorType;
> PathIteratorType path_iter(cell->vesselness_image, path);
>
> double sum_of_vesselness_values = 0;
> itk::uint64_t path_length = 0;
> path_iter.GoToBegin();
> while (!path_iter.IsAtEnd())
> {
> std::cout << "Path iterator position: " <<
> path_iter.GetPathPosition() << std::endl;
> std::cout << "Path iterator index: " << path_iter.GetIndex() <<
> std::endl;
> sum_of_vesselness_values += path_iter.Get();
> ++path_iter;
> }
>
>
> And here is the relevant output:
>
> Start Index: [100, 81, 17] End Index: [114, 81, 17]
> Path iterator position: 0
> Path iterator index: [100, 81, 17]
> Path iterator position: 0.0888889
> Path iterator index: [101, 81, 17]
> Path iterator position: 0.177778
> Path iterator index: [102, 81, 17]
> Path iterator position: 0.237037
> Path iterator index: [103, 81, 17]
> Path iterator position: 0.296296
> Path iterator index: [104, 81, 17]
> Path iterator position: 0.385185
> Path iterator index: [105, 81, 17]
> Path iterator position: 0.444444
> Path iterator index: [106, 81, 17]
> Path iterator position: 0.533333
> Path iterator index: [107, 81, 17]
> Path iterator position: 0.592593
> Path iterator index: [108, 81, 17]
> Path iterator position: 0.651852
> Path iterator index: [109, 81, 17]
> Path iterator position: 0.740741
> Path iterator index: [110, 81, 17]
> Path iterator position: 0.8
> Path iterator index: [111, 81, 17]
> <Crash>
>
> Thanks,
>
> Ho Cheung
> Research Assistant
> Bio-Image Analytics Lab - University of Houston
> hocheung20 at gmail.com
> Cell: (832) 215-6347
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20120224/34cd0a21/attachment.htm>
More information about the Insight-developers
mailing list