Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

MakeOverlappingRects.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Geometry_MakeOverlappingRects_h
00002 #define Impala_Core_Geometry_MakeOverlappingRects_h
00003 
00004 #include "Core/Geometry/RectangleSet.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Geometry
00011 {
00012 
00013 
00014 template <class BackInsertIterator>
00015 inline void
00016 MakeOverlappingRects(BackInsertIterator bi, int imWidth, int imHeight,
00017                      int borderWidth, int nrRegionsMin, int nrRegionsMax,
00018                      int nrRegionsStepSize)
00019 {
00020     imWidth -= 2*borderWidth;
00021     imHeight -= 2*borderWidth;
00022     int nrRects = 0;
00023     int toProduce = 0;
00024     for (int nr=nrRegionsMin ; nr<=nrRegionsMax ; nr+=nrRegionsStepSize)
00025     {
00026         int maxPerDim = nr + (nr - 1);
00027         toProduce += maxPerDim * maxPerDim;
00028         int regionWidth = imWidth/nr;
00029         int regionHeight = imHeight/nr;
00030         int regionXoffset = regionWidth/2;
00031         int regionYoffset = regionHeight/2;
00032 
00033         int nrY = 1;
00034         for (int y=borderWidth+regionYoffset ;
00035              y<=imHeight-regionYoffset+borderWidth ; y+=regionYoffset)
00036         {
00037             if (nrY++ > maxPerDim)
00038                 continue;
00039             int nrX = 1; 
00040             for(int x=borderWidth+regionXoffset ;
00041                 x<=imWidth-regionXoffset+borderWidth ; x+=regionXoffset)
00042             {
00043                 if (nrX++ > maxPerDim)
00044                     continue;
00045                 Rectangle rect(x-regionXoffset, y-regionYoffset,
00046                                x+regionXoffset-1, y+regionYoffset-1);
00047                 *bi++ = rect;
00048                 nrRects++;
00049             }
00050         }
00051     }
00052     if (nrRects != toProduce)
00053         std::cout << "MakeOverlappingRects: produced incorrect number: "
00054                   << nrRects << " instead of " << toProduce << std::endl;
00055 }
00056 
00057 } // namespace Geometry
00058 } // namespace Core
00059 } // namespace Impala
00060 
00061 #endif

Generated on Fri Mar 19 09:31:09 2010 for ImpalaSrc by  doxygen 1.5.1