[Insight-users] Get and Set itk Origin
jef vdmb
jvdmb at hotmail.com
Tue Sep 15 09:03:10 EDT 2009
I included some code (used in a templated function) to clarify my question:
// ImageTypes
typedef itk::Image<PixelType, Dimension> InputImageType;
// Read
typedef itk::ImageFileReader<InputImageType> InputReaderType;
typename InputReaderType::Pointer reader = InputReaderType::New();
reader->SetFileName( m_InputFileName);
reader->Update();
typename InputImageType::Pointer input= reader->GetOutput();
std::cout<<"Input Origin is "<<input->GetOrigin()<<std::endl;
// Filter
typedef itk::MirrorPadImageFilter<InputImageType, InputImageType> MirrorPadImageFilterType;
typename MirrorPadImageFilterType::Pointer mirrorFilter=MirrorPadImageFilterType::New();
mirrorFilter->SetInput(input);
typename InputImageType::SizeType size;
size.Fill(10);
mirrorFilter->SetPadLowerBound(size);
mirrorFilter->Update();
// Output
typename InputImageType::Pointer output=mirrorFilter->GetOutput();
std::cout<<"Output Origin is "<<output->GetOrigin()<<std::endl;
output->Update();
std::cout<<"Output Origin is "<<output->GetOrigin()<<std::endl;
// Write
typedef itk::ImageFileWriter<InputImageType> WriterType;
typename WriterType::Pointer writer = WriterType::New();
writer->SetFileName(m_ArgsInfo.output_arg);
writer->SetInput(output);
writer->Update();
Output of this piece of code is
Input Origin is [0, 0, -282]
Output Origin is [0, 0, -282]
Output Origin is [0, 0, -282]
However the written output has header file:
ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1 0 0 0 1 0 0 0 1
Offset = -20 -20 -302
CenterOfRotation = 0 0 0
AnatomicalOrientation = RAI
ElementSpacing = 2 2 2
DimSize = 245 186 292
ElementType = MET_FLOAT
ElementDataFile = air_padded.raw
In this header, the origin HAS changed according to the padding size at the lower end?
Thank you in advance for your help,
Jef
> Date: Tue, 15 Sep 2009 08:22:50 -0400
> Subject: Re: [Insight-users] Get and Set itk Origin
> From: bill.lorensen at gmail.com
Send
> To: jvdmb at hotmail.com
> CC: insight-users at itk.org
>
> Maybe you should post some code. What you describe should work.
>
> Bill
>
> On Tue, Sep 15, 2009 at 5:32 AM, jef vdmb <jvdmb at hotmail.com> wrote:
> > Hi,
> >
> > I am having a hard time understanding the way meta data like the image
> > origin is updated after a pipeline execution.
> >
> > My situation is the following:
> >
> > * an image is read
> > * next passed as input to a filter (in this case MirrorPadImageFilter, but I
> > have seen it for others as well)
> > * the filter is updated (->Update());
> > * the output retrieved using ->GetOutput()
> >
> > The initial input had origin (0,0,0). The output however should have an
> > origin different from zero (with the parameters I used for the
> > MirrorPadImageFilter). When the output is interrogated for its origin
> > (->GetOrigin() ), it (wrongly) shows all zeros. When writing the image
> > afterwards, it was written with the correct origin ( offset field of the
> > .mhd image format).
> >
> > It would seem my output image is not yet updated at the time I performed the
> > ->GetOrigin(). The last filter was however explicitly updated just before
> > and even an "->Update()" on the output image itself doesn't modify this
> > behaviour.
> >
> > I would like to retrieve the origin for further processing but seem to end
> > up with the uninitialized (0,0,0). I would appreciate any suggestions on
> > how to assure the meta information is fully updated.
> >
> > Regards,
> > Jef
> >
> >
> >
> > ________________________________
> > Hotmail: Powerful Free email with security by Microsoft. Get it now.
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > 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
> >
> >
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/171222985/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090915/db57432b/attachment.htm>
More information about the Insight-users
mailing list