Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

for those in need

//----------------------------------------------------------------------ImgDIVISON
if(!imgROI.data || imgROI.empty())
{
    cerr << "Problem Loading Image" << endl;
    return 1;
}
while (imgROI.cols % colDivisor != 0)
{
  imgROI.cols++;
}
while (imgROI.rows % rowDivisor != 0)
{
  imgROI.rows++;
}
if(imgROI.cols % colDivisor == 0 && imgROI.rows % rowDivisor == 0)
{
    for(int y = 0, i = 0; y < imgROI.cols; y += imgROI.cols / colDivisor, i++)
    {
        for(int x = 0, j = 0; x < imgROI.rows; x += imgROI.rows / rowDivisor, j++)
        {
            blocks.push_back(imgROI(Rect(y, x, (imgROI.cols / colDivisor), (imgROI.rows / rowDivisor))).clone());
            rectangle (imgROI, Point(y, x), Point(y + (imgROI.cols / colDivisor) - 1, x + (imgROI.rows / rowDivisor) - 1), CV_RGB(255, 0, 0), 1);
        }
    }
}else if(imgROI.cols % colDivisor != 0)
{
    cout << "Error: Please use another divisor for the column split." << endl;
    exit(1);
}else if(imgROI.rows % rowDivisor != 0)
{
    cout << "Error: Please use another divisor for the row split." << endl;
    exit(1);
}
//----------------------------------------------------------------------ImgDIVISON