[Insight-users] NthElement Image output

jmerkow jmerkow at gmail.com
Tue Nov 5 19:10:55 EST 2013


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&lt; 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.


More information about the Insight-users mailing list