@@ -914,6 +914,55 @@ public void erode(){
914914 Imgproc .erode (getCurrentMat (), getCurrentMat (), new Mat ());
915915 }
916916
917+ /**
918+ * Apply a morphological operation (e.g., opening, closing) to the image with a given kernel element.
919+ *
920+ * See:
921+ * http://docs.opencv.org/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
922+ *
923+ * @param operation
924+ * The morphological operation to apply: Imgproc.MORPH_CLOSE, MORPH_OPEN,
925+ * MORPH_TOPHAT, MORPH_BLACKHAT, MORPH_GRADIENT.
926+ * @param kernelElement
927+ * The shape to apply the operation with: Imgproc.MORPH_RECT, MORPH_CROSS, or MORPH_ELLIPSE.
928+ * @param width
929+ * Width of the shape.
930+ * @param height
931+ * Height of the shape.
932+ */
933+ public void morphX (int operation , int kernelElement , int width , int height ) {
934+ Mat kernel = Imgproc .getStructuringElement (kernelElement , new Size (width , height ));
935+ Imgproc .morphologyEx (getCurrentMat (), getCurrentMat (), operation , kernel );
936+ }
937+
938+ /**
939+ * Close the image with a circle of a given size.
940+ *
941+ * See:
942+ * http://docs.opencv.org/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html#closing
943+ *
944+ * @param size
945+ * Radius of the circle to close with.
946+ */
947+ public void close (int size ) {
948+ Mat kernel = Imgproc .getStructuringElement (Imgproc .MORPH_ELLIPSE , new Size (size , size ));
949+ Imgproc .morphologyEx (getCurrentMat (), getCurrentMat (), Imgproc .MORPH_CLOSE , kernel );
950+ }
951+
952+ /**
953+ * Open the image with a circle of a given size.
954+ *
955+ * See:
956+ * http://docs.opencv.org/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html#opening
957+ *
958+ * @param size
959+ * Radius of the circle to open with.
960+ */
961+ public void open (int size ) {
962+ Mat kernel = Imgproc .getStructuringElement (Imgproc .MORPH_ELLIPSE , new Size (size , size ));
963+ Imgproc .morphologyEx (getCurrentMat (), getCurrentMat (), Imgproc .MORPH_OPEN , kernel );
964+ }
965+
917966 /**
918967 * Blur an image symetrically by a given number of pixels.
919968 *
0 commit comments