int top, bottom, left, right;
int borderType = BORDER_CONSTANT;
const char* window_name = "copyMakeBorder Demo";
int main(
int argc,
char** argv )
{
const char* imageName = argc >=2 ? argv[1] : "lena.jpg";
src = imread( samples::findFile( imageName ), IMREAD_COLOR );
printf(" Error opening image\n");
printf(" Program Arguments: [image_name -- default lena.jpg] \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");
namedWindow( window_name, WINDOW_AUTOSIZE );
top = (int) (0.05*src.
rows); bottom = top;
left = (int) (0.05*src.
cols); right = left;
for(;;)
{
Scalar value( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
imshow( window_name, dst );
char c = (char)waitKey(500);
if( c == 27 )
{ break; }
else if( c == 'c' )
else if( c == 'r' )
}
return 0;
}
n-dimensional dense array class
Definition mat.hpp:829
int cols
Definition mat.hpp:2155
bool empty() const
Returns true if the array has no elements.
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition mat.hpp:2155
Random Number Generator.
Definition core.hpp:2878
@ BORDER_REPLICATE
aaaaaa|abcdefgh|hhhhhhh
Definition base.hpp:270
@ BORDER_CONSTANT
iiiiii|abcdefgh|iiiiiii with some specified i
Definition base.hpp:269
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3