[opengtl-commits] [582] add options to control the PixelDescription of the output image

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 582
Author:   cyrille
Date:     2009-03-02 13:25:00 +0100 (Mon, 02 Mar 2009)

Log Message:
-----------
add options to control the PixelDescription of the output image

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp


Modified: trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2009-03-02 12:22:42 UTC (rev 581)
+++ trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2009-03-02 12:25:00 UTC (rev 582)
@@ -54,9 +54,12 @@
   std::cout << std::endl;
   std::cout << "Options : " << std::endl;
   std::cout << "  -S --asm-source         print the assembly source code generated after the execution of the kernel" << std::endl;
+  std::cout << "  -L --module-dir   add a location where to find modules" << std::endl;
+  std::cout << std::endl;
   std::cout << "  -w --width [w]          define the width of the output" << std::endl;
   std::cout << "  -h --height [h]         define the height of the output" << std::endl;
-  std::cout << "  -L --module-dir   add a location where to find modules" << std::endl;
+  std::cout << "  -c --channels [count]   set the number of channels of the output" << std::endl;
+  std::cout << "  -t --channeltype [type] set the type of the output (uint8, uint16, half, float)" << std::endl;
   std::cout << std::endl;
   std::cout << "  -h --help               print this message" << std::endl;
   std::cout << "  -v --version            print the version information" << std::endl;
@@ -72,6 +75,10 @@
   bool showAssembly = false;
   int width = 800;
   int height = 600;
+  int channelsCount = 3;
+  // Select the type of the resulting image
+  const GTLCore::Type* typeChannelImage = GTLCore::Type::UnsignedInteger8;
+  bool userChannelType = false;
   for(int ai = 1; ai < argc; ai++)
   {
     if(ARG_IS("-h","--help"))
@@ -111,6 +118,39 @@
         ++ai;
         height = GTLCore::String( argv[ai] ).toInt();
       }
+    } else if(ARG_IS("-c", "--channels")) {
+      if( ai == argc )
+      {
+        std::cerr << "Expected count after -c --channels." << std::endl;
+        return EXIT_FAILURE;
+      } else {
+        ++ai;
+        channelsCount = GTLCore::String( argv[ai] ).toInt();
+      }
+    } else if(ARG_IS("-t", "--channeltype")) {
+      if( ai == argc )
+      {
+        std::cerr << "Expected type after -t --channeltype." << std::endl;
+        return EXIT_FAILURE;
+      } else {
+        ++ai;
+        GTLCore::String channelType = argv[ai];
+        userChannelType = true;
+        if( channelType == "uint16" )
+        {
+          typeChannelImage = GTLCore::Type::UnsignedInteger16;
+        } else if( channelType == "half" )
+        {
+          typeChannelImage = GTLCore::Type::Half;
+        } else if( channelType == "float" )
+        {
+          typeChannelImage = GTLCore::Type::Float;
+        } else if( channelType != "uint8" )
+        {
+          std::cerr << "Unknown channel type: '" << channelType << "'." << std::endl;
+          return EXIT_FAILURE;
+        }
+      }
     } else {
       fileNames.push_back( argv[ai] );
     }
@@ -144,8 +184,6 @@
       source += "\n";
       std::getline(in,str);
     }
-    // Select the type of the resulting image
-    const GTLCore::Type* typeChannelImage = GTLCore::Type::UnsignedInteger8;
     // Load Images
     std::list<GTLCore::AbstractImage*> images;
     std::list<GTLCore::Region> inputDOD;
@@ -166,15 +204,17 @@
       }
       images.push_back( image );
       inputDOD.push_back( region );
-      foreach( const GTLCore::Type* type, image->pixelDescription().channelTypes())
+      if(not userChannelType)
       {
-        if( type->bitsSize() > typeChannelImage->bitsSize() )
+        foreach( const GTLCore::Type* type, image->pixelDescription().channelTypes())
         {
-          typeChannelImage = type;
+          if( type->bitsSize() > typeChannelImage->bitsSize() )
+          {
+            typeChannelImage = type;
+          }
         }
       }
     }
-    int channelsCount = 3;
     GTLCore::PixelDescription pixel( typeChannelImage, channelsCount );
     OpenShiva::Kernel p(channelsCount);
     p.setSource( source );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/