


#include<opencv2\opencv.hpp>
#include<opencv2\highgui\highgui.hpp>
#include<iostream>
#include<math.h>
using namespace std;
using namespace cv;
int main()
{
Mat src = imread("E:\\vs2015\\opencvstudy\\1.jpg", 1);
if (src.empty())
{
cout << "could not load the src image!" << endl;
return -1;
}
char *input_title = "input Image";
imshow(input_title, src);
Mat dst;
int top = (int)(0.05*src.rows);
int bottom =(int)( 0.05*src.rows);
int left = (int)(0.05*src.cols);
int right = (int)(0.05*src.cols);
RNG rng(12345);
int borderType = BORDER_DEFAULT;
int c = 0;
while (true)
{
c = waitKey(500);
if ((char)c == 27) //ESC
{
break;
}
if ((char)c == 'r')
{
borderType = BORDER_REPLICATE;
}
else if ((char)c == 'w')
{
borderType = BORDER_WRAP;
}
else if ((char)c == 'c')
{
borderType = BORDER_DEFAULT;
}
Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
copyMakeBorder(src, dst, top, bottom, left, right, borderType, color);
imshow("output image", dst);
}
GaussianBlur(src, dst, Size(5, 5), 0, 0, BORDER_DEFAULT);
//waitKey(0);
return 0;
}