[Insight-users] How long does it take do you think ?
tony hakki
tony2007vtk at yahoo.com
Sat Mar 31 04:40:34 EST 2007
Dear Luis
Here is my code,what might the wrong ?According to me everything is OK. Could you please have a look at his for me. This is really important for me.
//-----------------------------------------------------------
// Set up a Transform
//-----------------------------------------------------------
typedef itk::QuaternionRigidTransform< double > TransformType;
TransformType::Pointer transform = TransformType::New();
typedef MovingImageType::SpacingType SpacingType;
typedef MovingImageType::PointType OriginType;
typedef MovingImageType::RegionType RegionType;
typedef MovingImageType::SizeType SizeType;
const OriginType movingOrigin = input->GetOrigin();
const RegionType movingRegion = input->GetLargestPossibleRegion();
const SizeType movingSize = movingRegion.GetSize();
const SpacingType movingSpacing = input->GetSpacing();
TransformType::InputPointType centerMoving;
centerMoving[0] = movingOrigin[0] + movingSpacing[0] * movingSize[0] / 2.0;
centerMoving[1] = movingOrigin[1] + movingSpacing[1] * movingSize[1] / 2.0;
centerMoving[2] = movingOrigin[2] + movingSpacing[2] * movingSize[1] / 2.0;
TransformType::InputPointType centerFixed;
centerFixed[0] = 14.7947 ;
centerFixed[1] =-1.48122;
centerFixed[2] =2.43377;
transform->SetCenter(centerFixed);
transform->SetTranslation( centerMoving - centerFixed );
//------------------------------------------------------------
// Optimizer Type
//-----------------------------------------------------------
typedef itk::QuaternionRigidTransformGradientDescentOptimizer OptimizerType;
OptimizerType::Pointer optimizer = OptimizerType::New();
//------------------------------------------------------------
// Set up an Interpolator
//------------------------------------------------------------
typedef itk::LinearInterpolateImageFunction<
MovingImageType,
double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
//-----------------------------------------------------------
// Set up Metric
//-----------------------------------------------------------
typedef itk::NormalizedCorrelationPointSetToImageMetric<
FixedPointSetType,
MovingImageType > MetricType;
typedef MetricType::TransformType TransformBaseType;
typedef TransformBaseType::ParametersType ParametersType;
MetricType::Pointer metric = MetricType::New();
//-----------------------------------------------------------
//RegistrationMethod
//-----------------------------------------------------------
typedef itk::PointSetToImageRegistrationMethod<
FixedPointSetType,
MovingImageType > RegistrationType;
RegistrationType::Pointer registrationMethod = RegistrationType::New();
typedef itk::CommandIterationUpdate<
OptimizerType > CommandIterationType;
// Instantiate an Observer to report the progress of the Optimization
CommandIterationType::Pointer iterationCommand = CommandIterationType::New();
iterationCommand->SetOptimizer( optimizer.GetPointer() );
// Scale the translation components of the Transform in the Optimizer
OptimizerType::ScalesType scales( transform->GetNumberOfParameters() );
scales.Fill( 1.0 );
int j;
for ( j = 4; j < 7; j++ )
{
scales[j] = 0.0001;
}
unsigned long numberOfIterations = 1000000;
optimizer->SetScales( scales );
optimizer->SetNumberOfIterations( numberOfIterations );
optimizer->MinimizeOn();
// can probably provide a better guess than the identity...
transform->SetIdentity();
registrationMethod->SetInitialTransformParameters( transform->GetParameters() );
RegistrationType::ParametersType initialParameters(
transform->GetNumberOfParameters() );
initialParameters.Fill( 0.0 );
initialParameters[3] = 1.0;
// Connect all the components required for Registration
//------------------------------------------------------
registrationMethod->SetMetric( metric );
registrationMethod->SetOptimizer( optimizer );
registrationMethod->SetFixedPointSet(pointSet);
registrationMethod->SetMovingImage(input);
registrationMethod->SetInterpolator(interpolator);
registrationMethod->SetTransform( transform );
//------------------------------------------------------------
// Set up transform parameters
//------------------------------------------------------------
ParametersType parameters( transform->GetNumberOfParameters() );
// initialize the offset/vector part
for( unsigned int k = 0; k <Dimension; k++ )
{
parameters[k]= 0.0f;
}
try
{
registrationMethod->SetInitialTransformParameters( initialParameters );
registrationMethod->StartRegistration();
}
catch( itk::ExceptionObject & e )
{
std::cout << e << std::endl;
}
OptimizerType::ParametersType finalParameters =registrationMethod->GetLastTransformParameters();
const unsigned int nmbrOfIterations = optimizer->GetCurrentIteration();
const double bestValue = optimizer->GetValue();
transform->SetParameters( finalParameters );
----- Original Message ----
From: Luis Ibanez <luis.ibanez at kitware.com>
To: tony hakki <tony2007vtk at yahoo.com>
Cc: Robert Tamburo <rjtst21 at pitt.edu>; insight-users at itk.org
Sent: Friday, March 30, 2007 6:56:17 PM
Subject: Re: [Insight-users] How long does it take do you think ?
Hi Tony,
A well tunned registration process should take less than
500 iterations in a Gradient-Descent type of optimizer.
If it takes longer than 500 iterations,
then it means that:
a) Your have a poor initialization, or
b) The step length (or learning rate) are too small.
If you were registering images of sizes 512 x 512 x 200, that should
probably should take between 2 minutes and 20 minutes in a modern
computer.
If you are doing PointSet registration, and your point sets have around
25,000 points, then it should take about 20 minutes to register them
using ICP (in a modern computer).
You will find easier to monitor the registration process is you add
a visualization of the point sets using VTK, to the command observer
of the registration.
Regards,
Luis
-------------------
tony hakki wrote:
> you are generally right, but in this algorithm when optimizer finds the
> best results it will be stoped by program not to wait 900 million
> iterations . I didn't think that it would need 900 million iterations. I
> thought at the beginning just assign 900 million any how it would not
> need 900 million iterations. It has been still runnning :((
>
> ----- Original Message ----
> From: Robert Tamburo <rjtst21 at pitt.edu>
> To: tony hakki <tony2007vtk at yahoo.com>
> Cc: insight-users at itk.org
> Sent: Friday, March 30, 2007 4:39:08 PM
> Subject: Re: [Insight-users] How long does it take do you think ?
>
> I've never used this algorithm but 900 million iterations seems like
> insanity. Assume that each iteration takes either 1 millisecond (best
> case scenario?) or 1 second (worst case scenario?) then calculate how
> long 900 million iterations will take. You will probably want to rethink
> the number of iterations you're using. You may also want to set up a
> convergence criteria to stop the registration. You may find that you
> only need a handful iterations to achieve acceptable results.
>
> On Mar 30, 2007, at 3:34 AM, tony hakki wrote:
>
>> hello ;
>> I have tried to implement point set to image registration. My point
>> set has 151 points(x,y,z),and the image 3D .raw image size is
>> size = 329 527 181 and the resolution is res= 0.200068 0.200068
>> 0.200068 .Is there anybody who is expert on registration process to
>> guess how long does computer run to finish registration process? my
>> computer has 2.21 GHz processor, and 3 GB Ram . I assigned
>> numberofiteration as 900.000.000 (900 million) and my computer has
>> been runnning for 20 hours(yes ,20 hours:))),do you think this is normal?
>> Thanks
>> Tony
>>
>> ------------------------------------------------------------------------
>> Sucker-punch spam
>> <http://us.rd.yahoo.com/evt=49981/*http://advision.webevents.yahoo.com/mailbeta/features_spam.html>
>> with award-winning protection.
>> Try the free Yahoo! Mail Beta.
>> <http://us.rd.yahoo.com/evt=49981/*http://advision.webevents.yahoo.com/mailbeta/features_spam.html>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org <mailto:Insight-users at itk.org>
>> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
>
> ------------------------------------------------------------------------
> We won't tell. Get more on shows you hate to love
> <http://us.rd.yahoo.com/evt=49980/*http://tv.yahoo.com/collections/265 >
> (and love to hate): Yahoo! TV's Guilty Pleasures list.
> <http://us.rd.yahoo.com/evt=49980/*http://tv.yahoo.com/collections/265 >
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
____________________________________________________________________________________
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070331/cc00c03e/attachment.html
More information about the Insight-users
mailing list