17 int top, bottom, left, right;
19 const char* window_name =
"copyMakeBorder Demo";
25 int main(
int,
char** argv )
35 printf(
" No data entered, please enter the path to an image file \n");
40 printf(
"\n \t copyMakeBorder Demo: \n" );
41 printf(
"\t -------------------- \n" );
42 printf(
" ** Press 'c' to set the border to a random constant value \n");
43 printf(
" ** Press 'r' to set the border to be replicated \n");
44 printf(
" ** Press 'ESC' to exit the program \n");
50 top = (int) (0.05*src.rows); bottom = (int) (0.05*src.rows);
51 left = (int) (0.05*src.cols); right = (int) (0.05*src.cols);
54 imshow( window_name, dst );
62 else if( (
char)c ==
'c' )
64 else if( (
char)c ==
'r' )
67 Scalar value( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
68 copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
70 imshow( window_name, dst );
aaaaaa|abcdefgh|hhhhhhh
Definition: base.hpp:235
Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
void copyMakeBorder(InputArray src, OutputArray dst, int top, int bottom, int left, int right, int borderType, const Scalar &value=Scalar())
Forms a border around an image.
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
Random Number Generator.
Definition: core.hpp:2600
Definition: highgui.hpp:138
iiiiii|abcdefgh|iiiiiii with some specified i
Definition: base.hpp:234
int main(int argc, const char *argv[])
Definition: facerec_demo.cpp:67
n-dimensional dense array class
Definition: mat.hpp:726
int waitKey(int delay=0)
Waits for a pressed key.