<div dir="ltr">Hello. I tried to compute the normalized mutual information between two images, based on an example at <div><br><div><a href="http://itk.org/Wiki/ITK/Examples/Broken/ImageProcessing/MutualInformationImageToImageFilter">http://itk.org/Wiki/ITK/Examples/Broken/ImageProcessing/MutualInformationImageToImageFilter</a>.</div></div><div><br></div><div>I changed the example in order to compute the mutual information between two images and it worked fine, but when I changed from mutual information to normalized mutual information I get stuck at getting the value of normalized mutual information(last line in following code). To be precise, I get memory access violation, something that didn't happen with mutual informaion. Here is the code:</div><div><br></div><div><div>const    unsigned int    Dimension = 2;</div><div>  typedef  unsigned char   PixelType;</div><div><br></div><div>  typedef itk::Image< PixelType, Dimension >  FixedImageType;</div><div>  typedef itk::Image< PixelType, Dimension >  MovingImageType;</div><div><br></div><div>  typedef itk::CenteredRigid2DTransform< double > TransformType;</div><div><br></div><div>  </div><div>  typedef itk::LinearInterpolateImageFunction<</div><div>                                    MovingImageType,</div><div>                                    double             > InterpolatorType;</div><div>  </div><div><br></div><div>  typedef itk::NormalizedMutualInformationHistogramImageToImageMetric2<</div><div>                                          FixedImageType,</div><div>                                          MovingImageType >    MetricType;</div><div><br></div><div>  typedef itk::ImageFileReader<FixedImageType> FixedReaderType;</div><div>  typedef itk::ImageFileReader<MovingImageType> MovingReaderType;</div><div><br></div><div>  </div><div><br></div><div>  /*Read images*/</div><div><br></div><div>  FixedReaderType::Pointer fixedReader = FixedReaderType::New();</div><div>  MovingReaderType::Pointer movingReader = MovingReaderType::New();</div><div>  </div><div>  fixedReader->SetFileName(argv[1]);</div><div>  movingReader->SetFileName(argv[2]);</div><div><br></div><div>  fixedReader->Update();</div><div>  movingReader->Update();</div><div><br></div><div>  </div><div><br></div><div>  /*Set metric*/</div><div>  MetricType::Pointer metric = MetricType::New();</div><div><br></div><div>  metric->SetFixedImage(fixedReader->GetOutput());</div><div>  metric->SetMovingImage(movingReader->GetOutput());</div><div>  metric->SetFixedImageRegion(fixedReader->GetOutput()->GetLargestPossibleRegion());</div><div>  </div><div>  MetricType::HistogramType::SizeType h;</div><div>  h.SetSize(2);</div><div>  h[0] = h[1] = 128;</div><div>  metric->SetHistogramSize(h);</div><div><br></div><div>  //metric->SetNumberOfSpatialSamples(1000);</div><div><br></div><div>  InterpolatorType::Pointer interp = InterpolatorType::New();</div><div>  interp->SetInputImage(movingReader->GetOutput());</div><div>  metric->SetInterpolator(interp);</div><div><br></div><div>  MetricType::ScalesType scales;</div><div>  scales.Fill(1.0);</div><div>  metric->SetDerivativeStepLengthScales(scales);</div><div><br></div><div>  FixedImageType::SizeType s = fixedReader->GetOutput()->GetLargestPossibleRegion().GetSize();</div><div>  </div><div>  </div><div>  /*Set Transform*/</div><div>  double c[2];</div><div>  c[0] = (s[0] - 1.0) / 2.0;</div><div>  c[1] = (s[1] - 1.0) / 2.0;</div><div><br></div><div>  TransformType::Pointer transform = TransformType::New();</div><div>  metric->SetTransform(transform);</div><div>  transform->SetAngle(0.12);</div><div><br></div><div>  TransformType::TranslationType t;</div><div>  t[0] = t[1] = 10;</div><div>  transform->SetTranslation(t);</div><div>  transform->SetCenter(c);</div><div>  TransformType::ParametersType p;</div><div>  p.SetSize(5);</div><div>  p.Fill(0.0);</div><div>  std::cout << "transformation: " << p<< std::endl;</div><div>  std::cout << "Mutual Information: " << metric->GetValue(p) << std::endl;</div></div><div><br></div><div>What could be the problem?</div></div><div id="DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><table style="border-top:1px solid #aaabb6;margin-top:30px">
        <tr>
                <td style="width:105px;padding-top:15px">
                        <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/logo-avast-v1.png" style="width: 90px; height:33px;"></a>
                </td>
                <td style="width:470px;padding-top:20px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Το παρόν email στάλθηκε από ασφαλή υπολογιστή που προστατεύεται από το Avast. <br><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>                </td>
        </tr>
</table>
<a href="#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>