List of usage examples for org.opencv.core Mat Mat
public Mat(Mat m, Range rowRange, Range colRange)
From source file:ctPrincipal.Graficos.java
private Mat LoadImagB(String imgS) { try {/*from w ww. j a v a 2 s . c o m*/ File imgF2 = new File(imgS); BufferedImage imageB = ImageIO.read(imgF2); byte[] data = ((DataBufferByte) imageB.getRaster().getDataBuffer()).getData(); image2 = new Mat(imageB.getHeight(), imageB.getWidth(), CvType.CV_8UC3); image2.put(0, 0, data); } catch (IOException ex) { Logger.getLogger(Operacoes.class.getName()).log(Level.SEVERE, null, ex); } return image2; }
From source file:ctPrincipal.Operacoes.java
private void IniciaOperacoes() { this.output = new Mat(256, 256, CvType.CV_8UC3); LoadImagA(); LoadImagB(); }
From source file:ctPrincipal.Operacoes.java
private void LoadImagB() { try {/* w w w .j av a 2 s .com*/ BufferedImage imageB = ImageIO.read(imgF2); byte[] data = ((DataBufferByte) imageB.getRaster().getDataBuffer()).getData(); image2 = new Mat(imageB.getHeight(), imageB.getWidth(), CvType.CV_8UC3); image2.put(0, 0, data); this.image2bin = new Mat(imageB.getHeight(), imageB.getWidth(), CvType.CV_8UC1); Imgproc.cvtColor(image2, image2bin, Imgproc.COLOR_RGB2GRAY); } catch (IOException ex) { Logger.getLogger(Operacoes.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ctPrincipal.Operacoes.java
private void LoadImagA() { try {//from ww w . ja v a2 s .c om BufferedImage imageA = ImageIO.read(imgF1); byte[] data = ((DataBufferByte) imageA.getRaster().getDataBuffer()).getData(); image1 = new Mat(imageA.getHeight(), imageA.getWidth(), CvType.CV_8UC3); image1.put(0, 0, data); this.image1bin = new Mat(imageA.getHeight(), imageA.getWidth(), CvType.CV_8UC1); Imgproc.cvtColor(image1, image1bin, Imgproc.COLOR_RGB2GRAY); } catch (IOException ex) { Logger.getLogger(Operacoes.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ctPrincipal.Ruidos.java
private void IniciaOperacoes() { this.output = new Mat(256, 26, CvType.CV_8UC3); LoadImagA(); }
From source file:cubesolversimulator.VisualInputForm.java
/** * Creates new form VisualInputForm/*from w w w . j a va2s . co m*/ */ public VisualInputForm() { try { initComponents(); cam = Webcam.getDefault(); cam.setViewSize(WebcamResolution.VGA.getSize()); panel = new WebcamPanel(cam); panel.setSize(jPanel8.getSize()); jPanel8.add(panel); cam.open(); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); jPanel6.setLayout(null); orig = new Mat(cam.getImage().getHeight(), cam.getImage().getWidth(), 16); blured = new Mat(orig.rows(), orig.cols(), orig.type()); gray = new Mat(orig.rows(), orig.cols(), orig.type()); edge = new Mat(orig.rows(), orig.cols(), orig.type()); contour = new Mat(orig.rows(), orig.cols(), orig.type()); temp = new Mat(orig.rows(), orig.cols(), orig.type()); img = new JLabel(""); } catch (Exception ex) { Logger.getLogger(VisualInputForm.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:cv.faceRecognize.faceRecognizer.java
public Mat ListToMat(List<Integer> a) { System.out.println(a);//w ww. j ava 2 s . c o m Mat m = new Mat(a.size(), 1, CvType.CV_32SC1); // IntBuffer inf = m.createBuffer(); System.out.println(m); int i = 0; for (int lable : a) { System.out.println(Arrays.toString(m.get(i, 1))); m.put(i, 0, lable); System.out.println(Arrays.toString(m.get(i, 0))); i += 1; } System.out.println(m); return m; }
From source file:cv.faceRecognize.faceRecognizer.java
public void tainFaceRecognizer() { Mat lableMat = new Mat(fileHandler.getImageLablesNo().size(), 1, CV_32SC1); //IntBuffer labelsBuf = lableMat.; for (int i = 0; i <= fileHandler.getImageLablesNo().size(); i++) { }/* w ww . j av a 2 s . c om*/ LBPHFaceRecognizer.train(faces, lableMat); }
From source file:cx.uni.jk.mms.iaip.filter.LogRedBlue.java
License:Open Source License
@Override public Mat convert(Mat mat) { MinMaxLocResult negativeMmlr, positiveMmlr; double min, max, alpha, beta; /** negative values to positive and log */ Mat negativeMat = mat.clone();/*ww w. ja va 2 s .c o m*/ Core.min(negativeMat, new Scalar(0.0d), negativeMat); Core.multiply(negativeMat, new Scalar(-1.0d), negativeMat); Core.add(negativeMat, new Scalar(1.0d), negativeMat); Core.log(negativeMat, negativeMat); /** positve values log */ Mat positiveMat = mat.clone(); Core.max(positiveMat, new Scalar(0.0d), positiveMat); Core.add(positiveMat, new Scalar(1.0d), positiveMat); Core.log(positiveMat, positiveMat); /** find common contrast and brightness to fit into 8 bit */ negativeMmlr = Core.minMaxLoc(negativeMat); positiveMmlr = Core.minMaxLoc(positiveMat); min = 0; max = Math.max(negativeMmlr.maxVal, positiveMmlr.maxVal); alpha = 256.0d / (max - min); beta = -min * alpha; /** conversion of both matrices to 8 bit */ negativeMat.convertTo(negativeMat, CvType.CV_8UC1, alpha, beta); positiveMat.convertTo(positiveMat, CvType.CV_8UC1, alpha, beta); /** combine both matrices into one 8 bit 3 channel rgb picture */ Mat tempMat = new Mat(mat.rows(), mat.cols(), CvType.CV_8UC3); List<Mat> mixSrcMats = new ArrayList<>(); mixSrcMats.add(negativeMat); // 1 channel: 0 mixSrcMats.add(positiveMat); // 1 channel: 1 List<Mat> mixDstMats = new ArrayList<>(); mixDstMats.add(tempMat); // 3 channels: 0-2 MatOfInt fromToMat = new MatOfInt(0, 0 /* neg->red */, -1, 1/* * null->green */, 1, 2 /* * pos- * > * blue */); Core.mixChannels(mixSrcMats, mixDstMats, fromToMat); return tempMat; }
From source file:cx.uni.jk.mms.iaip.filter.LogYellowCyan.java
License:Open Source License
@Override public Mat convert(Mat mat) { MinMaxLocResult negativeMmlr, positiveMmlr; double min, max, alpha, beta; /** negative values to positive and log */ Mat negativeMat = mat.clone();// www . j a v a 2 s . c om Core.min(negativeMat, new Scalar(0.0d), negativeMat); Core.multiply(negativeMat, new Scalar(-1.0d), negativeMat); Core.add(negativeMat, new Scalar(1.0d), negativeMat); Core.log(negativeMat, negativeMat); /** positve values log */ Mat positiveMat = mat.clone(); Core.max(positiveMat, new Scalar(0.0d), positiveMat); Core.add(positiveMat, new Scalar(1.0d), positiveMat); Core.log(positiveMat, positiveMat); /** find common contrast and brightness to fit into 8 bit */ negativeMmlr = Core.minMaxLoc(negativeMat); positiveMmlr = Core.minMaxLoc(positiveMat); min = 0; max = Math.max(negativeMmlr.maxVal, positiveMmlr.maxVal); alpha = 256.0d / (max - min); beta = -min * alpha; /** conversion of both matrices to 8 bit */ negativeMat.convertTo(negativeMat, CvType.CV_8UC1, alpha, beta); positiveMat.convertTo(positiveMat, CvType.CV_8UC1, alpha, beta); /** create additional mat for saturated green */ Mat brightMat = negativeMat.clone(); Core.max(negativeMat, positiveMat, brightMat); // Core.absdiff(brightMat, new Scalar(255.0d), brightMat); // Core.multiply(brightMat, new Scalar(1.0d/3.0d), brightMat); /** combine all matrices into one 8 bit 3 channel rgb picture */ Mat tempMat = new Mat(mat.rows(), mat.cols(), CvType.CV_8UC3); List<Mat> mixSrcMats = new ArrayList<>(); mixSrcMats.add(negativeMat); // 1 channel: 0 mixSrcMats.add(positiveMat); // 1 channel: 1 mixSrcMats.add(brightMat); // 1 channel: 2 List<Mat> mixDstMats = new ArrayList<>(); mixDstMats.add(tempMat); // 3 channels: 0-2 MatOfInt fromToMat = new MatOfInt(0, 0 /* neg->red */, 2, 1/* * avg->green */, 1, 2 /* * pos- * > * blue */); Core.mixChannels(mixSrcMats, mixDstMats, fromToMat); return tempMat; }