I wrote a function that is supposed to crop a 2d vector starting at point r, c. The rectangle from there should have rows rows and cols columns.
void pgm_crop( vector <IVec> p, int r, int c, int rows, int cols )
{
int count = 0; //first count variable
int count2 = 0; // 2nd count variable
for( count = 0; count < r; count++ )
{
if( count + 1 != r )
{
p.erase( p.begin() + count ); // erase rows before given point
}
else
p.resize( rows ); // resize to number of rows
for( count2 = 0; count2 < c; count2++ )
{
if( count2 + 1 != c )
{
p[count].erase( p[count].begin() + count2 ); // erase elements before given point
}
else
p[count].resize( cols ); // resize to number of columns
}
}
}
The output i get is weird. It duplicates rows instead of deleting them