OpenCV (2)

lena0

OpenCVを使えば、画像のフィルタリングは簡単です。

lena1

lena2

lena3

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char** argv )
{
    Mat image;
    image = imread("/Users/user1/Desktop/lena_std.tif", 1 );
    namedWindow("OpenCV 0", WINDOW_AUTOSIZE );
    imshow("OpenCV 0", image);

    Mat gray_image;
    cvtColor(image, gray_image, CV_BGR2GRAY);
    namedWindow("OpenCV 1", WINDOW_AUTOSIZE );
    imshow("OpenCV 1", gray_image);

    Mat blur_image;
    GaussianBlur(image, blur_image, Size(7, 7), 0, 0);
    namedWindow("OpenCV 2", WINDOW_AUTOSIZE );
    imshow("OpenCV 2", blur_image);
    
    Mat edge_image;
    Laplacian(image, edge_image, CV_8U, 3, 1.0, 0.0, BORDER_DEFAULT);
    namedWindow("OpenCV 3", WINDOW_AUTOSIZE );
    imshow("OpenCV 3", edge_image);
    
    waitKey(0);
    
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.