#include #include #include #include using namespace std; using namespace cv; int main() { { Mat_ img = imread("resources/go2.png",IMREAD_GRAYSCALE); imshow("eredeti", img); Mat_ dest = Mat::zeros(img.size(), CV_8UC1); for (int i = 0; i < img.cols; ++i) { for (int o = 0; o < img.rows; ++o) { dest(i, o) = abs(img(i, o) - img(i + 1, o + 1)) + abs(img(i, o + 1) - img(i + 1, o)); } } imshow("elkeres",dest); Canny(img,dest,50,160); imshow("canny",dest); } { Mat img = imread("resources/go2.png",IMREAD_GRAYSCALE); Mat dx, dy, dest; Sobel(img,dx,CV_16S,1,0); Sobel(img,dy,CV_16S,0,1); convertScaleAbs(abs(dx)+abs(dy),dest); imshow("dest",dest); } { Mat img = imread("resources/go2.png",IMREAD_GRAYSCALE); Mat dest; vector circles; //cx, cy, r HoughCircles(img, circles, HOUGH_GRADIENT, 2, 10, 80, 50, 22, 26); cout << circles.size() << endl; cvtColor(img, dest, COLOR_GRAY2BGR); for (Vec3f c : circles) { if (img.at(c[1], c[0]) > 128) { circle(dest, Point(c[0], c[1]), c[2], Scalar(0,0,255), 2); } else { circle(dest, Point(c[0], c[1]), c[2], Scalar(255, 0, 0), 2); } } imshow("korok", dest); } { Mat img = imread("resources/go2.png",IMREAD_GRAYSCALE); Mat dest; Laplacian(img,dest,CV_16S,3); convertScaleAbs(dest,dest); imshow("laplacian",dest); } waitKey(); return 0; }