<div dir="ltr"><div class="gmail_default" style="font-size:small"><span style="font-family:verdana,sans-serif">You lack a </span><font face="monospace, monospace">reader->Update();</font><font face="verdana, sans-serif"> call before </font><font face="monospace, monospace">reader->GetOutput();</font><font face="verdana, sans-serif"> call. Without this the region passed to ThreadedDomainPartitioner is 0,0 which causes the exception.</font></div><div class="gmail_default" style="font-size:small"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style="font-size:small"><font face="verdana, sans-serif">Regards</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 8, 2016 at 11:28 AM, artioml <span dir="ltr"><<a href="mailto:artioml@post.bgu.ac.il" target="_blank">artioml@post.bgu.ac.il</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I want to calculate MSE between the red and the green channel of a given<br>
image.<br>
I have used an adapter as suggested in the examples section. But the metric<br>
throws an exception.<br>
<br>
What does the error mean? Anyone has an idea how to fix the problem? Thank<br>
you very much!<br>
<br>
Here is the error message:<br>
<br>
terminate called after throwing an instance of 'itk::ExceptionObject'<br>
  what():<br>
/home/art/SourceCode/InsightToolkit-4.8.2/Modules/Core/Common/include/itkDomainThreader.hxx:113:<br>
itk::ERROR:<br>
MeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader(0x1c32950): A<br>
subclass of ThreadedDomainPartitioner::PartitionDomainreturned more<br>
subdomains than were requested<br>
<br>
Here is the code:<br>
<br>
    typedef itk::RGBPixel<float>  InputPixelType;<br>
    const   unsigned int   Dimension = 2;<br>
    typedef itk::Image< InputPixelType, Dimension >   ImageType;<br>
<br>
    typedef itk::ImageAdaptor<  ImageType, RedChannelPixelAccessor ><br>
RedImageAdaptorType;<br>
    RedImageAdaptorType::Pointer red_adaptor = RedImageAdaptorType::New();<br>
    typedef itk::ImageAdaptor<  ImageType, GreenChannelPixelAccessor ><br>
GreenImageAdaptorType;<br>
    GreenImageAdaptorType::Pointer green_adaptor =<br>
GreenImageAdaptorType::New();<br>
<br>
    typedef itk::ImageFileReader< ImageType >   ReaderType;<br>
    ReaderType::Pointer reader = ReaderType::New();<br>
    reader->SetFileName( argv[1] );<br>
    ImageType::Pointer imageRGB = reader->GetOutput();<br>
<br>
    red_adaptor->SetImage( imageRGB );<br>
    green_adaptor->SetImage( imageRGB );<br>
<br>
    typedef itk::MeanSquaresImageToImageMetricv4< RedImageAdaptorType,<br>
GreenImageAdaptorType >    MetricType;<br>
    MetricType::Pointer metric = MetricType::New();<br>
<br>
    metric->SetFixedImage(red_adaptor);<br>
    metric->SetMovingImage(green_adaptor);<br>
    metric->SetMaximumNumberOfThreads(1);<br>
    metric->Initialize();<br>
    std::cout << "Result: " << metric->GetValue() << std::endl;<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-users.7.n7.nabble.com/Passing-adapters-to-a-metric-tp36755.html" rel="noreferrer" target="_blank">http://itk-users.7.n7.nabble.com/Passing-adapters-to-a-metric-tp36755.html</a><br>
Sent from the ITK - Users mailing list archive at Nabble.com.<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>