Skip to content

Suspicious for-while-loops in ParzenWindowMutualInformationImageToImageMetric #1443

@N-Dekker

Description

@N-Dekker

The following looks suspicious:

        for (unsigned int i = 0; i < nzji.size(); ++i)
        {
          while (imjacit != imageJacobian.end())
          {
            *imjacit *= *jacprecit;
            ++imjacit;
            ++jacprecit;
          }
        }

When the while loop is completely processed for the first time, imjacit will be at imageJacobian.end(), so the next for-loop iterations (for i > 0) won't do much anymore.

This very same code is encountered twice in itkParzenWindowMutualInformationImageToImageMetric.hxx, probably copy-and-pasted:

for (unsigned int i = 0; i < nzji.size(); ++i)
{
while (imjacit != imageJacobian.end())
{
*imjacit *= *jacprecit;
++imjacit;
++jacprecit;
}
}

for (unsigned int i = 0; i < nzji.size(); ++i)
{
while (imjacit != imageJacobian.end())
{
*imjacit *= *jacprecit;
++imjacit;
++jacprecit;
}
}

The for-while loop appears introduced by commit 1767cd3, May 22, 2009, at

for ( unsigned int i = 0; i < this->m_NonZeroJacobianIndices.size(); ++i )
while ( imjacit != imageJacobian.end() )
{
(*imjacit) *= (*jacprecit);
++imjacit;
++jacprecit;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions