不同窗口的高斯平滑10-1
Mat m1 = imread("D:\\编程\\opencv\\opencv\\opencv\\sources\\samples\\data\\blox.jpg", -1);
namedWindow("raw");
imshow("raw", m1);
Mat m_3by3, m_5by5, m_9by9, m_11by11;
GaussianBlur(m1, m_3by3, Size(3, 3), 0.0);
namedWindow("3*3");
imshow("3*3", m_3by3);
GaussianBlur(m1, m_5by5, Size(5, 5), 0.0);
namedWindow("5*5");
imshow("5*5", m_5by5);
GaussianBlur(m1, m_9by9, Size(9, 9), 0.0);
namedWindow("9*9");
imshow("9*9", m_9by9);
GaussianBlur(m1, m_11by11, Size(11,11), 0.0);
namedWindow("11*11");
imshow("11*11", m_11by11);
GaussianBlur(m_5by5, m_5by5, Size(5, 5), 0.0);
namedWindow("5*5_twice");
imshow("5*5_twice", m_5by5);
destroyAllWindows();
中心一个亮点的高斯平滑10-2
Mat m2 = Mat::zeros(100, 100, CV_8UC1);
m2.at<uchar>(Point(49, 50)) = 255;
m2.at<uchar>(Point(49, 49)) = 255;
m2.at<uchar>(Point(50, 49)) = 255;
m2.at<uchar>(Point(50,50)) = 255;
Mat m2_5by5,m2_9by9, m2_5by5_2;
GaussianBlur(m2, m2_5by5, Size(5, 5), 0.0);
GaussianBlur(m2, m2_9by9, Size(9, 9), 0.0);
namedWindow("raw",0);
imshow("raw", m2);
namedWindow("m25*5",0);
imshow("m25*5", m2_5by5);
namedWindow("m29*9",0);
imshow("m29*9", m2_9by9);
GaussianBlur(m2_5by5, m2_5by5_2, Size(5, 5), 0.0);
namedWindow("m25*5_twice", 0);
imshow("m25*5_twice", m2_5by5_2);
图像阈值化10-11
Mat m10 = imread("D:\\编程\\opencv\\opencv\\opencv\\sources\\samples\\data\\detect_blob.png");
cvtColor(m10, m10, COLOR_BGR2GRAY);
namedWindow("raw", 0);
imshow("raw", m10);
Mat m10_tophat,m10_mask;
Mat kn = getStructuringElement(MORPH_RECT, Size(51,51));
morphologyEx(m10, m10_tophat, MORPH_TOPHAT, kn);
namedWindow("tophat", 0);
imshow("tophat", m10_tophat);
threshold(m10, m10_mask, THRESH_OTSU, 255, THRESH_TOZERO);
namedWindow("thresh", 0);
imshow("thresh", m10_mask);
waitKey(0);
destroyAllWindows();