#include #include using namespace cv;
using namespace std;
const int kvalue = 15;//雙邊濾波鄰域大小
const double pi = 3.14;//圓周率
int graylevel(mat image, mat dst, point cen, int r)//求取圓形區域內的平均灰度值
} }for(int i = (cen.y - r); i <= (cen.y + r); ++i)//畫出圓,圓內畫素值為平均灰度值
}} return(graysum / n);
}int main()
sort(v.begin(), v.end());//從小到大排序
std::vectorpoints1, points2;//宣告點向量,分別儲存兩排燈的圓心座標
for (size_t i = 0; i < circles.size(); i++)//用來區分兩排燈
cv::vec4f line1, line2;//擬合直線
fitline(mat(points1), line1, cv_dist_l2, 0, 0.01, 0.01);
fitline(mat(points2), line2, cv_dist_l2, 0, 0.01, 0.01);
int x01 = (int)line1[2];
int y01 = (int)line1[3];
int x11 = (int)(x01 + 300*line1[0]);
int y11 = (int)(y01 + 300*line1[1]);
int x21 = (int)(x01 - 300*line1[0]);
int y21 = (int)(y01 - 300*line1[1]);
int x02 = (int)line2[2];
int y02 = (int)line2[3];
int x12 = (int)(x02 + 300*line2[0]);
int y12 = (int)(y02 + 300*line2[1]);
int x22 = (int)(x02 - 300*line2[0]);
int y22 = (int)(y02 - 300*line2[1]);
cv::line(dst, point(x11, y11), point(x21, y21), scalar(255), 1);//畫出直線
cv::line(dst, point(x12, y12), point(x22, y22), scalar(255), 1);
imshow("特徵提取", dst);
求取圓形區域內的平均灰度值
include include using namespace cv using namespace std const int kvalue 雙邊濾波鄰域大小 const double pi 3.14 圓周率 int graylevel mat image,mat dst,point cen,in...
求取圓形區域內的平均灰度值
include include using namespace cv using namespace std const int kvalue 15 雙邊濾波鄰域大小 const double pi 3.14 圓周率 int graylevel mat image,mat dst,point cen...
區域內點的個數
problem description x晚上睡不著的時候不喜歡玩手機,也不喜歡打遊戲,他喜歡數星星。input 多組輸入。每組先輸入乙個整數n n 10000 接著輸入兩個點代表矩形的左下點b x,y 和右上點t x,y 然後輸入n個 x,y 代表 顆星星。問有多少顆星星在窗子內部,在窗邊上的不計...