本文整理匯總了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));
}