การดำเนินการทางสัณฐานวิทยาคือชุดของการดำเนินการที่ประมวลผลภาพตามรูปร่างที่กำหนด
-
การกัดเซาะ − การพังทลายเป็นการดำเนินการทางสัณฐานวิทยาระหว่างที่พิกเซลจะถูกลบออกจากขอบเขตของภาพ
-
การขยาย − ระหว่าง คือการดำเนินการทางสัณฐานวิทยาซึ่งพิกเซลจะถูกเพิ่มไปยังขอบเขตของภาพ
-
จำนวนพิกเซลที่เพิ่ม/ลบทั้งหมดขึ้นอยู่กับขนาดขององค์ประกอบโครงสร้างที่ใช้
-
การเปิดทางสัณฐานวิทยา − ในระหว่างการดำเนินการนี้ การกัดเซาะจะถูกนำไปใช้กับอินพุตที่กำหนดและการขยายผลลัพธ์จะถูกนำไปใช้ ใช้เพื่อลบวัตถุขนาดเล็กออกจากพื้นหน้าของรูปภาพ
-
การปิดทางสัณฐานวิทยา − ในระหว่างการดำเนินการนี้ การขยายจะใช้กับอินพุตที่ให้มาและการกัดเซาะของผลลัพธ์จะถูกนำไปใช้ ใช้สำหรับลบวัตถุขนาดเล็กบนรูปภาพ
หมวกทรงสูงทางสัณฐานวิทยา คือความแตกต่างระหว่างภาพที่กำหนดและการเปิด
ตัวอย่าง
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class TopHatExample {
public static void main(String args[]) {
//Loading the OpenCV core library
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
//Reading image data
String file ="D:\\Images\\morph_input1.jpg";
Mat src = Imgcodecs.imread(file);
//Creating destination matrix
Mat dst = new Mat(src.rows(), src.cols(), src.type());
//Preparing the kernel matrix object
Mat kernel = Mat.ones(5,5, CvType.CV_32F);
//Applying dilate on the Image
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel);
//Displaying the image
HighGui.imshow("Blackhat Gradient", dst);
HighGui.waitKey();
}
} ใส่รูปภาพ

ผลลัพธ์

หมวกดำสัณฐาน คือความแตกต่างระหว่างการปิดและภาพที่กำหนด
ตัวอย่าง
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class TopHatExample {
public static void main(String args[]) {
//Loading the OpenCV core library
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
//Reading image data
String file ="D:\\Images\\morph_input1.jpg";
Mat src = Imgcodecs.imread(file);
//Creating destination matrix
Mat dst = new Mat(src.rows(), src.cols(), src.type());
//Preparing the kernel matrix object
Mat kernel = Mat.ones(5,5, CvType.CV_32F);
//Applying dilate on the Image
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_BLACKHAT, kernel);
//Displaying the image
HighGui.imshow("Blackhat Gradient", dst);
HighGui.waitKey();
}
} ใส่รูปภาพ

ผลลัพธ์
