[Insight-developers] Bug in Code/Review/itkOptImageToImageMetric.txx?

Luis Ibanez luis.ibanez at kitware.com
Wed Jun 10 12:57:56 EDT 2009


Hi Kent,

The number of fixed samples is updated according the number
of pixels inside the (potential) fixed image mask in lines: 454-513,

more specifically in 467-472

  if ( count > maxcount || randIter.IsAtEnd() )
        {
        m_NumberOfFixedImageSamples = samples_found;
        samples.resize(samples_found);
        break;
        }


but... of course... it is always possible that there is a bug
and we missed some combination of circumstances.


Any chance that we could reduce this to a minimal case ?


E.g. I would think in taking one of the examples in
Insight/Examples/Registration and adding a Mask to it,
so that we can reproduce this in a small test case.

I'll be happy to help setting this up.



BTW: In your case are us using AllPixels or are you
letting the Metric subsample the image ?

Depending on that, the code will take two different paths.


    Thanks


          Luis


--------------------------------------------------------------------------------------------------
On Wed, Jun 10, 2009 at 12:27 PM, kent williams <norman-k-williams at uiowa.edu
> wrote:

> We ran into a problem that Hans could probably explain better than I: We
> are
> getting core dumps in itkOptImageToImageMetric.txx.
>
> The problem is that there is a member array m_BSplineTransformWeightsArray,
> that gets sized based on m_NumberOfFixedImageSamples and
> m_NumBSplineWeights.  It's getting allocated (in our case to 10,000
> samples), but when it gets filled in (in PreComputeTransformValues()),
> every
> element is not set -- some are left with a value of zero or some random
> value.
>
> I think the problem is that the iteration over weights doesn't take into
> account the reduced actual sample count due to using masks.
>
>
>      if(sampleOk)
>        {
>        // If the transform is BSplineDeformable, we can use the precomputed
>        // weights and indices to obtained the mapped position
>        const WeightsValueType * weights =       if(sampleOk)
>        {
>        // If the transform is BSplineDeformable, we can use the precomputed
>        // weights and indices to obtained the mapped position
>        const WeightsValueType * weights =
>
> m_BSplineTransformWeightsArray[sampleNumber];
>        const IndexValueType   * indices =
>
> m_BSplineTransformIndicesArray[sampleNumber];
>
>        for( unsigned int j = 0; j < FixedImageDimension; j++ )
>          {
>          mappedPoint[j] =
> m_BSplinePreTransformPointsArray[sampleNumber][j];
>          }
>
>        for ( unsigned int k = 0; k < m_NumBSplineWeights; k++ )
>          {
>          for ( unsigned int j = 0; j < FixedImageDimension; j++ )
>            {
> //CRASHES HERE line 908
>            mappedPoint[j] += weights[k] * m_Parameters[ indices[k]
>                              + m_BSplineParametersOffset[j] ];
>            }
>          }
>        }
>      }
>
>
> m_BSplineTransformWeightsArray[sampleNumber];
>        const IndexValueType   * indices =
>
> m_BSplineTransformIndicesArray[sampleNumber];
>
>        for( unsigned int j = 0; j < FixedImageDimension; j++ )
>          {
>          mappedPoint[j] =
> m_BSplinePreTransformPointsArray[sampleNumber][j];
>          }
>
>        for ( unsigned int k = 0; k < m_NumBSplineWeights; k++ )
>          {
>          for ( unsigned int j = 0; j < FixedImageDimension; j++ )
>            {
>            mappedPoint[j] += weights[k] * m_Parameters[ indices[k]
>                                                 +
> m_BSplineParametersOffset[j] ];
>            }
>          }
>        }
>      }
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090610/5e3a4079/attachment.htm>


More information about the Insight-developers mailing list