#include #include #include #include using namespace std; using namespace cv; int main() { { Mat img = imread("resources/galaxy.jpg",IMREAD_GRAYSCALE); Mat se = getStructuringElement(MORPH_RECT, Size(5, 5)); Mat dest; morphologyEx(img, dest, MORPH_TOPHAT,se); imshow("img", img); imshow("dest", dest); } { Mat img = imread("resources/dog.jpg",IMREAD_GRAYSCALE); Mat dest; threshold(img, dest, 100, 255, THRESH_BINARY); imshow("kuszoboles",dest); Mat se = getStructuringElement(MORPH_RECT, Size(3, 3)); morphologyEx(dest,dest,MORPH_OPEN,se); imshow("morphed",dest); } { Mat img = imread("resources/sajt.jpg",IMREAD_GRAYSCALE); Mat dest; Mat se = getStructuringElement(MORPH_RECT, Size(5, 5)); morphologyEx(img,dest,MORPH_GRADIENT,se); imshow("morphed1",dest); Mat binary; Mat se2 = getStructuringElement(MORPH_ELLIPSE, Size(14,14)); threshold(img,binary,250,255,THRESH_BINARY_INV); morphologyEx(binary,dest,MORPH_CLOSE,se2); imshow("morphed2",dest); } { Mat img = imread("resources/szitakoto.jpg",IMREAD_GRAYSCALE); threshold(img,img,190,210,THRESH_BINARY); Mat se = getStructuringElement(MORPH_ELLIPSE,Size(15,15)); morphologyEx(img,img,MORPH_OPEN,se); imshow("img",img); int count = 0; for (int i = 0; i < img.rows; i++) { for (int o = 0; o < img.rows; o++) { if (!img.at(i,o)) { count++; } } } cout< points; for (int i = 0; i < hitmiss.rows; i++) { for (int o = 0; o < hitmiss.cols; o++) { if (hitmiss.at(o,i)) { points.push_back(Point(i,o)); } } } for (Point p : points) { drawMarker(img,p,Scalar(0,255,0),MARKER_CROSS); } imshow("hitmiss",img); } waitKey(); return 0; }