[ITK-users] SimpleITK | Registration in C#
Matias Montroull
matimontg at gmail.com
Fri Jun 19 18:37:15 EDT 2015
Hi, I have this code so far for doing registration with SimpleITK. I've run
it and seems to work ok but the offset and matrix doesn't change so I think
I'm missing the command part which I haven't been able to figure out.. I
marked in bold what I think needs further code, unfortunately I haven't
found any example in C#, all is in Pyton or C++, I was able to kind of
translate to C# and figure out but the Command part is a struggle for me so
far..
itk.simple.Image Imagen_fija = new itk.simple.Image();
itk.simple.Image Imagen_flotante = new itk.simple.Image();
ImageSeriesReader reader_fija = new ImageSeriesReader();
var archivosdcm_fija =
ImageSeriesReader.GetGDCMSeriesFileNames(@"C:\TRACKER\Pacientes\ST1_CT\DCM");
reader_fija.SetFileNames(archivosdcm_fija);
Imagen_fija = reader_fija.Execute();
ImageSeriesReader reader_flotante = new ImageSeriesReader();
var archivosdcm_flotante =
ImageSeriesReader.GetGDCMSeriesFileNames(@"C:\TRACKER\Pacientes\ST1_RM\DCM");
reader_flotante.SetFileNames(archivosdcm_flotante);
Imagen_flotante = reader_flotante.Execute();
CastImageFilter conversorafloat = new CastImageFilter();
conversorafloat.SetOutputPixelType(itk.simple.PixelIDValueEnum.sitkFloat32);
Imagen_fija = conversorafloat.Execute(Imagen_fija);
Imagen_flotante = conversorafloat.Execute(Imagen_flotante);
ImageRegistrationMethod R = new ImageRegistrationMethod();
R.SetMetricAsMattesMutualInformation(50); //numberof
histogrambins
R.SetMetricSamplingPercentage(3.0); //Sampling %
R.SetOptimizerAsRegularStepGradientDescent(16.0, 0.1, 100,
0.99); //max step, min step, iteraciones, relaxation
R.SetInterpolator(InterpolatorEnum.sitkLinear);
AffineTransform transform = new AffineTransform(3);
itk.simple.Transform Initial_transform =
SimpleITK.CenteredTransformInitializer(Imagen_fija, Imagen_flotante,
transform, CenteredTransformInitializerFilter.OperationModeType.GEOMETRY);
R.SetInitialTransform(Initial_transform);
ResampleImageFilter resampler_fija = new ResampleImageFilter();
resampler_fija.SetReferenceImage(Imagen_fija);
resampler_fija.SetTransform(Initial_transform);
resampler_fija.SetInterpolator(InterpolatorEnum.sitkLinear);
Imagen_fija= resampler_fija.Execute(Imagen_fija);
ResampleImageFilter resampler_flotante = new
ResampleImageFilter();
resampler_flotante.SetReferenceImage(Imagen_flotante);
resampler_flotante.SetTransform(Initial_transform);
resampler_flotante.SetInterpolator(InterpolatorEnum.sitkLinear);
Imagen_flotante = resampler_flotante.Execute(Imagen_flotante);
* itk.simple.Command cmd = new Command();*
* R.AddCommand(EventEnum.sitkIterationEvent, cmd);*
itk.simple.Transform transform_final = R.Execute(Imagen_fija,
Imagen_flotante);
double metrica = R.GetMetricValue();
--
Matias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150619/05429e0e/attachment.html>
More information about the Insight-users
mailing list