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

Dženan Zukić dzenanz at gmail.com
Tue Feb 9 10:47:55 EST 2016


You lack a reader->Update(); call before reader->GetOutput(); call. Without
this the region passed to ThreadedDomainPartitioner is 0,0 which causes the
exception.

Regards

On Mon, Feb 8, 2016 at 11:28 AM, artioml <artioml at post.bgu.ac.il> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160209/bf07cf80/attachment.html>
-------------- next part --------------
_____________________________________
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