Skip to content

Commit

Permalink
BUG: Fix initializing FixedImageMarginalPDF with garbage
Browse files Browse the repository at this point in the history
MattesMutualInformationImageToImageMetricv4 gave wrong results
if number of work units changed, because FixedImageMarginalPDF
was initialized with values from previous iteration instead
of zeros.
  • Loading branch information
ozavalistyi authored and dzenanz committed May 5, 2021
1 parent de50d5d commit 0de9cfe
Showing 1 changed file with 7 additions and 13 deletions.
Expand Up @@ -55,12 +55,9 @@ MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader<
{
this->m_MattesAssociate->m_MovingImageMarginalPDF.resize(this->m_MattesAssociate->m_NumberOfHistogramBins, 0.0F);
}
else
{
std::fill(this->m_MattesAssociate->m_MovingImageMarginalPDF.begin(),
this->m_MattesAssociate->m_MovingImageMarginalPDF.end(),
PDFValueType{});
}
std::fill(this->m_MattesAssociate->m_MovingImageMarginalPDF.begin(),
this->m_MattesAssociate->m_MovingImageMarginalPDF.end(),
PDFValueType{});

const ThreadIdType mattesAssociateNumThreadsUsed = this->m_MattesAssociate->GetNumberOfWorkUnitsUsed();
const bool reinitializeThreaderFixedImageMarginalPDF =
Expand All @@ -71,14 +68,11 @@ MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader<
this->m_MattesAssociate->m_ThreaderFixedImageMarginalPDF.resize(
mattesAssociateNumThreadsUsed, std::vector<PDFValueType>(this->m_MattesAssociate->m_NumberOfHistogramBins, 0.0F));
}
else
for (ThreadIdType threadId = 0; threadId < mattesAssociateNumThreadsUsed; ++threadId)
{
for (ThreadIdType threadId = 0; threadId < mattesAssociateNumThreadsUsed; ++threadId)
{
std::fill(this->m_MattesAssociate->m_ThreaderFixedImageMarginalPDF[threadId].begin(),
this->m_MattesAssociate->m_ThreaderFixedImageMarginalPDF[threadId].end(),
PDFValueType{});
}
std::fill(this->m_MattesAssociate->m_ThreaderFixedImageMarginalPDF[threadId].begin(),
this->m_MattesAssociate->m_ThreaderFixedImageMarginalPDF[threadId].end(),
PDFValueType{});
}

const ThreadIdType localNumberOfWorkUnitsUsed = this->GetNumberOfWorkUnitsUsed();
Expand Down

0 comments on commit 0de9cfe

Please sign in to comment.