OpenCV阈值分割

#include 

#include 

#include 

#include 

#include 

using namespace std;

using namespace cv;

int main()

{

    Mat ScrImage, ScrImgaeCopy1, OutImage, OutImage1, OutImage2, OutImage3, OutImage4, OutImage5, OutImage6, OutImage7, OutImage8, OutImage9;

    ScrImage = imread("1.jpg", 0); //读入图像 \\image1.jpg brownbug.jpg whitebug.jpg

    imshow("【原图】", ScrImage);

    threshold(ScrImage, OutImage1, 90, 255, CV_THRESH_BINARY);//固定阈值分割

    adaptiveThreshold(ScrImage, OutImage2, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, 31, 10);//自适应阈值分割

    cout <<"图像的行:"  << ScrImage.rows << "\n" << "图像的列:" << ScrImage.cols << endl;
    cout << "\n" << "像素3,4处的灰度值:" << int(ScrImage.at(3, 4)) << endl;

    imshow("【固定阈值处理:二值化】", OutImage1);

    imshow("【自动阈值处理:二值化】", OutImage2);

    waitKey(0);

    return NULL;

}

 

你可能感兴趣的:(opencv)