[opengtl-commits] [587] scale to the 0x0 - 0xFFFF range

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


Revision: 587
Author:   cyrille
Date:     2009-03-06 22:43:38 +0100 (Fri, 06 Mar 2009)

Log Message:
-----------
scale to the 0x0 - 0xFFFF range

Modified Paths:
--------------
    trunk/OpenGTL/Extensions/RawDC/RawDC.cpp


Modified: trunk/OpenGTL/Extensions/RawDC/RawDC.cpp
===================================================================
--- trunk/OpenGTL/Extensions/RawDC/RawDC.cpp	2009-03-06 20:50:59 UTC (rev 586)
+++ trunk/OpenGTL/Extensions/RawDC/RawDC.cpp	2009-03-06 21:43:38 UTC (rev 587)
@@ -57,6 +57,7 @@
   }
  
   #define OUT raw.imgdata.params
+  #define C raw.imgdata.color
 
   OUT.document_mode=0;
   OUT.output_bps=16;
@@ -75,19 +76,30 @@
   int count = raw.imgdata.sizes.iwidth * raw.imgdata.sizes.iheight;
   GTLCore::Array* array = new GTLCore::Array((int)(count * sizeof(unsigned short)));
   
-  int max = 0;
+  int maxou = 0;
+  unsigned short *output = array->data<unsigned short>();
   
-  unsigned short *output = array->data<unsigned short>();
-  double coef = 0xFFFF / raw.imgdata.color.maximum;
-
   for (uint row=0 ; row < raw.imgdata.sizes.iheight ; row++)
   {
       for (uint col=0 ; col < raw.imgdata.sizes.iwidth ; col++)
       {
-          *output = coef * raw.imgdata.image[raw.imgdata.sizes.iwidth*row + col] [raw.FC(row, col)];
+          *output = GTLCore::bound(0,
+                  int( (raw.imgdata.image[raw.imgdata.sizes.iwidth*row + col][raw.FC(row, col)]) - C.black ),
+                  0xFFFF );
+                  if( *output > maxou ) maxou = *output;
           ++output;
       }
   }
+  
+  output = array->data<unsigned short>();
+  double coef = 0xFFFF / (double)maxou;
+  for(int i = 0; i < count; ++i)
+  {
+    *output *= coef;
+    ++output;
+  }
+  
+  GTL_DEBUG( "Camera maximum = " << C.maximum << " black = " << C.black << " maxou = " << maxou );
   if(_region)
   {
     _region->setWidth(raw.imgdata.sizes.iwidth);


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