a1nw.cpp
void overlay_rectangle(SDoublePlane &input, int _top, int _left, int _bottom, int _right, double graylevel, int width)
{
  for(int w=-width/2; w<=width/2; w++) {
    int top = _top+w, left = _left+w, right=_right+w, bottom=_bottom+w;

    // if any of the coordinates are out-of-bounds, truncate them 
    top = min( max( top, 0 ), input.rows()-1);
    bottom = min( max( bottom, 0 ), input.rows()-1);
    left = min( max( left, 0 ), input.cols()-1);
    right = min( max( right, 0 ), input.cols()-1);
      
    // draw top and bottom lines
    for(int j=left; j<=right; j++)
	  input[top][j] = input[bottom][j] = graylevel;
    // draw left and right lines
    for(int i=top; i<=bottom; i++)
	  input[i][left] = input[i][right] = graylevel;
  }
}
// Draws a rectangle on an image plane, using the specified gray level value and line width.
//

Draws a rectangle on an image plane, using the specified gray level value and line width.
Draws a rectangle on an image plane using the specified gray level value and line width .
void overlay_rectangle(SDoublePlane &input, int _top, int _left, int _bottom, int _right, double graylevel, int width)
{
  for(int w=-width/2; w<=width/2; w++) {
    int top = _top+w, left = _left+w, right=_right+w, bottom=_bottom+w;
    top = min( max( top, 0 ), input.rows()-1);
    bottom = min( max( bottom, 0 ), input.rows()-1);
    left = min( max( left, 0 ), input.cols()-1);
    right = min( max( right, 0 ), input.cols()-1);
    for(int j=left; j<=right; j++)
	  input[top][j] = input[bottom][j] = graylevel;
    for(int i=top; i<=bottom; i++)
	  input[i][left] = input[i][right] = graylevel;
  }
}
void overlay_rectangle ( SDoublePlane & input , int _top , int _left , int _bottom , int _right , double graylevel , int width ) { for ( int w = - width / 2 ; w <= width / 2 ; w ++ ) { int top = _top + w , left = _left + w , right = _right + w , bottom = _bottom + w ; top = min ( max ( top , 0 ) , input . rows ( ) - 1 ) ; bottom = min ( max ( bottom , 0 ) , input . rows ( ) - 1 ) ; left = min ( max ( left , 0 ) , input . cols ( ) - 1 ) ; right = min ( max ( right , 0 ) , input . cols ( ) - 1 ) ; for ( int j = left ; j <= right ; j ++ ) input [ top ] [ j ] = input [ bottom ] [ j ] = graylevel ; for ( int i = top ; i <= bottom ; i ++ ) input [ i ] [ left ] = input [ i ] [ right ] = graylevel ; } }
Draws a rectangle on an image plane, using the specified gray level value and line width.
Draws a rectangle on an image plane using the specified gray level value and line width .
// if any of the coordinates are out-of-bounds, truncate them 
 // draw top and bottom lines
 // draw left and right lines
