Created
February 21, 2017 14:21
-
-
Save atinfinity/f1a6534bd86aa32aed01c05f0a223126 to your computer and use it in GitHub Desktop.
線画抽出サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/core.hpp> | |
#include <opencv2/imgproc.hpp> | |
#include <opencv2/imgcodecs.hpp> | |
#include <opencv2/highgui.hpp> | |
#include <iostream> | |
int main(int argc, const char* argv[]) | |
{ | |
if (argc < 2) | |
{ | |
std::cout << "Usage: ./line_drawing <filename>" << std::endl; | |
return -1; | |
} | |
cv::Mat src = cv::imread(argv[1], cv::IMREAD_GRAYSCALE); | |
if (src.empty()) | |
{ | |
std::cout << "Error: Could not load image file." << std::endl; | |
return -1; | |
} | |
cv::Mat temp, dst; | |
cv::dilate(src, temp, cv::Mat(), cv::Point(-1, -1), 1); | |
cv::absdiff(src, temp, dst); | |
cv::bitwise_not(dst, dst); | |
cv::imshow("line drawing", dst); | |
cv::waitKey(0); | |
cv::destroyAllWindows(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment