template<class BackInsertIterator>
Function for dividing a big rectangle (typically an image) into a collection of several smaller rectangles. 1/nrRegionsX, and 1/nrRegionsY, indicate the size of the region compared to the image the regions are possibly overlapping, where "overlap" = how much relative overlap) Definition at line 21 of file MakeSubRects.h. Referenced by Impala::Core::Geometry::RectanglePyramidPerDim::SetImageSize(). 00023 { 00024 00025 if(overlap < 0 || overlap >= 1) 00026 { 00027 std::cout << "MakeSubRects: overlap not between [0,1), overlap: " 00028 << overlap << std::endl; 00029 exit(1); 00030 } 00031 00032 // std::cout << "imWidth: " << imWidth << std::endl; 00033 // std::cout << "imHeight: " << imHeight << std::endl; 00034 00035 imWidth -= 2*borderWidth; 00036 imHeight -= 2*borderWidth; 00037 00038 int regionWidth = imWidth/nrRegionsX; 00039 int regionHeight = imHeight/nrRegionsY; 00040 00041 // std::cout << "regionWidth: " << regionWidth << std::endl; 00042 // std::cout << "regionHeight: " << regionHeight << std::endl; 00043 00044 int regionXoffset = regionWidth/2; 00045 int regionYoffset = regionHeight/2; 00046 00047 int incrementX = regionWidth*(1.0-overlap); 00048 int incrementY = regionHeight*(1.0-overlap); 00049 00050 // std::cout << "incrementX: " << incrementX << std::endl; 00051 // std::cout << "incrementY: " << incrementY << std::endl; 00052 00053 00054 int maxRegionsX = ((imWidth-regionWidth) / incrementX ) +1; 00055 int maxRegionsY = ((imHeight-regionHeight) / incrementY ) +1; 00056 00057 // std::cout << "maxRegionsX: " << maxRegionsX << std::endl; 00058 // std::cout << "maxRegionsY: " << maxRegionsY << std::endl; 00059 00060 int nrRects = 0; 00061 int toProduce = maxRegionsX * maxRegionsY; 00062 00063 00064 int nrY = 1; 00065 for (int y=borderWidth+regionYoffset ; 00066 y<=imHeight-regionYoffset+borderWidth ; y+=incrementY) 00067 { 00068 if (nrY++ > maxRegionsY) 00069 continue; 00070 int nrX = 1; 00071 for(int x=borderWidth+regionXoffset ; 00072 x<=imWidth-regionXoffset+borderWidth ; x+=incrementX) 00073 { 00074 if (nrX++ > maxRegionsX) 00075 continue; 00076 Rectangle rect(x-regionXoffset, y-regionYoffset, 00077 x+regionXoffset-1, y+regionYoffset-1); 00078 // std::cout << "new-rect: " << rect << std::endl; 00079 *bi++ = rect; 00080 nrRects++; 00081 } 00082 } 00083 00084 if (nrRects != toProduce) 00085 std::cout << "MakeSubRects: produced incorrect number: " 00086 << nrRects << " instead of " << toProduce << std::endl; 00087 }
|