@@ -927,6 +927,55 @@ public void erode(){
927927 Imgproc .erode (getCurrentMat (), getCurrentMat (), new Mat ());
928928 }
929929
930+ /**
931+ * Apply a morphological operation (e.g., opening, closing) to the image with a given kernel element.
932+ *
933+ * See:
934+ * http://docs.opencv.org/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
935+ *
936+ * @param operation
937+ * The morphological operation to apply: Imgproc.MORPH_CLOSE, MORPH_OPEN,
938+ * MORPH_TOPHAT, MORPH_BLACKHAT, MORPH_GRADIENT.
939+ * @param kernelElement
940+ * The shape to apply the operation with: Imgproc.MORPH_RECT, MORPH_CROSS, or MORPH_ELLIPSE.
941+ * @param width
942+ * Width of the shape.
943+ * @param height
944+ * Height of the shape.
945+ */
946+ public void morphX (int operation , int kernelElement , int width , int height ) {
947+ Mat kernel = Imgproc .getStructuringElement (kernelElement , new Size (width , height ));
948+ Imgproc .morphologyEx (getCurrentMat (), getCurrentMat (), operation , kernel );
949+ }
950+
951+ /**
952+ * Close the image with a circle of a given size.
953+ *
954+ * See:
955+ * http://docs.opencv.org/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html#closing
956+ *
957+ * @param size
958+ * Radius of the circle to close with.
959+ */
960+ public void close (int size ) {
961+ Mat kernel = Imgproc .getStructuringElement (Imgproc .MORPH_ELLIPSE , new Size (size , size ));
962+ Imgproc .morphologyEx (getCurrentMat (), getCurrentMat (), Imgproc .MORPH_CLOSE , kernel );
963+ }
964+
965+ /**
966+ * Open the image with a circle of a given size.
967+ *
968+ * See:
969+ * http://docs.opencv.org/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html#opening
970+ *
971+ * @param size
972+ * Radius of the circle to open with.
973+ */
974+ public void open (int size ) {
975+ Mat kernel = Imgproc .getStructuringElement (Imgproc .MORPH_ELLIPSE , new Size (size , size ));
976+ Imgproc .morphologyEx (getCurrentMat (), getCurrentMat (), Imgproc .MORPH_OPEN , kernel );
977+ }
978+
930979 /**
931980 * Blur an image symetrically by a given number of pixels.
932981 *
0 commit comments