An example using copyMakeBorder function
int top, bottom, left, right;
int borderType;
const char* window_name = "copyMakeBorder Demo";
int main( int argc, char** argv )
{
String imageName(
"../data/lena.jpg");
if (argc > 1)
{
imageName = argv[1];
}
{
printf(" No data entered, please enter the path to an image file \n");
return -1;
}
printf( "\n \t copyMakeBorder Demo: \n" );
printf( "\t -------------------- \n" );
printf( " ** Press 'c' to set the border to a random constant value \n");
printf( " ** Press 'r' to set the border to be replicated \n");
printf( " ** Press 'ESC' to exit the program \n");
top = (int) (0.05*src.
rows); bottom = (int) (0.05*src.
rows);
left = (int) (0.05*src.
cols); right = (int) (0.05*src.
cols);
dst = src;
for(;;)
{
if( c == 27 )
{ break; }
else if( c == 'c' )
else if( c == 'r' )
Scalar value( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
}
return 0;
}