案例表述:在一幅图片中,有圆形和类圆形,有些类似于星云的照片,其中把一个圆提取出来。
#include <opencv2/opencv.hpp>
#include <iostream>
#include <math.h>
using namespace cv;
using namespace std;
Mat src, binary, dst;
int main(int argc, char** argv) {
src = imread("D:/images/case.png", IMREAD_GRAYSCALE);
if (src.empty()) {
printf("could not load image...\n");
return -1;
}
namedWindow("input image", WINDOW_AUTOSIZE);
imshow("input image", src);
// 二值化
threshold(src, binary, 0, 255, THRESH_BINARY | THRESH_OTSU