private void parseAnnotations(FileObject annotationFile) throws IOException { if (!annotationFile.exists()) { return; } final MatFileReader reader = new MatFileReader(annotationFile.getContent().getInputStream()); final MLDouble boxes = (MLDouble) reader.getMLArray("box_coord"); this.bounds = new Rectangle( (float) (double) boxes.getReal(2) - 1, (float) (double) boxes.getReal(0) - 1, (float) (boxes.getReal(3) - boxes.getReal(2)) - 1, (float) (boxes.getReal(1) - boxes.getReal(0)) - 1); final double[][] contourData = ((MLDouble) reader.getMLArray("obj_contour")).getArray(); this.contour = new Polygon(); for (int i = 0; i < contourData[0].length; i++) { contour.points.add( new Point2dImpl((float) contourData[0][i] + bounds.x - 1, (float) contourData[1][i] + bounds.y - 1) ); } contour.close(); }
private void parseAnnotations(FileObject annotationFile) throws IOException { if (!annotationFile.exists()) { return; } final MatFileReader reader = new MatFileReader(annotationFile.getContent().getInputStream()); final MLDouble boxes = (MLDouble) reader.getMLArray("box_coord"); this.bounds = new Rectangle( (float) (double) boxes.getReal(2) - 1, (float) (double) boxes.getReal(0) - 1, (float) (boxes.getReal(3) - boxes.getReal(2)) - 1, (float) (boxes.getReal(1) - boxes.getReal(0)) - 1); final double[][] contourData = ((MLDouble) reader.getMLArray("obj_contour")).getArray(); this.contour = new Polygon(); for (int i = 0; i < contourData[0].length; i++) { contour.points.add( new Point2dImpl((float) contourData[0][i] + bounds.x - 1, (float) contourData[1][i] + bounds.y - 1) ); } contour.close(); }
/** * Gets two-dimensional real array. * * @return - 2D real array */ public double[][] getArray() { final int M = getM(); final int N = getN(); double[][] result = new double[M][]; for ( int m = 0; m < M; m++ ){ result[m] = new double[N]; for ( int n = 0; n < N; n++ ){ result[m][n] = getReal(m,n); } } return result; } /**
/** * Gets two-dimensional real array. * * @return - 2D real array */ public double[][] getArray() { double[][] result = new double[getM()][]; for ( int m = 0; m < getM(); m++ ) { result[m] = new double[ getN() ]; for ( int n = 0; n < getN(); n++ ) { result[m][n] = getReal(m,n); } } return result; } /**
/** * Gets two-dimensional real array. * * @return - 2D real array */ public double[][] getArray() { double[][] result = new double[getM()][]; for ( int m = 0; m < getM(); m++ ) { result[m] = new double[ getN() ]; for ( int n = 0; n < getN(); n++ ) { result[m][n] = getReal(m,n); } } return result; } /**
for (int l = 0; l < dims[1]; l++) { for (int m = 0; m < dims[0]; m++, expectedValRe += 1.0) { Double actualRe = mlArray.getReal(m, l, k, j, i); Assert.assertEquals(expectedValRe, actualRe); Double actualIm = mlArray.getImaginary(m, l, k, j, i);
for (int l = 0; l < dims[1]; l++) { for (int m = 0; m < dims[0]; m++, expectedValRe += 1.0) { Double actualRe = mlArray.getReal(mlArray.getIndex(m, l, k, j, i)); Assert.assertEquals(expectedValRe, actualRe); Double actualIm = mlArray.getImaginary(mlArray.getIndex(m, l, k, j, i));