[Insight-users] On Metrics of registration
cspl
affable at hd2 . dot . net . in
Mon, 26 Aug 2002 14:27:30 +0530
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01C24D0C.B60125B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Dear Mr.Luis,
I am working on itkImageRegistration with different metric classes as =
metrics for registration.I could get the output with =
itkMutualInformationImageToImageMetric class.But,I am getting error when =
i used itkNormalizedCorrelationImageToImageMetric and =
itkMeanSquaresImageToImageMetric.I found that some classes like =
setFixedImagestandarddeviation,setNumberOfSamples etc are not available =
in Normal and meansquares.I am getting problem at startregistration().I =
am unable to catch the exception using try and catch.I am getting some =
memory exception.I am enclosing code.
--------code---------
//Check for registration type
if(RegType=3D=3D0)
{
Flag=3Dfalse;
typedef itk::MeanSquaresImageToImageMetric<ImageType,ImageType> =
MetricType; MetricType::Pointer metric =3D =
MetricType::New();
AfxMessageBox("mean squares");
registration->SetMetric(metric);
}
else if (RegType=3D=3D1)
{
typedef itk::NormalizedCorrelationImageToImageMetric<ImageType, =
ImageType> MetricType; =20
MetricType::Pointer metric =3D MetricType::New();
/*metric->SetFixedImageRegion(FixedImage->GetBufferedRegion());
metric->SetScaleGradient( 1.0 );*/
registration->SetMetric(metric);
Flag=3Dfalse;
}
else if (RegType=3D=3D2)
{
typedef itk::MutualInformationImageToImageMetric<ImageType, ImageType> =
MetricType; =20
MetricType::Pointer metric =3D MetricType::New();
metric->SetMovingImageStandardDeviation( 2 );
metric->SetFixedImageStandardDeviation( 2 );
metric->SetNumberOfSpatialSamples( 50 );=20
registration->SetMetric(metric);
Flag=3Dfalse;
}=20
else
{ =20
Flag=3Dtrue;
}
=20
=20
typedef itk::QuaternionRigidTransform<double> TransformType;
typedef itk::QuaternionRigidTransformGradientDescentOptimizer =
OptimizerType; =20
typedef itk::LinearInterpolateImageFunction<ImageType, double> =
InterpolatorType;
=20
TransformType::Pointer transform =3D TransformType::New(); =
OptimizerType::Pointer optimizer =3D OptimizerType::New();
InterpolatorType::Pointer interpolator =3D InterpolatorType::New();
=20
=20
RegistrationType1::ParametersType =
guess(transform->GetNumberOfParameters() );
=20
guess[0] =3D 0.0;
guess[1] =3D 0.0;
guess[2] =3D 0.0;
guess[3] =3D 1.0;
guess[4] =3D 1.0;
guess[5] =3D 1.0;
guess[6] =3D 0.0;
=20
registration->SetInitialTransformParameters (guess); =20
=20
// Set translation scale
typedef OptimizerType::ScalesType ScaleType;
ScaleType scales(transform->GetNumberOfParameters());
scales.Fill( 1.0 );
for( unsigned j =3D 4; j < 7; j++ )
{
scales[j] =3D 1.0 / vnl_math_sqr(1000.0);
}
=20
=20
//Scale parameters=20
optimizer->SetNumberOfIterations(1000);
optimizer->SetLearningRate( 0.0000001 ); =20
=20
// Setup the optimizer
optimizer->SetScales(scales);
// optimizer->MaximizeOn();
=20
//set registration parameters
=20
registration->SetOptimizer(optimizer);
registration->SetTransform(transform);
registration->SetInterpolator(interpolator);
registration->SetFixedImage(FixedImage);
registration->SetMovingImage(MovingImage);
registration->DebugOn();
=20
try
{
registration->StartRegistration();
}
catch(itk::ExceptionObject &except)
{ =20
std::cerr<<"Exception"<<except.GetDescription();
=20
=20
}
=20
Regards,
CSPL
------=_NextPart_000_000C_01C24D0C.B60125B0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Dear Mr.Luis,<BR> I am working on=20
itkImageRegistration with different metric classes as metrics for =
registration.I=20
could get the output with itkMutualInformationImageToImageMetric =
class.But,I am=20
getting error when i used itkNormalizedCorrelationImageToImageMetric and =
itkMeanSquaresImageToImageMetric.I found that some classes like=20
setFixedImagestandarddeviation,setNumberOfSamples etc are not available =
in=20
Normal and meansquares.I am getting problem at startregistration().I am =
unable=20
to catch the exception using try and catch.I am getting some memory =
exception.I=20
am enclosing code.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV><FONT face=3DArial =
size=3D2>
<DIV><BR>--------code---------<BR> //Check for registration=20
type<BR> if(RegType=3D=3D0)<BR> {<BR> Flag=3Dfalse;<BR>typ=
edef=20
itk::MeanSquaresImageToImageMetric<ImageType,ImageType>=20
MetricType; =20
MetricType::Pointer =
=20
metric =3D =
MetricType::New();<BR> AfxMessageBox("mean=20
squares");<BR> registration->SetMetric(metric);<BR> }<=
BR> else=20
if (RegType=3D=3D1)<BR> {<BR>typedef=20
itk::NormalizedCorrelationImageToImageMetric<ImageType, ImageType=
>=20
MetricType; <BR> =20
MetricType::Pointer =
metric =3D=20
MetricType::New();<BR>/*metric->SetFixedImageRegion(FixedImage->Get=
BufferedRegion());<BR> =20
metric->SetScaleGradient( 1.0 );*/<BR> =20
registration->SetMetric(metric);<BR> =20
Flag=3Dfalse;<BR> }<BR> else if =
(RegType=3D=3D2)<BR> {<BR>typedef=20
itk::MutualInformationImageToImageMetric<ImageType, =
ImageType>=20
MetricType; <BR> =20
MetricType::Pointer =
metric =3D=20
MetricType::New();</DIV>
<DIV> </DIV>
<DIV> metric->SetMovingImageStandardDeviation( 2=20
);<BR> metric->SetFixedImageStandardDeviation( 2=20
);<BR> metric->SetNumberOfSpatialSamples( 50=20
); <BR> =20
registration->SetMetric(metric);<BR> =
Flag=3Dfalse;<BR> }=20
<BR> else<BR> { <BR> =
Flag=3Dtrue;<BR> }</DIV>
<DIV> </DIV>
<DIV> <BR> <BR>typedef =
itk::QuaternionRigidTransform<double>=20
TransformType;</DIV>
<DIV> </DIV>
<DIV>typedef itk::QuaternionRigidTransformGradientDescentOptimizer=20
OptimizerType; </DIV>
<DIV> </DIV>
<DIV>typedef itk::LinearInterpolateImageFunction<ImageType, =
double>=20
InterpolatorType;<BR> =20
<BR> TransformType::Pointer =20
transform =3D TransformType::New(); =20
OptimizerType::Pointer =20
optimizer =3D=20
OptimizerType::New();<BR> InterpolatorType::Pointer  =
;=20
interpolator =3D =
InterpolatorType::New();<BR> =20
<BR> <BR> =20
RegistrationType1::ParametersType =
guess(transform->GetNumberOfParameters()=20
);<BR> <BR> =
guess[0] =3D=20
0.0;<BR> guess[1] =3D =
0.0;<BR> =20
guess[2] =3D 0.0;<BR> guess[3] =3D=20
1.0;<BR> guess[4] =3D =
1.0;<BR> =20
guess[5] =3D 1.0;<BR> guess[6] =3D=20
0.0;<BR> <BR> =20
registration->SetInitialTransformParameters=20
(guess); =20
<BR> =20
<BR> // Set translation scale<BR> =
typedef=20
OptimizerType::ScalesType ScaleType;<BR> ScaleType=20
scales(transform->GetNumberOfParameters());<BR> =20
scales.Fill( 1.0 );<BR> for( unsigned j =3D 4; j < =
7; j++=20
)<BR> {<BR> scales[j] =3D 1.0 =
/=20
vnl_math_sqr(1000.0);<BR> =20
}<BR> =20
<BR> <BR> //Scale=20
parameters <BR> =20
optimizer->SetNumberOfIterations(1000);<BR> =20
optimizer->SetLearningRate( 0.0000001=20
); =
<BR> =20
<BR> // Setup the optimizer<BR> =20
optimizer->SetScales(scales);<BR> =20
// optimizer->MaximizeOn();<BR> &nbs=
p; =20
<BR> //set registration =
parameters<BR> =20
<BR> =20
registration->SetOptimizer(optimizer);<BR> =20
registration->SetTransform(transform);<BR> =20
registration->SetInterpolator(interpolator);<BR> =20
registration->SetFixedImage(FixedImage);<BR> =20
registration->SetMovingImage(MovingImage);<BR> regist=
ration->DebugOn();</DIV>
<DIV> &n=
bsp; <BR> =20
try<BR> {<BR> =20
registration->StartRegistration();<BR> =20
}<BR> catch(itk::ExceptionObject=20
&except)<BR> { <BR> =20
std::cerr<<"Excepti=
on"<<except.GetDescription();<BR> =20
<BR> <BR> =
}<BR> =20
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>CSPL</FONT></DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_000C_01C24D0C.B60125B0--