本文整理汇总了Java中org.opencv.imgproc.Imgproc.morphologyEx方法的典型用法代码示例。如果您正苦于以下问题:Java Imgproc.morphologyEx方法的具体用法?Java Imgproc.morphologyEx怎么用?Java Imgproc.morphologyEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.imgproc.Imgproc
的用法示例。
在下文中一共展示了Imgproc.morphologyEx方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: denoise
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static void denoise() {
String imgInPath = "captchaExample.jpg";
imgInPath = "MyCaptcha.PNG";
imgInPath = "blurredtext.jpg";
String imgOutPath = "captchaNoiseRemovedExample.png";
imgOutPath = "MyNoiseRemovedCaptcha.PNG";
Mat image = Imgcodecs.imread(imgInPath);
Mat out = new Mat();
Mat tmp = new Mat();
Mat kernel = new Mat(new Size(3, 3), CvType.CV_8UC1, new Scalar(255));
// Mat kernel = new Mat(image.size(), CvType.CV_8UC1, new Scalar(255));
Imgproc.morphologyEx(image, tmp, Imgproc.MORPH_OPEN, kernel);
Imgproc.morphologyEx(tmp, out, Imgproc.MORPH_CLOSE, kernel);
Imgcodecs.imwrite(imgOutPath, out);
}
示例2: noiseRemoval
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public void noiseRemoval() {
// Mat Kernel = cv::Mat(cv::Size(Maximum_Width_of_Noise,Maximum_Height_of_noise),CV_8UC1,cv::Scalar(255));
Mat Kernel = new Mat(new Size(3, 3), CvType.CV_8U, new Scalar(255));
Mat source = Imgcodecs.imread("noiseExample.png");
Mat temp = new Mat();
Mat topHat = new Mat();
Mat destination = new Mat();
Imgproc.morphologyEx(source, temp, Imgproc.MORPH_OPEN, Kernel);
Imgproc.morphologyEx(temp, destination, Imgproc.MORPH_CLOSE, Kernel);
// Imgproc.morphologyEx(temp, topHat, Imgproc.MORPH_GRADIENT, Kernel);
// Imgproc.morphologyEx(topHat, destination, Imgproc.MORPH_CLOSE, Kernel);
Imgcodecs.imwrite("noiseRemovedExample.png", source);
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:15,代码来源:OpenCVNonMavenExamples.java
示例3: apply_filters
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public Mat apply_filters(Mat input_mat) {
Mat blurred = new Mat();
Mat edges = new Mat();
Mat structure = new Mat();
Imgproc.GaussianBlur(input_mat,blurred,new Size(3,3),1); //Jack-ify the image
Imgproc.bilateralFilter(blurred,blurred,11,17,17);
Imgproc.Canny(blurred,edges,20,50);
structure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT,new Size(45,45));
Imgproc.morphologyEx(edges,edges,Imgproc.MORPH_CLOSE,structure);
return edges;
}