记录贴~
环境:OpenCV3.2 C++
#include<opencv2\opencv.hpp>
using namespace std;
using namespace cv;
Mat org;
Mat img;
Mat imgROI;
Mat roiResize;
Mat tranPart;
int foo = 30;
int fooResize = 2 * foo;
void on_Mouse(int event, int x, int y, int flag, void*ustc) {
Mat img_temp = img.clone();
if (x>fooResize && x<img_temp.cols-fooResize && y>fooResize && y<img_temp.rows-fooResize) {
imgROI = img_temp(Rect(x - foo, y - foo, 2 * foo, 2 * foo));
tranPart = img_temp(Range(y - 2 * foo, y + 2 * foo), Range(x - 2 * foo, x + 2 * foo));
resize(imgROI, roiResize, Size(2 * imgROI.cols, 2 * imgROI.rows));
roiResize.copyTo(tranPart);
circle(img_temp, Point(x, y), 10, Scalar(0, 0, 255), 1, 8, 0);
imshow("img", img_temp);
}
}
int main() {
org = imread("lena.png");
img = org.clone();
namedWindow("img&