]> Creatis software - clitk.git/commitdiff
Deal with options --like and --spacinglike at the same time
authorDavid Sarrut <david.sarrut@gmail.com>
Fri, 3 Feb 2012 06:57:12 +0000 (07:57 +0100)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Tue, 9 Apr 2013 06:56:50 +0000 (08:56 +0200)
tools/clitkAffineTransformGenericFilter.txx

index dc4d362dd0e50a0c83a4a2d73f4844de5c14cddb..b2d7a534aa7e250b2d51a4300ebc144fe88669dd 100644 (file)
@@ -289,7 +289,23 @@ namespace clitk
       typename InputReaderType::Pointer likeReader=InputReaderType::New();
       likeReader->SetFileName(m_ArgsInfo.spacinglike_arg);
       likeReader->Update(); 
-      resampler->SetOutputSpacing( likeReader->GetOutput()->GetSpacing() );
+
+      // set the support like the image 
+      if (m_ArgsInfo.like_given) {
+        typename OutputImageType::SizeType outputSize;
+        outputSize[0] = ceil(resampler->GetSize()[0]*resampler->GetOutputSpacing()[0]
+                             /likeReader->GetOutput()->GetSpacing()[0]);
+        outputSize[1] = ceil(resampler->GetSize()[1]*resampler->GetOutputSpacing()[1]
+                             /likeReader->GetOutput()->GetSpacing()[1]);
+        outputSize[2] = ceil(resampler->GetSize()[2]*resampler->GetOutputSpacing()[2]
+                             /likeReader->GetOutput()->GetSpacing()[2]);
+        if (m_ArgsInfo.verbose_flag) {
+          std::cout << "Compute the number of pixels such as the support is like " << m_ArgsInfo.like_arg << std::endl;
+        }
+        resampler->SetSize( outputSize );
+      }
+
+      resampler->SetOutputSpacing( likeReader->GetOutput()->GetSpacing() );      
     }
 
     if (m_ArgsInfo.verbose_flag) {