[ITK] [ITK-users] Passing adapters to a metric

artioml artioml at post.bgu.ac.il
Mon Feb 8 11:28:58 EST 2016


Hello, 

I want to calculate MSE between the red and the green channel of a given
image. 
I have used an adapter as suggested in the examples section. But the metric
throws an exception. 

What does the error mean? Anyone has an idea how to fix the problem? Thank
you very much! 

Here is the error message: 

terminate called after throwing an instance of 'itk::ExceptionObject' 
  what(): 
/home/art/SourceCode/InsightToolkit-4.8.2/Modules/Core/Common/include/itkDomainThreader.hxx:113: 
itk::ERROR:
MeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader(0x1c32950): A
subclass of ThreadedDomainPartitioner::PartitionDomainreturned more
subdomains than were requested 

Here is the code: 

    typedef itk::RGBPixel<float>  InputPixelType; 
    const   unsigned int   Dimension = 2; 
    typedef itk::Image< InputPixelType, Dimension >   ImageType; 

    typedef itk::ImageAdaptor<  ImageType, RedChannelPixelAccessor >
RedImageAdaptorType; 
    RedImageAdaptorType::Pointer red_adaptor = RedImageAdaptorType::New(); 
    typedef itk::ImageAdaptor<  ImageType, GreenChannelPixelAccessor >
GreenImageAdaptorType; 
    GreenImageAdaptorType::Pointer green_adaptor =
GreenImageAdaptorType::New(); 

    typedef itk::ImageFileReader< ImageType >   ReaderType; 
    ReaderType::Pointer reader = ReaderType::New(); 
    reader->SetFileName( argv[1] ); 
    ImageType::Pointer imageRGB = reader->GetOutput(); 

    red_adaptor->SetImage( imageRGB ); 
    green_adaptor->SetImage( imageRGB ); 

    typedef itk::MeanSquaresImageToImageMetricv4< RedImageAdaptorType,
GreenImageAdaptorType >    MetricType; 
    MetricType::Pointer metric = MetricType::New(); 

    metric->SetFixedImage(red_adaptor); 
    metric->SetMovingImage(green_adaptor); 
    metric->SetMaximumNumberOfThreads(1); 
    metric->Initialize(); 
    std::cout << "Result: " << metric->GetValue() << std::endl;



--
View this message in context: http://itk-users.7.n7.nabble.com/Passing-adapters-to-a-metric-tp36755.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list