]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Thu, 31 Oct 2013 15:47:14 +0000 (16:47 +0100)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Thu, 31 Oct 2013 15:47:14 +0000 (16:47 +0100)
tools/CMakeLists.txt
tools/clitkImageConvert.cxx
tools/clitkImageConvert.ggo
tools/clitkImageConvertGenericFilter.cxx
tools/clitkImageConvertGenericFilter.h
tools/clitkMatrixMultiply.cxx [new file with mode: 0644]
tools/clitkMatrixMultiply.ggo [new file with mode: 0644]

index 06d85a77c66ea0d1b5c3c29a305ccaca17823dad..e6cdd02e697f6fc62e335fec84fbdce3d51ac4c5 100644 (file)
@@ -120,6 +120,11 @@ IF (CLITK_BUILD_TOOLS)
   TARGET_LINK_LIBRARIES(clitkMatrixToElastixTransform clitkCommon )
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixToElastixTransform)
 
+  WRAP_GGO(clitkMatrixMultiply_GGO_C clitkMatrixMultiply.ggo)
+  ADD_EXECUTABLE(clitkMatrixMultiply clitkMatrixMultiply.cxx ${clitkMatrixMultiply_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkMatrixMultiply clitkCommon )
+  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixMultiply)
+
   WRAP_GGO(clitkMatrixInverse_GGO_C clitkMatrixInverse.ggo)
   ADD_EXECUTABLE(clitkMatrixInverse clitkMatrixInverse.cxx ${clitkMatrixInverse_GGO_C})
   TARGET_LINK_LIBRARIES(clitkMatrixInverse clitkCommon )
index abedc61a800310e4a951ae64fe5bb63ccf46b156..3a9beaf4a25406dbfd0d5ece95bf5b04d7a8db59 100644 (file)
@@ -67,6 +67,7 @@ int main(int argc, char * argv[])
   filter->SetInputFilenames(l);
   filter->SetIOVerbose(args_info.verbose_flag);
   filter->SetOutputFilename(output);
+  filter->SetVV(args_info.vv_flag);
   filter->EnableWriteCompression(args_info.compression_flag);
   if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
 
index 837ee03bb6c75e5ef39e9b489eeb4929bcf95dd2..b6f003c8f9fb9ad6339afbf8e0500a23799d31c0 100644 (file)
@@ -3,9 +3,10 @@ package "clitkImageConvert"
 version "1.0"
 purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double\n\nIf the -o option is not given, the last parameter of the command line is used as output."
 
-option "config"      - "Config file"                     string no
-option "input"       i "Input image filename"            string no
-option "output"      o "Output image filename"           string no
-option "type"        t "Output type (float, ushort ...)" string no
-option "verbose"     v "Verbose"                         flag   off
-option "compression" c "Compress output"                 flag   off
+option "config"      - "Config file"                                                string no
+option "input"       i "Input image filename"                                       string no
+option "output"      o "Output image filename"                                      string no
+option "type"        t "Output type (float, ushort ...)"                            string no
+option "verbose"     v "Verbose"                                                    flag   off
+option "compression" c "Compress output"                                            flag   off
+option "vv"          - "Read image as in vv and save transform in meta information" flag   off
index e8d8efb79d9f8c6a54d9cc1b5f37e0401d613c75..2783053fdb2d7546c4096948e621c38a7a4fdeb2 100644 (file)
@@ -19,6 +19,8 @@
 #define CLITKIMAGECONVERTGENERICFILTER_CXX
 
 #include "clitkImageConvertGenericFilter.h"
+#include "vvImageReader.h"
+#include "vvImageWriter.h"
 
 //--------------------------------------------------------------------
 clitk::ImageConvertGenericFilter::ImageConvertGenericFilter():
@@ -70,7 +72,24 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType()
     }
   }
 
-  if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) {
+  if(mVV) {
+    if (mOutputPixelTypeName != "NotSpecified" || m_WriteCompression) {
+      std::cerr << "--vv is not compatible with --compression and --type options." << std::endl;
+      exit(-1);
+    }
+
+    vvImageReader::Pointer reader = vvImageReader::New();
+    reader->SetInputFilenames(m_InputFilenames);
+    reader->Update(vvImageReader::IMAGE);
+
+    vvImageWriter::Pointer writer = vvImageWriter::New();
+    writer->SetOutputFileName(m_OutputFilenames.front());
+    writer->SetSaveTransform(true);
+    writer->SetInput(reader->GetOutput());
+    writer->Update();
+    return;
+  }
+  else if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) {
     typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
     this->SetNextOutput<InputImageType>(input);
   } else {
index 20717144431725a5f793d061467e10f170dc61bb..8ffb360596833d0225c6b022cc9dd04711dc544d 100644 (file)
@@ -73,6 +73,7 @@ namespace clitk {
     std::string GetInputPixelTypeName() { return m_PixelTypeName; }
     std::string GetOutputPixelTypeName() { return mOutputPixelTypeName; }
     void SetOutputPixelType(std::string p) { mOutputPixelTypeName = p; }
+    void SetVV(bool b) { mVV = b; }
     bool IsWarningOccur() { return mWarningOccur; }
     std::string & GetWarning() { return mWarning; }
     void EnableDisplayWarning(bool b) { mDisplayWarning = b; }
@@ -92,6 +93,7 @@ namespace clitk {
     std::string mWarning;
     bool mWarningOccur;
     bool mDisplayWarning;
+    bool mVV;
 
   private:
     template <class InputImageType, bool isVector>
diff --git a/tools/clitkMatrixMultiply.cxx b/tools/clitkMatrixMultiply.cxx
new file mode 100644 (file)
index 0000000..95e1a40
--- /dev/null
@@ -0,0 +1,59 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+// clitk
+#include "clitkMatrixMultiply_ggo.h"
+#include "clitkTransformUtilities.h"
+#include "clitkIO.h"
+#include "clitkMatrix.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+  // Init command line
+  GGO(clitkMatrixMultiply, args_info);
+  CLITK_INIT;
+
+  // Read matrix
+  itk::Matrix<double, 4, 4> matrix1, matrix2;
+  try {
+    matrix1 = clitk::ReadMatrix3D(args_info.input1_arg);
+    matrix2 = clitk::ReadMatrix3D(args_info.input2_arg);
+  }
+  catch (itk::ExceptionObject & err) {
+    std::cerr << "Error reading "
+              << args_info.input1_arg
+              << " and "
+              << args_info.input2_arg
+              << std::endl;
+    std::cerr << err.GetDescription() << std::endl;
+    exit(-1);
+  }
+
+  itk::Matrix<double, 4, 4> matrix(matrix2.GetVnlMatrix() * matrix1.GetVnlMatrix());
+
+  // Print matrix
+  std::ofstream os;
+  clitk::openFileForWriting(os, args_info.output_arg);
+  os << clitk::Get4x4MatrixDoubleAsString(matrix, 16);
+  os.close();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkMatrixMultiply.ggo b/tools/clitkMatrixMultiply.ggo
new file mode 100644 (file)
index 0000000..5463bdd
--- /dev/null
@@ -0,0 +1,8 @@
+package "clitkMatrixMultiply"
+version "1.0"
+purpose "Multiply two 4x4 matrices. In matrice notations, does input2*input"
+
+option "config"  - "Config file"            string optional
+option "input1"  i "Input matrix filename"  string required
+option "input2"  j "Input matrix filename"  string required
+option "output"  o "Output matrix filename" string required