java - 在java opencv中使用dilate时更改大小

标签 java android opencv

我在java中使用opencv。我面临这个奇怪的问题,在我执行 dilate 功能后,我的图像改变了它的大小。在 documentation明确表示:

dst - output image of the same size and type as src.

我的代码是:

Log.d(TAG, "dilate size1  " + dilate.size().height + " " + dilate.size().width);
Imgproc.GaussianBlur(warpg, smooth, new Size(3, 3), 3);
Log.d(TAG, "smooth size1  " + smooth.size().height + " " + smooth.size().width);
Imgproc.adaptiveThreshold(smooth, thresh, 255, 0, 1, 5, 2);
Log.d(TAG, "thresh size1  " + thresh.size().height + " " + thresh.size().width);
kernel = Imgproc.getStructuringElement(Imgproc.MORPH_CROSS, new Size(3, 3));
Imgproc.erode(thresh, erode, kernel, new Point(-1, -1), 1);
Log.d(TAG, "erode size1  " + erode.size().height + " " + erode.size().width);
Imgproc.dilate(erode, dilate, kernel, new Point(-1, -1), 1);
Imgproc.findContours(thresh, contours, hierarchy,
        Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE);
Log.d(TAG, "dilate size2  " + dilate.size().height + " " + dilate.size().width);

输出为:

dilate size1  450.0 450.0
smooth size1  450.0 450.0
thresh size1  450.0 450.0
erode size1  450.0 450.0
dilate size2  1.0 313.0

有什么想法吗?

最佳答案

我解决了做:

dilate = new Mat(erode.rows(), erode.cols(), erode.type());
erode.copyTo(dilate);
Imgproc.dilate(dilate, dilate, kernel, new Point(-1, -1), 1);

干杯。

关于java - 在java opencv中使用dilate时更改大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30198947/

相关文章:

java - 按字符串中的第二个单词对 ArrayList 进行排序

java - Hibernate Criteria 通过获取错误进行分组

java - 我无法导入 org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer

java - 存储库模式 : Can a repository use other repositories?

android - 将数据从一个 Activity 设置到另一个 Activity

Android列 '_id'不存在?

android - 与proguard混淆

python - 在图像中获取新对象

matlab - 相机到校准图案的距离会影响校准参数吗?

android - OpenCV InRange 参数