说明
- 最近在做关于区域筛选问题的相关内容,考虑了一些聚类分析算法,但是对于ROI区域还是不能完全做到独立和分割,因此采用这种方法在一定范围内可以时边缘区域模糊掉,只处理中心区域或者中间区域的图片信息,当然对于目标离散的图片,不适合这种方法进行目标处理,还需要进一步挖掘相关算法进行优化。
#include "stdafx.h"
#include"cv.h"
#include"highgui.h"
#include
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
Mat img = imread("C:\\Users\\Administrator\\Desktop\\B0.bmp");
Point root_points[1][6];
root_points[0][0] = Point(5,5);
root_points[0][1] = Point(img.cols,5);
root_points[0][2] = Point(img.cols,225);
root_points[0][3] = Point(465,225);
root_points[0][4] = Point(215,220);
root_points[0][5] = Point(5,220);
const Point* ppt[1] = {root_points[0]};
int npt[] = {6};
polylines(img, ppt, npt, 1, 1, Scalar(255),1,8,0);
fillPoly(img, ppt, npt, 1, Scalar(255,255,255));
Point root_points_1[1][8];
root_points_1[0][0] = Point(0,860);
root_points_1[0][1] = Point(img.cols,860);
root_points_1[0][2] = Point(img.cols,860);
root_points_1[0][3] = Point(img.cols,860);
root_points_1[0][4] = Point(img.cols,860);
root_points_1[0][5] = Point(img.cols,860);
root_points_1[0][6] = Point(img.cols,img.rows);
root_points_1[0][7] = Point(0,img.rows);
const Point* ppt_1[1] = {root_points_1[0]};
int npt_1[] = {8};
polylines(img, ppt_1, npt_1, 1, 1, Scalar(255),1,8,0);
imshow("Test", img);
waitKey(1000);
fillPoly(img, ppt_1, npt_1, 1, Scalar(255,255,255));
imshow("img",img);
waitKey(0);
return 0;
}
结果展示