1 module dcv.example.morph; 2 3 /** 4 * Image morphological operations example using DCV library. 5 */ 6 7 import dcv.core; 8 import dcv.io; 9 import dcv.imgproc; 10 import dcv.plot; 11 12 13 void main() 14 { 15 Image image = imread("../data/lena.png"); 16 17 auto slice = image.sliced.rgb2gray; 18 auto thesholded = slice.threshold!ubyte(30, 60); 19 auto dilated = thesholded.dilate(radialKernel!ubyte(5)); 20 auto eroded = thesholded.erode(radialKernel!ubyte(5)); 21 auto opened = thesholded.open(radialKernel!ubyte(5)); 22 auto closed = thesholded.close(radialKernel!ubyte(5)); 23 24 slice.imshow("Original"); 25 thesholded.imshow("Thresholded"); 26 dilated.imshow("Dilated"); 27 eroded.imshow("Eroded"); 28 opened.imshow("Opened"); 29 closed.imshow("Closed"); 30 31 waitKey(); 32 }