libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd cvd/vision.h cvd_src/gltext.cpp progs/ca...


From: Edward Rosten
Subject: [libcvd-members] libcvd cvd/vision.h cvd_src/gltext.cpp progs/ca...
Date: Thu, 23 Jul 2009 15:39:21 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        09/07/23 15:39:21

Modified files:
        cvd            : vision.h 
        cvd_src        : gltext.cpp 
        progs          : calibrate.cxx 

Log message:
        Removed C99 ism

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/vision.h?cvsroot=libcvd&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/gltext.cpp?cvsroot=libcvd&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/libcvd/progs/calibrate.cxx?cvsroot=libcvd&r1=1.17&r2=1.18

Patches:
Index: cvd/vision.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/vision.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- cvd/vision.h        4 Dec 2008 14:46:05 -0000       1.31
+++ cvd/vision.h        23 Jul 2009 15:39:21 -0000      1.32
@@ -67,6 +67,78 @@
     };
 };
 
+
+/** Subsamples an image to 2/3 of its size by averaging 3x3 blocks in to 2x2 
blocks.
address@hidden in input image
address@hidden out output image (muze be <code>out.size() == in.size()/2*3 
</code>)
address@hidden IncompatibleImageSizes if out does not have the correct 
dimensions.
address@hidden gVision
+*/
+template<class C> void twoThirdsSample(const SubImage<C>& in, SubImage<C>& out)
+{
+    typedef typename Pixel::traits<C>::wider_type sum_type;
+       if( (in.size()/3*2) != out.size())
+        throw Exceptions::Vision::IncompatibleImageSizes(__FUNCTION__);
+       
+       for(int yy=0, y=0; y < in.size().y-2; y+=3, yy+=2)
+               for(int xx=0, x=0; x < in.size().x-2; x+=3, xx+=2)
+               {
+                       // a b c
+                       // d e f
+                       // g h i
+
+                       sum_type b = in[y][x+1]*2;
+                       sum_type d = in[y+1][x]*2;
+                       sum_type f = in[y+1][x+2]*2;
+                       sum_type h = in[y+2][x+1]*2;
+                       sum_type e = in[y+1][x+1];
+
+                       out[yy][xx]     = static_cast<C>((in[  y][  
x]*4+b+d+e)/9);
+                       out[yy][xx+1]   = static_cast<C>((in[  
y][x+2]*4+b+f+e)/9);
+                       out[yy+1][xx]   = static_cast<C>((in[y+2][  
x]*4+h+d+e)/9);
+                       out[yy+1][xx+1] = 
static_cast<C>((in[y+2][x+2]*4+h+f+e)/9);
+               }
+}
+
+/**
address@hidden
+*/
+void twoThirdsSample(const SubImage<byte>& in, SubImage<byte>& out);
+
+  #ifndef DOXYGEN_IGNORE_INTERNAL
+  namespace Internal
+  {
+       template<class C> class twoThirdsSampler{};
+       template<class C>  struct ImagePromise<twoThirdsSampler<C> >
+       {
+               ImagePromise(const SubImage<C>& im)
+               :i(im)
+               {}
+
+               const SubImage<C>& i;
+               template<class D> void execute(Image<D>& j)
+               {
+                       j.resize(i.size()/3*2);
+                       twoThirdsSample(i, j);
+               }
+       };
+  };
+  template<class C> Internal::ImagePromise<Internal::twoThirdsSampler<C> > 
twoThirdsSample(const SubImage<C>& c)
+  {
+    return Internal::ImagePromise<Internal::twoThirdsSampler<C> >(c);
+  }
+  #else
+       ///Subsamples an image by averaging 3x3 blocks in to 2x2 ones.
+       /// Note that this is performed using lazy evaluation, so subsampling
+       /// happns on assignment, and memory allocation is not performed if
+       /// unnecessary.
+    /// @param from The image to convert from
+       /// @return The converted image
+    /// @ingroup gVision
+       template<class C> Image<C> twoThirdsSample(const SubImage<C>& from);
+
+  #endif
+
 /// subsamples an image to half its size by averaging 2x2 pixel blocks
 /// @param in input image
 /// @param out output image, must have the right dimensions versus input image

Index: cvd_src/gltext.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/gltext.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- cvd_src/gltext.cpp  25 May 2009 14:01:21 -0000      1.2
+++ cvd_src/gltext.cpp  23 Jul 2009 15:39:21 -0000      1.3
@@ -1,6 +1,7 @@
 #include <cvd/gl_helpers.h>
 
 #include <cassert>
+#include <cmath> 
 #include <map>
 
 using namespace std;
@@ -147,7 +148,7 @@
             continue;
         }
         if(c == '\t'){
-            const float advance = tab_width - fmodf(total, tab_width);
+            const float advance = tab_width - std::fmod(total, tab_width);
             total += advance;
             glTranslated(advance, 0, 0);
             continue;

Index: progs/calibrate.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/progs/calibrate.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- progs/calibrate.cxx 27 Apr 2009 13:42:31 -0000      1.17
+++ progs/calibrate.cxx 23 Jul 2009 15:39:21 -0000      1.18
@@ -582,24 +582,24 @@
 
     if(blWhite)
     {
-       if(midVal - tlVal < 0.05)
+       if(midVal - tlVal < 0.02)
            return false;
-       if(trVal - midVal < 0.05)
+       if(trVal - midVal < 0.02)
            return false;
-       if(blVal - midVal < 0.05)
+       if(blVal - midVal < 0.02)
            return false;
-       if(midVal - brVal < 0.05)
+       if(midVal - brVal < 0.02)
            return false;
     }
     else
     {
-       if(tlVal - midVal < 0.05)
+       if(tlVal - midVal < 0.02)
            return false;
-       if(midVal - trVal < 0.05)
+       if(midVal - trVal < 0.02)
            return false;
-       if(midVal - blVal < 0.05)
+       if(midVal - blVal < 0.02)
            return false;
-       if(brVal - midVal < 0.05)
+       if(brVal - midVal < 0.02)
            return false;
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]