<div dir="ltr">Thank you all for your answers, I'll give it a try!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 23, 2014 at 4:09 AM, Dan Mueller <span dir="ltr"><<a href="mailto:dan.muel@gmail.com" target="_blank">dan.muel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi Matias,</p>
<p dir="ltr">I would highly recommend SimpleITK. Given your requirements, it appears SimpleITK wraps all the features you need.</p>
<p dir="ltr">Secondly I would recommend SWIG. Some years ago I created a wiki page to explain how this works:<br>
<a href="http://www.itk.org/Wiki/ITK/Using_ITK_from_.NET" target="_blank">http://www.itk.org/Wiki/ITK/Using_ITK_from_.NET</a></p>
<p dir="ltr">Hope this helps.</p>
<p dir="ltr">Cheers, Dan</p>
<div class="gmail_quote"><div><div class="h5">On 22 Nov 2014 23:01, "Matias Montroull" <<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi,<div><br></div><div>I have the following code that I would like to use in C#. Since it is ITK, it's coded in C++ so I was wondering if I could create a DLL that can be used in C# and then call the function as it was a class, pass parameters and use the method?</div><div><br></div><div>All I need is to pass 3 parameters to the function (which is a function to rotate images)</div><div><br></div><div>here's the code:</div><div><br></div><div><div>#include "itkImage.h"</div><div>#include "itkImageFileReader.h"</div><div>#include "itkImageFileWriter.h"</div><div>#include "itkResampleImageFilter.h"</div><div>#include "itkAffineTransform.h"</div><div>#include "itkGDCMImageIO.h"</div><div><br></div><div>int main( int argc, char * argv[] )</div><div>{</div><div>if( argc < 4 )</div><div>{</div><div>std::cerr << "Usage: " << std::endl;</div><div>std::cerr << argv[0] << " inputImageFile outputImageFile degrees" << std::endl;</div><div>return EXIT_FAILURE;</div><div>}</div><div><br></div><div>const unsigned int Dimension = 2; //imagen 2D</div><div>typedef signed short InputPixelType;</div><div>typedef signed short OutputPixelType;</div><div>typedef itk::Image< InputPixelType, Dimension > InputImageType;</div><div>typedef itk::Image< OutputPixelType, Dimension > OutputImageType;</div><div>typedef itk::ImageFileReader< InputImageType > ReaderType;</div><div>typedef itk::ImageFileWriter< OutputImageType > WriterType;</div><div>ReaderType::Pointer reader = ReaderType::New(); //lo que lee</div><div>WriterType::Pointer writer = WriterType::New(); //lo que escribe</div><div>reader->SetFileName( argv[1] ); //primer argumento</div><div>writer->SetFileName( argv[2] ); //segundo argumento</div><div><br></div><div>typedef itk::GDCMImageIO ImageIOType;</div><div>ImageIOType::Pointer gdcmImageIO = ImageIOType::New();</div><div>reader->SetImageIO( gdcmImageIO );</div><div><br></div><div><br></div><div>const double angleInDegrees = atof( argv[3] ); //angulo de rotación</div><div><br></div><div>typedef itk::ResampleImageFilter<InputImageType, OutputImageType > FilterType; //Filtro</div><div>FilterType::Pointer filter = FilterType::New();</div><div><br></div><div>typedef itk::AffineTransform< double, Dimension > TransformType; //usado para mapear el espacio de entrada con el espacio de salida</div><div>TransformType::Pointer transform = TransformType::New();</div><div><br></div><div>typedef itk::LinearInterpolateImageFunction<InputImageType, double > InterpolatorType;</div><div>InterpolatorType::Pointer interpolator = InterpolatorType::New();</div><div>filter->SetInterpolator( interpolator );</div><div>filter->SetDefaultPixelValue(0); //Pixel por defecto de lo que queda fuera de la imagen cuando se rota</div><div><br></div><div>reader->Update();</div><div><br></div><div>const InputImageType * inputImage = reader->GetOutput();</div><div>const InputImageType::SpacingType & spacing = inputImage->GetSpacing();</div><div>const InputImageType::PointType & origin = inputImage->GetOrigin();</div><div>InputImageType::SizeType size =</div><div>inputImage->GetLargestPossibleRegion().GetSize();</div><div>filter->SetOutputOrigin( origin );</div><div>filter->SetOutputSpacing( spacing );</div><div>filter->SetOutputDirection( inputImage->GetDirection() );</div><div>filter->SetSize( size );</div><div><br></div><div>filter->SetInput( reader->GetOutput() );</div><div>writer->SetInput( filter->GetOutput() );</div><div>writer->UseInputMetaDataDictionaryOff();</div><div>writer->SetImageIO(gdcmImageIO);</div><div> TransformType::OutputVectorType translation1;</div><div>const double imageCenterX = origin[0] + spacing[0] * size[0] / 2.0;</div><div>const double imageCenterY = origin[1] + spacing[1] * size[1] / 2.0;</div><div>translation1[0] = -imageCenterX;</div><div>translation1[1] = -imageCenterY;</div><div>transform->Translate( translation1 );</div><div>// Software Guide : EndCodeSnippet</div><div>std::cout << "imageCenterX = " << imageCenterX << std::endl;</div><div>std::cout << "imageCenterY = " << imageCenterY << std::endl;</div><div><br></div><div>const double degreesToRadians = std::atan(1.0) / 45.0;</div><div>const double angle = angleInDegrees * degreesToRadians;</div><div>transform->Rotate2D( -angle, false );</div><div><br></div><div>TransformType::OutputVectorType translation2;</div><div>translation2[0] = imageCenterX;</div><div>translation2[1] = imageCenterY;</div><div>transform->Translate( translation2, false );</div><div>filter->SetTransform( transform );</div><div><br></div><div>try</div><div>{</div><div>writer->Update();</div><div>}</div><div>catch( itk::ExceptionObject & excep )</div><div>{</div><div>std::cerr << "Exception caught !" << std::endl;</div><div>std::cerr << excep << std::endl;</div><div>}</div><div>// Software Guide : EndCodeSnippet</div><div>return EXIT_SUCCESS;</div><div>}</div></div><div><br></div></div>
<br></div></div><span class="">_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br></span></blockquote></div>
</blockquote></div><br></div>