Mat src, dst;
int top, bottom, left, right;
const char* window_name = "copyMakeBorder Demo";
RNG rng(12345);
int main(
int argc,
char** argv )
{
const char* imageName = argc >=2 ? argv[1] : "lena.jpg";
if( src.empty()) {
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");
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 );
if( c == 27 )
{ break; }
else if( c == 'c' )
else if( c == 'r' )
}
return 0;
}
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.
@ BORDER_REPLICATE
aaaaaa|abcdefgh|hhhhhhh
Definition: core/include/opencv2/core/base.hpp:270
@ BORDER_CONSTANT
iiiiii|abcdefgh|iiiiiii with some specified i
Definition: core/include/opencv2/core/base.hpp:269
Scalar_< double > Scalar
Definition: modules/core/include/opencv2/core/types.hpp:709
cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
@ WINDOW_AUTOSIZE
the user cannot resize the window, the size is constrainted by the image displayed.
Definition: highgui.hpp:144
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
@ IMREAD_COLOR
Same as IMREAD_COLOR_BGR.
Definition: imgcodecs.hpp:72
CV_EXPORTS_W Mat imread(const String &filename, int flags=IMREAD_COLOR_BGR)
Loads an image from a file.
int main(int argc, char *argv[])
Definition: highgui_qt.cpp:3
Definition: core/include/opencv2/core.hpp:107