[Insight-users] Is it silly to attempt this ?
Emma Ryan
eryanvtk at yahoo.com
Sat Feb 23 22:50:29 EST 2008
Hello Luis,
Thank you for your reply. My image is 256 x 256 x 32. I have 512Mb ram. No computer does not seem to swapping memory.
I used .mha file instead of .vtk for the deformation field and it was quick and correct.
So, does the warper not accept .vtk files ? I tried to debug the code to see where the program takes forever and it seemed to be in the ImageFilereader (deformation field type)
The imageReader should expect a certain byte size and I am sure there are that many bytes in the file, so I'm not sure what the problem is.
Emma
----- Original Message ----
From: Luis Ibanez <luis.ibanez at kitware.com>
To: Emma Ryan <eryanvtk at yahoo.com>
Cc: insight-users at itk.org
Sent: Saturday, February 23, 2008 8:00:34 PM
Subject: Re: [Insight-users] Is it silly to attempt this ?
Hi
Emma,
The
source
code
that
you
posted
seems
to
be
reasonable.
However,
a
duration
of
2
hours
for
warping
an
image
sounds
like
an
excesive
time.
1)
How
big
is
your
image
?
pixels
along
X
pixels
along
Y
pixels
along
Z
2)
How
much
RAM
do
you
have
?
3)
Have
you
checked
if
your
computer
is
not
swapping
memory
?
(you
can
check
this
on
Windows
by
looking
at
the
Task
Manager,
or
in
Linux
by
using
the
top
tool,
or
the
system
information
tool.)
Please
let
us
know,
Thanks
Luis
----------------
Emma
Ryan
wrote:
>
Hi,
>
>
I
am
trying
to
read
in
a
3D
deformationField.vtk
file
and
apply
it
to
>
a
3D
image.
To
read
the
deformation
field,
I
use
ImageFileReader
>
<deformafieldType>
and
then
connect
the
output
of
this
to
the
warper.
>
>
The
code
for
this
is
available
below.
It
seems
to
take
forever
to
read
>
the
deformation
field
file.
Even
after
2
hours,
the
reading
is
not
>
complete.
What
is
going
on
?
Any
clues
?
>
>
Thanks,
>
Emma
>
>
>
#if
defined(_MSC_VER)
>
#pragma
warning
(
disable
:
4786
)
>
#endif
>
>
#include
"itkImageFileReader.h"
>
#include
"itkImageFileWriter.h"
>
>
#include
"itkImageRegionIterator.h"
>
>
>
#include
"itkCastImageFilter.h"
>
#include
"itkWarpImageFilter.h"
>
#include
"itkLinearInterpolateImageFunction.h"
>
>
#include
"itkSquaredDifferenceImageFilter.h"
>
#include
"itkCheckerBoardImageFilter.h"
>
#include
"itkTimeProbe.h"
>
>
#include
"itkImageRegionIteratorWithIndex.h"
>
#include
"itkPointSet.h"
>
#include
<fstream>
>
>
>
>
int
main(
int
argc,
char
*argv[]
)
>
{
>
if(
argc
<
4
)
>
{
>
std::cerr
<<
"Missing
Parameters
"
<<
std::endl;
>
std::cerr
<<
"Usage:
"
<<
argv[0];
>
std::cerr
<<
"
fixedImagefile
movingImageFile
deformField.vtk
";
>
std::cerr
<<
"
outputImageFile
"
<<
std::endl;
>
return
1;
>
}
>
>
>
const
unsigned
int
Dimension
=
3;
>
typedef
unsigned
char
PixelType;
>
>
>
typedef
itk::Image<
PixelType,
Dimension
>
FixedImageType;
>
typedef
itk::ImageFileReader<
FixedImageType
>
FixedImageReaderType;
>
FixedImageReaderType::Pointer
fixedImageReader
=
>
FixedImageReaderType::New();
>
fixedImageReader->SetFileName(
argv[1]
);
>
>
>
typedef
itk::Image<
PixelType,
Dimension
>
MovingImageType;
>
typedef
itk::ImageFileReader<
MovingImageType
>
MovingImageReaderType;
>
MovingImageReaderType::Pointer
movingImageReader
=
>
MovingImageReaderType::New();
>
movingImageReader->SetFileName(
argv[2]
);
>
>
typedef
itk::Vector<
float,
Dimension
>
VectorPixelType;
>
typedef
itk::Image<
VectorPixelType,
Dimension
>
DeformationFieldType;
>
>
typedef
itk::ImageFileReader<
DeformationFieldType
>
FieldReaderType;
>
FieldReaderType::Pointer
fieldReader
=
FieldReaderType::New();
>
>
fieldReader->SetFileName(
argv[3]
);
>
>
>
try
{
>
>
fieldReader->Update();
>
}
>
>
catch
(
itk::ExceptionObject
&
err
)
>
{
>
std::cerr
<<
"ExceptionObject
caught
!"
<<
std::endl;
>
std::cerr
<<
err
<<
std::endl;
>
return
-1;
>
}
>
>
>
>
typedef
itk::WarpImageFilter<MovingImageType,
>
MovingImageType,DeformationFieldType
>
WarperType;
>
typedef
itk::LinearInterpolateImageFunction<MovingImageType,
double
>
>
InterpolatorType;
>
WarperType::Pointer
warper
=
WarperType::New();
>
InterpolatorType::Pointer
interpolator
=
InterpolatorType::New();
>
FixedImageType::Pointer
fixedImage
=
fixedImageReader->GetOutput();
>
>
>
warper->SetInput(
movingImageReader->GetOutput()
);
>
warper->SetInterpolator(
interpolator
);
>
warper->SetOutputSpacing(
fixedImage->GetSpacing()
);
>
warper->SetOutputOrigin(
fixedImage->GetOrigin()
);
>
>
warper->SetDeformationField(
fieldReader->GetOutput()
);
>
>
>
typedef
unsigned
char
OutputPixelType;
>
typedef
itk::Image<
OutputPixelType,
Dimension
>
OutputImageType;
>
typedef
itk::CastImageFilter<
>
MovingImageType,
>
OutputImageType
>
CastFilterType;
>
typedef
itk::ImageFileWriter<
OutputImageType
>
WriterType;
>
>
>
WriterType::Pointer
writer
=
WriterType::New();
>
CastFilterType::Pointer
caster
=
CastFilterType::New();
>
>
writer->SetFileName(
argv[4]
);
>
>
>
caster->SetInput(
warper->GetOutput()
);
>
writer->SetInput(
caster->GetOutput()
);
>
writer->Update();
>
>
>
return
0;
>
}
>
>
>
>
------------------------------------------------------------------------
>
Looking
for
last
minute
shopping
deals?
Find
them
fast
with
Yahoo!
>
Search.
>
<http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
>
>
>
------------------------------------------------------------------------
>
>
_______________________________________________
>
Insight-users
mailing
list
>
Insight-users at itk.org
>
http://www.itk.org/mailman/listinfo/insight-users
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080223/a1cc768b/attachment.htm
More information about the Insight-users
mailing list