本文整理汇总了Java中org.opencv.imgproc.Imgproc.pyrDown方法的典型用法代码示例。如果您正苦于以下问题:Java Imgproc.pyrDown方法的具体用法?Java Imgproc.pyrDown怎么用?Java Imgproc.pyrDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.imgproc.Imgproc
的用法示例。
在下文中一共展示了Imgproc.pyrDown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildPyramid
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
public static List<Mat> buildPyramid(Mat mat, int maxLevel) {
List<Mat> pyramid = new ArrayList<>();
pyramid.add(mat);
for (int i = 0; i < maxLevel; i++) {
Mat m = new Mat((mat.rows() + 1) / 2, (mat.cols() + 1) / 2, mat.type());
Imgproc.pyrDown(mat, m);
pyramid.add(m);
mat = m;
}
return pyramid;
}
示例2: process
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
/**
* Process an rgba image. The results can be drawn on retrieved later.
* This method does not modify the image.
*
* @param rgbaImage An RGBA image matrix
*/
public void process(Mat rgbaImage) {
Imgproc.pyrDown(rgbaImage, mPyrDownMat);
Imgproc.pyrDown(mPyrDownMat, mPyrDownMat);
Imgproc.cvtColor(mPyrDownMat, mHsvMat, Imgproc.COLOR_RGB2HSV_FULL);
//Test whether we need two inRange operations (only if the hue crosses over 255)
if (upperBound.getScalar().val[0] <= 255) {
Core.inRange(mHsvMat, lowerBound.getScalar(), upperBound.getScalar(), mMask);
} else {
//We need two operations - we're going to OR the masks together
Scalar lower = lowerBound.getScalar().clone();
Scalar upper = upperBound.getScalar().clone();
while (upper.val[0] > 255)
upper.val[0] -= 255;
double tmp = lower.val[0];
lower.val[0] = 0;
//Mask 1 - from 0 to n
Core.inRange(mHsvMat, lower, upper, mMaskOne);
//Mask 2 - from 255-n to 255
lower.val[0] = tmp;
upper.val[0] = 255;
Core.inRange(mHsvMat, lower, upper, mMask);
//OR the two masks
Core.bitwise_or(mMaskOne, mMask, mMask);
}
//Dilate (blur) the mask to decrease processing power
Imgproc.dilate(mMask, mDilatedMask, new Mat());
List<MatOfPoint> contourListTemp = new ArrayList<>();
Imgproc.findContours(mDilatedMask, contourListTemp, mHierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
// Filter contours by area and resize to fit the original image size
contours.clear();
for (MatOfPoint c : contourListTemp) {
Core.multiply(c, new Scalar(4, 4), c);
contours.add(new Contour(c));
}
}
示例3: downsample
import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
/**
* Downsample and blur an image (using a Gaussian pyramid kernel)
*
* @param img The image
* @param scale The scale, a number greater than 1
*/
public static void downsample(Mat img, double scale) {
Imgproc.pyrDown(img, img, new Size((double) img.width() / scale, (double) img.height() / scale));
}