當前位置: 首頁>>代碼示例>>Java>>正文


Java Mat.zeros方法代碼示例

本文整理匯總了Java中org.opencv.core.Mat.zeros方法的典型用法代碼示例。如果您正苦於以下問題:Java Mat.zeros方法的具體用法?Java Mat.zeros怎麽用?Java Mat.zeros使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opencv.core.Mat的用法示例。


在下文中一共展示了Mat.zeros方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: RectangleSubROI

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat RectangleSubROI(Mat input, Rect rect) {
	final Mat maskCopyTo = Mat.zeros(input.size(), CvType.CV_8UC1); // ����copyTo������mask����С��ԭͼ����һ��
	// floodFill��mask��width��height�����������ͼ��������������أ��������ᱨ��
	final Mat maskFloodFill = Mat.zeros(new Size(input.cols() + 2, input.rows() + 2), CvType.CV_8UC1); // ����floodFill������mask���ߴ��ԭͼ��һЩ
	// Imgproc.circle(maskCopyTo, new Point(cc.x, cc.y), radius, Scalar.all(255), 2,
	// 8, 0); // ����Բ������
	Imgproc.rectangle(maskCopyTo, rect.tl(), rect.br(), Scalar.all(255), 2, 8, 0);
	Imgproc.floodFill(maskCopyTo, maskFloodFill,
			new Point((rect.tl().x + rect.br().x) / 2, (rect.tl().y + rect.br().y) / 2), Scalar.all(255), null,
			Scalar.all(20), Scalar.all(20), 4); // ��ˮ��䷨���Բ���ڲ�
	// MatView.imshow(maskFloodFill, "Mask of floodFill"); // ����floodFill������mask
	// MatView.imshow(maskCopyTo, "Mask of copyTo"); // ����copyTo������mask
	final Mat imgRectROI = new Mat();
	input.copyTo(imgRectROI, maskCopyTo); // ��ȡԲ�ε�ROI
	// MatView.imshow(imgCircularROI, "Circular ROI"); // ��ʾԲ�ε�ROI
	return imgRectROI;
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:18,代碼來源:ROI_Irregular.java

示例2: adaptativeProcess

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat adaptativeProcess(Mat img){
	Mat im = new Mat();
	Imgproc.threshold(img,im,120,255,Imgproc.THRESH_TRUNC);
	im = Thresholding.adaptativeThresholding(im);
	Imgproc.medianBlur(im,im,7);
	Mat threshImg = Thresholding.InvertImageColor(im);
	Thresholding.gridDetection(threshImg);
	
		Mat mat = Mat.zeros(4,2,CvType.CV_32F);
	mat.put(0,0,0); mat.put(0,1,512);
	mat.put(1,0,0); mat.put(1,1,0);
	mat.put(2,0,512); mat.put(2,1,0);
	mat.put(3,0,512); mat.put(3,1,512);
	
	mat = Imgproc.getPerspectiveTransform(Thresholding.grid,mat);
	
	Mat M = new Mat();
	
	Imgproc.warpPerspective(threshImg,M,mat, new Size(512,512));
	
	Imgproc.medianBlur(M,M,3);
	Imgproc.threshold(M,M,254,255,Imgproc.THRESH_BINARY);
	
	return Thresholding.InvertImageColor(M);
}
 
開發者ID:Sanahm,項目名稱:SudoCAM-Ku,代碼行數:26,代碼來源:Thresholding.java

示例3: normalProcess

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat normalProcess(Mat img){
	Mat threshImg = Thresholding.InvertImageColor(img);
	Thresholding.gridDetection(threshImg);
	Mat mat = Mat.zeros(4,2,CvType.CV_32F);
	mat.put(0,0,0); mat.put(0,1,512);
	mat.put(1,0,0); mat.put(1,1,0);
	mat.put(2,0,512); mat.put(2,1,0);
	mat.put(3,0,512); mat.put(3,1,512);
	
	mat = Imgproc.getPerspectiveTransform(Thresholding.grid,mat);
	
	Mat M = new Mat();
	
	Imgproc.warpPerspective(threshImg,M,mat, new Size(512,512));
	return Thresholding.InvertImageColor(M);
}
 
開發者ID:Sanahm,項目名稱:SudoCAM-Ku,代碼行數:17,代碼來源:Thresholding.java

示例4: Saliency

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat Saliency(Mat img) {
	// blur image with a 3x3 or 5x5 Gaussian filter
	Mat gfbgr = new Mat();
	Imgproc.GaussianBlur(img, gfbgr, new Size(3, 3), 3);
	// Perform sRGB to CIE Lab color space conversion
	Mat LabIm = new Mat();
	Imgproc.cvtColor(gfbgr, LabIm, Imgproc.COLOR_BGR2Lab);
	// Compute Lab average values (note that in the paper this average is found from the
	// un-blurred original image, but the results are quite similar)
	List<Mat> lab = new ArrayList<>();
	Core.split(LabIm, lab);
	Mat l = lab.get(0);
	l.convertTo(l, CvType.CV_32F);
	Mat a = lab.get(1);
	a.convertTo(a, CvType.CV_32F);
	Mat b = lab.get(2);
	b.convertTo(b, CvType.CV_32F);
	double lm = Core.mean(l).val[0];
	double am = Core.mean(a).val[0];
	double bm = Core.mean(b).val[0];
	// Finally compute the saliency map
	Mat sm = Mat.zeros(l.rows(), l.cols(), l.type());
	Core.subtract(l, new Scalar(lm), l);
	Core.subtract(a, new Scalar(am), a);
	Core.subtract(b, new Scalar(bm), b);
	Core.add(sm, l.mul(l), sm);
	Core.add(sm, a.mul(a), sm);
	Core.add(sm, b.mul(b), sm);
	return sm;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:31,代碼來源:FeatureWeight.java

示例5: Exposedness

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat Exposedness(Mat img) {
	double sigma = 0.25;
	double average = 0.5;
	int rows = img.rows();
	int cols = img.cols();
	Mat exposedness = Mat.zeros(rows, cols, img.type());
	// W = exp(-(img - aver).^2 / (2*sigma^2));
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			double value = Math.exp(-1.0 * Math.pow(img.get(i, j)[0] - average, 2.0) / (2 * Math.pow(sigma, 2.0)));
			exposedness.put(i, j, value);
		}
	}
	return exposedness;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:16,代碼來源:FeatureWeight.java

示例6: Circle

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat Circle(Mat circularInput, Point cc, int radius) {
	final Mat maskCopyTo = Mat.zeros(circularInput.size(), CvType.CV_8UC1); // ����copyTo������mask����С��ԭͼ����һ��
	// floodFill��mask��width��height�����������ͼ��������������أ��������ᱨ��
	final Mat maskFloodFill = Mat.zeros(new Size(circularInput.cols() + 2, circularInput.rows() + 2),
			CvType.CV_8UC1); // ����floodFill������mask���ߴ��ԭͼ��һЩ
	Imgproc.circle(maskCopyTo, new Point(cc.x, cc.y), radius, Scalar.all(255), 2, 8, 0); // ����Բ������
	Imgproc.floodFill(maskCopyTo, maskFloodFill, new Point(207, 290), Scalar.all(255), null, Scalar.all(20),
			Scalar.all(20), 4); // ��ˮ��䷨���Բ���ڲ�
	// MatView.imshow(maskFloodFill, "Mask of floodFill"); // ����floodFill������mask
	// MatView.imshow(maskCopyTo, "Mask of copyTo"); // ����copyTo������mask
	final Mat imgCircularROI = new Mat();
	circularInput.copyTo(imgCircularROI, maskCopyTo); // ��ȡԲ�ε�ROI
	// MatView.imshow(imgCircularROI, "Circular ROI"); // ��ʾԲ�ε�ROI
	return imgCircularROI;
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:16,代碼來源:ROI_Irregular.java

示例7: irregularQuadrangle_Simplified

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat irregularQuadrangle_Simplified(Mat irrInput, Point p1, Point p2, Point p3, Point p4,
		double shift_x, double shift_y, boolean noULandLRcorner, double ulCornerRatio, double lrCornerRatio) {
	final Mat maskCopyTo = Mat.zeros(irrInput.size(), CvType.CV_8UC1); // ����copyTo������mask����С��ԭͼ����һ��

	// �����ĵ���Ϊ��ʼ����
	final double centerX = (p1.x + p2.x + p3.x + p4.x) / 4;
	final double centerY = (p1.y + p2.y + p3.y + p4.y) / 4;
	final Point cc = new Point(centerX, centerY);

	final List<MatOfPoint> counter = new ArrayList<>();
	final Point aP1 = new Point(p1.x + shift_x, p1.y + shift_y);
	final Point aP2 = new Point(p2.x - shift_x, p2.y + shift_y);
	final Point aP3 = new Point(p3.x + shift_x, p3.y - shift_y);
	final Point aP4 = new Point(p4.x - shift_x, p4.y - shift_y);

	if (noULandLRcorner) {
		final Point aP1L = new Point(aP1.x, aP1.y + (aP3.y - aP1.y) * ulCornerRatio);
		final Point aP1R = new Point(aP1.x + (aP2.x - aP1.x) * ulCornerRatio, aP1.y);
		final Point aP4L = new Point(aP4.x - (aP4.x - aP3.x) * lrCornerRatio, aP4.y);
		final Point aP4R = new Point(aP4.x, aP4.y - (aP4.y - aP2.y) * lrCornerRatio);

		counter.add(new MatOfPoint(aP1L, aP1R, aP2, aP4R, aP4L, aP3)); // ����һ��������Ķ���Σ�û�����ϽǺ����½�
	} else
		counter.add(new MatOfPoint(aP1, aP2, aP4, aP3)); // ����һ��������Ķ����

	// floodFill��mask��width��height�����������ͼ��������������أ��������ᱨ��
	Imgproc.drawContours(maskCopyTo, counter, -1, Scalar.all(255)); // ��������
	// MatView.imshow(maskCopyTo, "Irregular shape edge");
	final Mat maskFloodFill = new Mat(irrInput.rows() + 2, irrInput.cols() + 2, CvType.CV_8UC1); // ����floodFill������mask���ߴ��ԭͼ��һЩ
	Imgproc.floodFill(maskCopyTo, maskFloodFill, new Point(centerX, centerY), Scalar.all(255), null, Scalar.all(20),
			Scalar.all(20), 4); // ��ˮ��䷨����ڲ�
	// MatView.imshow(maskFloodFill, "Irregular shape��Mask of floodFill"); //
	// ����copyTo������mask
	// MatView.imshow(maskCopyTo, "Irregular shape��Mask of copyTo"); //
	// ����floodFill������mask
	final Mat imgIrregularROI = new Mat();
	irrInput.copyTo(imgIrregularROI, maskCopyTo); // ��ȡ��������״��ROI
	// MatView.imshow(imgIrregularROI, "Irregular shape ROI");
	return imgIrregularROI;
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:41,代碼來源:ROI_Irregular.java

示例8: ExtractBoxes

import org.opencv.core.Mat; //導入方法依賴的package包/類
/**
*/
public static Mat ExtractBoxes(Mat im, Mat enhance, int connectiviy){
	try{
		Mat stats = new Mat();
		Mat imB = Processing.binarize(im,Imgproc.THRESH_OTSU);
		Imgproc.connectedComponentsWithStats(imB.mul(enhance),new Mat(),stats,new Mat(),connectiviy,CvType.CV_32S);
		
		Mat stat = Mat.zeros(81,5,CvType.CV_32F);
		double max_area = stats.get(0,2)[0] * stats.get(0,3)[0];
		int j = 0;
		for(int i = 1; i < stats.height(); i++){
			double area = stats.get(i,2)[0] * stats.get(i,3)[0];
			if(area < max_area/70 && area > max_area/120){
				stat.put(j,0,stats.get(i,0)[0]);
				stat.put(j,1,stats.get(i,1)[0]);
				stat.put(j,2,stats.get(i,2)[0]);
				stat.put(j,3,stats.get(i,3)[0]);
				stat.put(j,4,stats.get(i,4)[0]);
				j +=1;
					
			}
			
		}
		stat = Processing.statSorted(stat,0);
		if(stat.get(0,0)[0] == 0 && stat.get(0,1)[0] ==0 && (stat.get(0,2)[0] ==0 || stat.get(0,3)[0] ==0))
			return null;
		return stat;
	}
	catch(Exception e){
		return null;
	}
}
 
開發者ID:Sanahm,項目名稱:SudoCAM-Ku,代碼行數:34,代碼來源:Processing.java

示例9: fillContour

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static void fillContour(Mat im, List<Point> contour, Point seed) {
    Mat mask = Mat.zeros(new Size(im.width() + 2, im.height() + 2), CvType.CV_8UC1);

    int len = contour.size();
    for (int i = 0; i < len; ++i) {
        int next_i = (i + 1) % len;
        Imgproc.line(im, contour.get(i), contour.get(next_i), Util.SCALAR_WHITE, 2);
    }
    Imgproc.floodFill(im, mask, seed, Util.SCALAR_WHITE);
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:11,代碼來源:Util.java

示例10: fillContours

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat fillContours(Size size, List<MatOfPoint> contours, Point[] seeds) {
    Mat im = Mat.zeros(size, CvType.CV_8U);
    Mat mask = Mat.zeros(new Size(size.width + 2, size.height + 2), CvType.CV_8U);

    for (int ind = 0; ind < contours.size(); ++ind) {
        Imgproc.drawContours(mask, contours, ind, Util.SCALAR_WHITE);
    }

    for (Point p : seeds) {
        Imgproc.floodFill(im, mask, p, Util.SCALAR_WHITE);
    }

    return im;
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:15,代碼來源:Util.java

示例11: Saliency

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat Saliency(Mat img) {
	// blur image with a 3x3 or 5x5 Gaussian filter
	Mat gfbgr = new Mat();
	Imgproc.GaussianBlur(img, gfbgr, new Size(3, 3), 3);
	// Perform sRGB to CIE Lab color space conversion
	Mat LabIm = new Mat();
	Imgproc.cvtColor(gfbgr, LabIm, Imgproc.COLOR_BGR2Lab);
	// Compute Lab average values (note that in the paper this average is found from the
	// un-blurred original image, but the results are quite similar)
	List<Mat> lab = new ArrayList<Mat>();
	Core.split(LabIm, lab);
	Mat l = lab.get(0);
	l.convertTo(l, CvType.CV_32F);
	Mat a = lab.get(1);
	a.convertTo(a, CvType.CV_32F);
	Mat b = lab.get(2);
	b.convertTo(b, CvType.CV_32F);
	double lm = Core.mean(l).val[0];
	double am = Core.mean(a).val[0];
	double bm = Core.mean(b).val[0];
	// Finally compute the saliency map
	Mat sm = Mat.zeros(l.rows(), l.cols(), l.type());
	Core.subtract(l, new Scalar(lm), l);
	Core.subtract(a, new Scalar(am), a);
	Core.subtract(b, new Scalar(bm), b);
	Core.add(sm, l.mul(l), sm);
	Core.add(sm, a.mul(a), sm);
	Core.add(sm, b.mul(b), sm);
	return sm;
}
 
開發者ID:IsaacChanghau,項目名稱:ImageEnhanceViaFusion,代碼行數:31,代碼來源:WeightCalculate.java

示例12: unevenLightCompensate

import org.opencv.core.Mat; //導入方法依賴的package包/類
/**
 * 其主要思路為:
	1、求取源圖I的平均灰度,並記錄rows和cols;
	2、按照一定大小,分為N*M個方塊,求出每塊的平均值,得到子塊的亮度矩陣D;
	3、用矩陣D的每個元素減去源圖的平均灰度,得到子塊的亮度差值矩陣E;
	4、用雙立方差值法,將矩陣E差值成與源圖一樣大小的亮度分布矩陣R;
	5、得到矯正後的圖像result=I-R;
* @Title: unevenLightCompensate 
* @Description: 光線補償 
* @param image
* @param blockSize
* void 
* @throws
 */
public static void unevenLightCompensate(Mat image, int blockSize) {
	if(image.channels() == 3) {
		Imgproc.cvtColor(image, image, 7);
	}
	double average = Core.mean(image).val[0];
	Scalar scalar = new Scalar(average);
	int rowsNew = (int) Math.ceil((double)image.rows() / (double)blockSize);
	int colsNew = (int) Math.ceil((double)image.cols() / (double)blockSize);
	Mat blockImage = new Mat();
	blockImage = Mat.zeros(rowsNew, colsNew, CvType.CV_32FC1);
	for(int i = 0; i < rowsNew; i ++) {
		for(int j = 0; j < colsNew; j ++) {
			int rowmin = i * blockSize;
			int rowmax = (i + 1) * blockSize;
			if(rowmax > image.rows()) rowmax = image.rows();
			int colmin = j * blockSize;
			int colmax = (j +1) * blockSize;
			if(colmax > image.cols()) colmax = image.cols();
			Range rangeRow = new Range(rowmin, rowmax);
			Range rangeCol = new Range(colmin, colmax);
			Mat imageROI = new Mat(image, rangeRow, rangeCol);
			double temaver = Core.mean(imageROI).val[0];
			blockImage.put(i, j, temaver);
		}
	}
	
	Core.subtract(blockImage, scalar, blockImage);
	Mat blockImage2 = new Mat();
	int INTER_CUBIC = 2;
	Imgproc.resize(blockImage, blockImage2, image.size(), 0, 0, INTER_CUBIC);
	Mat image2 = new Mat();
	image.convertTo(image2, CvType.CV_32FC1);
	Mat dst = new Mat();
	Core.subtract(image2, blockImage2, dst);
	dst.convertTo(image, CvType.CV_8UC1);
}
 
開發者ID:IaHehe,項目名稱:classchecks,代碼行數:51,代碼來源:ImgprocessUtils.java

示例13: doJaniThinning

import org.opencv.core.Mat; //導入方法依賴的package包/類
Mat doJaniThinning(Mat Image) {
    B = new boolean[Image.rows()][Image.cols()];
    // Inverse of B
    boolean [][] B_ = new boolean[Image.rows()][Image.cols()];
    for(int i=0; i<Image.rows(); i++)
        for(int j=0; j<Image.cols(); j++)
            B[i][j] = (Image.get(i, j)[0] > 10); //not a mistake, in matlab first invert and then morph

    boolean[][] prevB = new boolean[Image.rows()][Image.cols()];
    final int maxIter = 1000;
    for(int iter = 0; iter < maxIter; iter++) {
        // Assign B to prevB
        for (int i=0; i<Image.rows(); i++)
            System.arraycopy(B[i], 0, prevB[i], 0, Image.cols());

        //Iteration #1
        for(int i=0; i<Image.rows(); i++)
            for (int j = 0; j < Image.cols(); j++)
                B_[i][j] = !(B[i][j] && G1(i, j) && G2(i, j) && G3(i, j)) && B[i][j];

        // Assign result of iteration #1 to B, so that iteration #2 will see the results
        for(int i=0; i<Image.rows(); i++)
            System.arraycopy(B_[i], 0, B[i], 0, Image.cols());


        //Iteration #2
        for(int i=0; i<Image.rows(); i++)
            for (int j = 0; j < Image.cols(); j++)
                B_[i][j] = !(B[i][j] && G1(i, j) && G2(i, j) && G3_(i, j)) && B[i][j];

        // Assign result of Iteration #2 to B
        for(int i=0; i<Image.rows(); i++)
            System.arraycopy(B_[i], 0, B[i], 0, Image.cols());

        // stop when it doesn't change anymore
        boolean convergence = true;
        for (int i = 0; i < Image.rows(); i++)
            convergence &= Arrays.equals(B[i], prevB[i]);
        if (convergence){
            break;
        }
    }

    removeFalseRidgeEndings(Image);

    Mat r = Mat.zeros(Image.size(), CvType.CV_8UC1);

    for(int i=0; i<Image.rows(); i++)
        for(int j=0; j<Image.cols(); j++)
            if (B[i][j])
                r.put(i, j, 255);
    return r;
}
 
開發者ID:jorenham,項目名稱:fingerblox,代碼行數:54,代碼來源:ImageProcessing.java

示例14: irregularQuadrangle

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static Mat irregularQuadrangle(Mat irrInput, Point p1, Point p2, Point p3, Point p4, double shift,
		boolean noULandLRcorner, double ulCornerRatio, double lrCornerRatio) {
	final Mat maskCopyTo = Mat.zeros(irrInput.size(), CvType.CV_8UC1); // ����copyTo������mask����С��ԭͼ����һ��

	final double angle = MathBox.slopeAngle(p1, p2);
	// System.out.println(angle);
	final double sin = Math.sin(angle);
	final double cos = Math.cos(angle);

	// �����ĵ���Ϊ��ʼ����
	final double centerX = (p1.x + p2.x + p3.x + p4.x) / 4;
	final double centerY = (p1.y + p2.y + p3.y + p4.y) / 4;
	final Point cc = new Point(centerX, centerY);

	final List<MatOfPoint> counter = new ArrayList<>();
	final Point aP1raw = new Point(p1.x + shift, p1.y + shift);
	final Point aP2raw = new Point(p2.x - shift, p2.y + shift);
	final Point aP3raw = new Point(p3.x + shift, p3.y - shift);
	final Point aP4raw = new Point(p4.x - shift, p4.y - shift);

	final Point aP1 = MathBox.rotateAroundAPoint(cc, aP1raw, angle);
	final Point aP2 = MathBox.rotateAroundAPoint(cc, aP2raw, angle);
	final Point aP3 = MathBox.rotateAroundAPoint(cc, aP3raw, angle);
	final Point aP4 = MathBox.rotateAroundAPoint(cc, aP4raw, angle);

	if (noULandLRcorner) {
		final Point aP1Lraw = new Point(aP1.x, aP1.y + (aP3.y - aP1.y) * ulCornerRatio);
		final Point aP1Rraw = new Point(aP1.x + (aP2.x - aP1.x) * ulCornerRatio, aP1.y);
		final Point aP4Lraw = new Point(aP4.x - (aP4.x - aP3.x) * lrCornerRatio, aP4.y);
		final Point aP4Rraw = new Point(aP4.x, aP4.y - (aP4.y - aP2.y) * lrCornerRatio);

		final Point aP1L = MathBox.rotateAroundAPoint(cc, aP1Lraw, angle);
		final Point aP1R = MathBox.rotateAroundAPoint(cc, aP1Rraw, angle);
		final Point aP4L = MathBox.rotateAroundAPoint(cc, aP4Lraw, angle);
		final Point aP4R = MathBox.rotateAroundAPoint(cc, aP4Rraw, angle);

		counter.add(new MatOfPoint(aP1L, aP1R, aP2, aP4R, aP4L, aP3)); // ����һ��������Ķ���Σ�û�����ϽǺ����½�
	} else
		counter.add(new MatOfPoint(aP1, aP2, aP4, aP3)); // ����һ��������Ķ����

	// floodFill��mask��width��height�����������ͼ��������������أ��������ᱨ��
	Imgproc.drawContours(maskCopyTo, counter, -1, Scalar.all(255)); // ��������
	MatView.imshow(maskCopyTo, "Irregular shape edge");
	final Mat maskFloodFill = new Mat(irrInput.rows() + 2, irrInput.cols() + 2, CvType.CV_8UC1); // ����floodFill������mask���ߴ��ԭͼ��һЩ
	Imgproc.floodFill(maskCopyTo, maskFloodFill, new Point(centerX, centerY), Scalar.all(255), null, Scalar.all(20),
			Scalar.all(20), 4); // ��ˮ��䷨����ڲ�
	// MatView.imshow(maskFloodFill, "Irregular shape��Mask of floodFill"); //
	// ����copyTo������mask
	// MatView.imshow(maskCopyTo, "Irregular shape��Mask of copyTo"); //
	// ����floodFill������mask
	final Mat imgIrregularROI = new Mat();
	irrInput.copyTo(imgIrregularROI, maskCopyTo); // ��ȡ��������״��ROI
	// MatView.imshow(imgIrregularROI, "Irregular shape ROI");
	return imgIrregularROI;
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:56,代碼來源:ROI_Irregular.java

示例15: initSampleMask

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static void initSampleMask(int height, int width) {
    /**
     * Init sample mask according to `height`, `width`
     */

    // convert apexes to a binary image
    Mat sampleSrc = Mat.zeros(new Size(sampleWindowWidth, sampleWindowHeight), CvType.CV_8UC1);
    Util.fillContour(sampleSrc, sampleWindowContour, new Point(sampleWindowWidth / 2, sampleWindowHeight / 2));

    sampleMask = Mat.zeros(new Size(width, height), CvType.CV_8UC1);

    if (height < sampleWindowHeight || width < sampleWindowWidth) {
        throw new AssertionError(
                "Too small the image(" + width + " cols x" + height +
                        "rows) is to contain a sampling window sized"
                        + sampleWindowWidth + "x" + sampleWindowHeight
        );
    }

    rowOffset = (height - sampleSrc.height()) / 2;
    colOffset = (width - sampleSrc.width()) / 2;

    sampleSrc.copyTo(sampleMask.submat(
            rowOffset, sampleSrc.height() + rowOffset,
            colOffset, sampleSrc.width() + colOffset
    ));


    for (int r = 0; r < height; r += 4) {
        for (int c = 0; c < width; c += 4) {
            if (sampleMask.get(r, c)[0] > 0) {
                samplePixels.add(new Point(c, r));
            }
        }
    }

    // add points in sampleWindowContour for further use
    // now sampleWindowContour shares a same coordinate with
    // tap-detection algorithm
    for (Point p : sampleWindowContour) {
        p.x += colOffset;
        p.y += rowOffset;
    }
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:45,代碼來源:Sampler.java


注:本文中的org.opencv.core.Mat.zeros方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。