我正在尝试应用不同的高斯内核和不同的sigma
Mat gaussianKernel_1 = Imgproc.getGaussianKernel(3, .2, CvType.CV_32F);
Mat gaussianKernel_1 = Imgproc.getGaussianKernel(3, 2.7, CvType.CV_32F);
在灰度图像上,通过减去它们来获得高斯DoG的差异。问题是,在应用了如下所示的高斯差异之后 ,我得到了带有尺寸的黑色图像。
这是什么意思,为什么我没有得到一个mat对象包含高斯作为图像的差异
Mat gaussianKernel_0 = Imgproc.getGaussianKernel(3, .2, CvType.CV_32F);
if (!gaussianKernel_0.empty()) {
Mat orignalGrayScaleGaussian = new Mat();
Imgproc.filter2D(grayScaleMats.getMatAt(0), orignalGrayScaleGaussian, CvType.CV_32F, gaussianKernel_0);
gauss0GrayScaleMats.newMat(orignalGrayScaleGaussian);
}
Mat gaussianKernel_1 = Imgproc.getGaussianKernel(3, 2.7, CvType.CV_32F);
if (!gaussianKernel_1.empty()) {
Mat orignalGrayScaleGaussian = new Mat();
Imgproc.filter2D(grayScaleMats.getMatAt(0), orignalGrayScaleGaussian, CvType.CV_32F, gaussianKernel_1);
gauss1GrayScaleMats.newMat(orignalGrayScaleGaussian);
}
for (int i = 0; i < 5; i++) {
Mat pyrDownDest = new Mat();
if (i == 0) {
Imgproc.pyrDown(MatFactory.lastAddedObj(gauss0GrayScaleMats.getMatList()), pyrDownDest);
downSampledMats0.newMat(pyrDownDest);
MatFactory.writeMat(FilePathUtils.newOutputPath("downSampledMat0_" + i), MatFactory.lastAddedObj(downSampledMats0.getMatList()));
} else {
Imgproc.pyrDown(MatFactory.lastAddedObj(downSampledMats0.getMatList()), pyrDownDest);
downSampledMats0.newMat(pyrDownDest);
MatFactory.writeMat(FilePathUtils.newOutputPath("downSampledMat0_" + i), MatFactory.lastAddedObj(downSampledMats0.getMatList()));
}
}
for (int i = 0; i < 5; i++) {
Mat pyrDownDest = new Mat();
if (i == 0) {
Imgproc.pyrDown(MatFactory.lastAddedObj(gauss1GrayScaleMats.getMatList()), pyrDownDest);
downSampledMats1.newMat(pyrDownDest);
MatFactory.writeMat(FilePathUtils.newOutputPath("downSampledMat1_" + i), MatFactory.lastAddedObj(downSampledMats1.getMatList()));
} else {
Imgproc.pyrDown(MatFactory.lastAddedObj(downSampledMats1.getMatList()), pyrDownDest);
downSampledMats1.newMat(pyrDownDest);
MatFactory.writeMat(FilePathUtils.newOutputPath("downSampledMat1_" + i), MatFactory.lastAddedObj(downSampledMats1.getMatList()));
}
}
Log.D(TAG, "MainClass", "downSampledMats0Size: " + downSampledMats0.getMatList().size());
Log.D(TAG, "MainClass", "downSampledMats1Size: " + downSampledMats1.getMatList().size());
Mat desResize0 = new Mat();
Mat desResize1 = new Mat();
Imgproc.resize(downSampledMats0.getMatAt(3), desResize0, downSampledMats0.getMatAt(2).size());
Imgproc.resize(downSampledMats1.getMatAt(3), desResize1, downSampledMats1.getMatAt(2).size());
Mat DoG = new Mat();
Core.subtract(desResize0, desResize1, DoG);
if (!DoG.empty()){
MatFactory.writeMat(FilePathUtils.newOutputPath("DoG"), DoG);
} else {
Log.W(TAG, "MainClass", "DoG mat is empty");
}
}