Mat source = imread("1.jpg"); //从磁盘之中读取图片
Mat circleROI2, circleROI3, circleROI4, circleROI5, circleROI6,circleROI;
Mat circleROI1; //定义圆环ROI
Mat roi1, roi2, roi,out,wzc;
Mat roi3, roi4, roi5, roi6, roi7;
Mat roia, roib, roic, roid, roie;
Mat out1, out2, out3, out4, out5, out6;
Mat wzc1, wzc2, wzc3, wzc4, wzc5, wzc6;
//三个变量都按照source的尺寸初始化为零,
roi1 = Mat::zeros(source.size(), CV_8UC1);
roi2 = Mat::zeros(source.size(), CV_8UC1);
roi3 = Mat::zeros(source.size(), CV_8UC1);
roi4 = Mat::zeros(source.size(), CV_8UC1);
roi5 = Mat::zeros(source.size(), CV_8UC1);
roi6= Mat::zeros(source.size(), CV_8UC1);
roi7= Mat::zeros(source.size(), CV_8UC1);
//在源图像之中画圆,圆的位置和尺寸是手工计算出来的
//circle()函数的最后一个参数-1表示为区域都填充为RGB(255, 255, 255)
int i = 50, b = 50;
circle(roi1, Point(512, 288), 50, CV_RGB(255, 255, 255), -1);
circle(roi2, Point(512, 288), 100, CV_RGB(255, 255, 255), -1);
circle(roi3, Point(512, 288), 150, CV_RGB(255, 255, 255), -1);
circle(roi4, Point(512, 288), 200, CV_RGB(255, 255, 255), -1);
circle(roi5, Point(512, 288), 250, CV_RGB(255, 255, 255), -1);
circle(roi6, Point(512, 288), 300, CV_RGB(255, 255, 255), -1);
circle(roi7, Point(512, 288),350, CV_RGB(255, 255, 255), -1);
//大圆减去小圆就是提出出来的圆环
cv::subtract(roi2, roi1, roi);
cv::subtract(roi3, roi2, roia);
cv::subtract(roi4, roi3, roib);
cv::subtract(roi5, roi4, roic);
cv::subtract(roi6, roi5, roid);
cv::subtract(roi7, roi6, roie);
//把圆环区域的图像复制出来,进行下一步操作,
source.copyTo(circleROI, roi);
source.copyTo(circleROI1, roia);
source.copyTo(circleROI2, roib);
source.copyTo(circleROI3, roic);
source.copyTo(circleROI4, roid);
source.copyTo(circleROI5, roie);
source.copyTo(circleROI6, roi1);
blur(circleROI, out, Size(2, 2));
blur(circleROI1, out1, Size(3, 3));
blur(circleROI2, out2, Size(4, 4));
blur(circleROI3, out3, Size(5, 5));
blur(circleROI4, out4, Size(6, 6));
blur(circleROI5, out5, Size(7, 7));
add(out, circleROI6, wzc);
add(wzc,out1, wzc1);
add(wzc1, out2, wzc2);
add(wzc2, out3, wzc3);
add(wzc3, out4, wzc4);
add(wzc4, out5, wzc5);
//显示
imshow("result",wzc5);
waitKey();