morphologyEx
void Demo_1(int, void*) { cvtColor(img1, img_gray1, COLOR_BGR2GRAY); //二值化 threshold(img_gray1, img2, 0, 255, THRESH_BINARY | THRESH_OTSU); imshow(win2,img2); //形态学操作 Mat kernel1 = getStructuringElement(MorphShapes::MORPH_RECT, Size(3, 3), Point(-1, -1)); morphologyEx(img2, img3, MORPH_OPEN, kernel1, Point(-1, -1)); imshow(win3,img3); }
##################