[ITK Community] [Insight-users] NthElement Image output
Bradley Lowekamp
brad at lowekamp.net
Tue Nov 5 19:40:19 EST 2013
Hello,
Adaptors are not compatible with the Readers and Writers. The memory layout just doesn't match.
You could use some filter to extract a component. The VectorIndexSelectionCastImageFilter should be able to do it for you.
http://www.itk.org/Doxygen/html/classitk_1_1VectorIndexSelectionCastImageFilter.html
Brad
On Nov 5, 2013, at 7:10 PM, jmerkow <jmerkow at gmail.com> wrote:
> I am trying to use the Nth Element Image Adapter to access the two different
> components of the gradient. The examples show how to access a single pixel,
> or pass it to a blur filter, but I am having some trouble figuring it out.
>
> Basically, what I want to do is read in some (2D) image find the gradient,
> write each component as an image (2 components)
>
> My code looks something like this:
>
> reader->SetFileName(inputFilename); // reader is <float,3>
> writer->SetFileName(outputFilename); // writer is <float,2>
> //extract a 2D slice
>
> typedef itk::ExtractImageFilter<
> IImageType,OImageType
>> ExtractType; // IImageType is <float,3>, MImageType is <float,2>
> extract->InPlaceOn();
> extract->SetDirectionCollapseToSubmatrix();
>
> IImageType::RegionType newRegion(start,size); // start and size are set
> correctly to get a 2D image (tested this first)
> extract->SetExtractionRegion(newRegion);
>
> typedef itk::GradientImageFilter<MImageType,float,float> GradientType;
> typedef GradientType::OutputImageType GradientOutputType;
> typedef itk::NthElementImageAdaptor<GradientOutputType,float>
> ImageAdaptorType;
>
>
> /*Pipeline*/
> extract->SetInput(reader->GetOutput()); // This may get changed
> grad->SetInput(extract->GetOutput());
> grad->Update();
> adaptor->SetImage(grad->GetOutput());
> adaptor->SelectNthElement(0);
>
>
> Here is where I am not sure what to do... I want to do something like:
>
> writer->SetInput(adaptor);
>
> Obviously, my types don't match up, because writer is typed with <float,2>
> and adapter is a <CovariantVector< float, 2>, 2>, but I thought
> SelectNthElement would select the first vector component. I am not sure how
> to access the x and y gradient seperately.
>
> Jameson
>
>
>
>
>
>
> --
> View this message in context: http://itk-users.7.n7.nabble.com/NthElement-Image-output-tp32683.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://www.itk.org/mailman/listinfo/insight-users
_____________________________________
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://www.itk.org/mailman/listinfo/insight-users
More information about the Community
mailing list