当前位置: 首页>>代码示例>>Java>>正文


Java MatFileReader类代码示例

本文整理汇总了Java中com.jmatio.io.MatFileReader的典型用法代码示例。如果您正苦于以下问题:Java MatFileReader类的具体用法?Java MatFileReader怎么用?Java MatFileReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MatFileReader类属于com.jmatio.io包,在下文中一共展示了MatFileReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doImportGTfromMatlab

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
synchronized public void doImportGTfromMatlab() {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Choose ground truth file");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    if (chooser.showOpenDialog(chip.getAeViewer().getFilterFrame()) == JFileChooser.APPROVE_OPTION) {
        try {
            vxGTframe = ((MLDouble) (new MatFileReader(chooser.getSelectedFile().getPath())).getMLArray("vxGT")).getArray();
            vyGTframe = ((MLDouble) (new MatFileReader(chooser.getSelectedFile().getPath())).getMLArray("vyGT")).getArray();
            tsGTframe = ((MLDouble) (new MatFileReader(chooser.getSelectedFile().getPath())).getMLArray("ts")).getArray();
            importedGTfromMatlab = true;
            log.info("Imported ground truth file");
        } catch (IOException ex) {
            log.log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:AbstractMotionFlowIMU.java

示例2: readStringsArrayFromMat

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public static String[] readStringsArrayFromMat(Path matFile, String stringsArrayName) throws IOException {
    Objects.requireNonNull(matFile, "mat file is null");
    Objects.requireNonNull(stringsArrayName, "strings array name is null");
    MatFileReader matFileReader = new MatFileReader();
    Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile());
    MLCell stringsArray = (MLCell) matFileContent.get(stringsArrayName);
    String[] strings = new String[stringsArray.getN()];
    for (int i = 0; i < stringsArray.getN(); i++) {
        strings[i] = ((MLChar) stringsArray.get(0, i)).getString(0);
    }
    return strings;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:13,代码来源:Utils.java

示例3: fromFile

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public static Matrix fromFile(File file, Object... parameters) throws IOException {
	String key = null;
	if (parameters != null && parameters.length > 0 && parameters[0] instanceof String) {
		key = (String) parameters[0];
	}
	MatFileReader reader = new MatFileReader();
	Map<String, MLArray> map = reader.read(file);
	if (key == null) {
		key = map.keySet().iterator().next();
	}
	MLArray array = map.get(key);
	if (array == null) {
		throw new RuntimeException("matrix with label [" + key + "] was not found in .mat file");
	} else if (array instanceof MLDouble) {
		return new MLDenseDoubleMatrix((MLDouble) array);
	} else {
		throw new RuntimeException("This type is not yet supported: " + array.getClass());
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:20,代码来源:ImportMatrixMAT.java

示例4: loadDSIFTPCA

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
private static MemoryLocalFeatureList<FloatDSIFTKeypoint> loadDSIFTPCA(String faceFile) throws IOException {
	final File f = new File(faceFile);
	final MatFileReader reader = new MatFileReader(f);
	final MLSingle feats = (MLSingle) reader.getContent().get("feats");
	final int nfeats = feats.getN();
	final MemoryLocalFeatureList<FloatDSIFTKeypoint> ret = new MemoryLocalFeatureList<FloatDSIFTKeypoint>();
	for (int i = 0; i < nfeats; i++) {
		final FloatDSIFTKeypoint feature = new FloatDSIFTKeypoint();
		feature.descriptor = new float[feats.getM()];
		for (int j = 0; j < feature.descriptor.length; j++) {
			feature.descriptor[j] = feats.get(j, i);
		}
		ret.add(feature);
	}

	return ret;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:FVFWCheckGMM.java

示例5: loadMoG

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
private static MixtureOfGaussians loadMoG() throws IOException {
	final File f = new File(GMM_MATLAB_FILE);
	final MatFileReader reader = new MatFileReader(f);
	final MLStructure codebook = (MLStructure) reader.getContent().get("codebook");

	final MLSingle mean = (MLSingle) codebook.getField("mean");
	final MLSingle variance = (MLSingle) codebook.getField("variance");
	final MLSingle coef = (MLSingle) codebook.getField("coef");

	final int n_gaussians = mean.getN();
	final int n_dims = mean.getM();

	final MultivariateGaussian[] ret = new MultivariateGaussian[n_gaussians];
	final double[] weights = new double[n_gaussians];
	for (int i = 0; i < n_gaussians; i++) {
		weights[i] = coef.get(i, 0);
		final DiagonalMultivariateGaussian d = new DiagonalMultivariateGaussian(n_dims);
		for (int j = 0; j < n_dims; j++) {
			d.mean.set(0, j, mean.get(j, i));
			d.variance[j] = variance.get(j, i);
		}
		ret[i] = d;
	}

	return new MixtureOfGaussians(ret, weights);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:FVFWCheckGMM.java

示例6: loadPCA

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public static PrincipalComponentAnalysis loadPCA(File f) throws IOException {
	final MatFileReader reader = new MatFileReader(f);
	final MLSingle mean = (MLSingle) reader.getContent().get("mu");
	final MLSingle eigvec = (MLSingle) reader.getContent().get("proj");
	final Matrix basis = new Matrix(eigvec.getM(), eigvec.getN());
	final double[] meand = new double[eigvec.getN()];
	for (int j = 0; j < eigvec.getN(); j++) {
		// meand[i] = mean.get(i,0); ignore the means
		meand[j] = 0;
		for (int i = 0; i < eigvec.getM(); i++) {
			basis.set(i, j, eigvec.get(i, j));
		}
	}
	final PrincipalComponentAnalysis ret = new LoadedPCA(basis.transpose(), meand);
	return ret;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:FVFWCheckPCAGMM.java

示例7: loadMoG

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public static MixtureOfGaussians loadMoG(File f) throws IOException {
	final MatFileReader reader = new MatFileReader(f);
	final MLStructure codebook = (MLStructure) reader.getContent().get("codebook");

	final MLSingle mean = (MLSingle) codebook.getField("mean");
	final MLSingle variance = (MLSingle) codebook.getField("variance");
	final MLSingle coef = (MLSingle) codebook.getField("coef");

	final int n_gaussians = mean.getN();
	final int n_dims = mean.getM();

	final MultivariateGaussian[] ret = new MultivariateGaussian[n_gaussians];
	final double[] weights = new double[n_gaussians];
	for (int i = 0; i < n_gaussians; i++) {
		weights[i] = coef.get(i, 0);
		final DiagonalMultivariateGaussian d = new DiagonalMultivariateGaussian(n_dims);
		for (int j = 0; j < n_dims; j++) {
			d.mean.set(0, j, mean.get(j, i));
			d.variance[j] = variance.get(j, i);
		}
		ret[i] = d;
	}

	return new MixtureOfGaussians(ret, weights);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:FVFWCheckPCAGMM.java

示例8: loadMatlabLMDR

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
private static LargeMarginDimensionalityReduction loadMatlabLMDR() throws IOException {
	final LargeMarginDimensionalityReduction lmdr = new LargeMarginDimensionalityReduction(128);

	final MatFileReader reader = new MatFileReader(new File("/Users/jon/lmdr.mat"));
	final MLSingle W = (MLSingle) reader.getContent().get("W");
	final MLSingle b = (MLSingle) reader.getContent().get("b");

	lmdr.setBias(b.get(0, 0));

	final Matrix proj = new Matrix(W.getM(), W.getN());
	for (int j = 0; j < W.getN(); j++) {
		for (int i = 0; i < W.getM(); i++) {
			proj.set(i, j, W.get(i, j));
		}
	}

	lmdr.setTransform(proj);

	return lmdr;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:FVFWExperiment.java

示例9: loadMatlabPCAW

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
private static LargeMarginDimensionalityReduction loadMatlabPCAW() throws IOException {
	final LargeMarginDimensionalityReduction lmdr = new LargeMarginDimensionalityReduction(128);

	final MatFileReader reader = new MatFileReader(new File("/Users/jon/pcaw.mat"));
	final MLSingle W = (MLSingle) reader.getContent().get("proj");

	lmdr.setBias(169.6264190673828);

	final Matrix proj = new Matrix(W.getM(), W.getN());
	for (int j = 0; j < W.getN(); j++) {
		for (int i = 0; i < W.getM(); i++) {
			proj.set(i, j, W.get(i, j));
		}
	}

	lmdr.setTransform(proj);

	return lmdr;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:FVFWExperiment.java

示例10: main

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	// MLCell cell = new MLCell("data", new int[]{100000,1});
	// Random r = new Random();
	// for (int i = 0; i < 100000; i++) {
	// MLCell inner = new MLCell(null, new int[]{2,1});
	// inner.set(new MLChar(null,"Dummy String" + r.nextDouble()), 0, 0);
	// MLDouble d = new MLDouble(null, new double[][]{new
	// double[]{r.nextDouble()}});
	// inner.set(d, 1, 0);
	// cell.set(inner, i,0);
	// }
	// ArrayList<MLArray> arr = new ArrayList<MLArray>();
	// arr.add(cell);
	// new MatFileWriter( "mat_file.mat", arr);
	final MatFileReader reader = new MatFileReader("/Users/ss/Development/python/storm-spams/XYs.mat");
	final Map<String, MLArray> content = reader.getContent();
	final MLCell cell = (MLCell) content.get("XYs");
	System.out.println(cell.get(0, 0));
	System.out.println(cell.get(0, 1));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:MatlabIO.java

示例11: parseAnnotations

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
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();
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:Caltech101.java

示例12: fillDataFields

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
private void fillDataFields(MatFileReader reader) {
    root = (MLStructure) reader.getMLArray(rootKey);
    accX = getDoubleList(root, accXKey);
    accY = getDoubleList(root, accYKey);
    accZ = getDoubleList(root, accZKey);
    gpsSpeeds = getDoubleList(root, gpsSpeedKey);
    longitudes = getDoubleList(root, longitudeKey);
    latitudes = getDoubleList(root, latitudeKey);
    altitudes = getDoubleList(root, altitudeKey);
    indices = getIntList(root, indexKey);
    deviceIds = getIntList(root, deviceIdKey);
    years = getIntList(root, yearsKey);
    months = getIntList(root, monthsKey);
    days = getIntList(root, daysKey);
    hours = getIntList(root, hoursKey);
    minutes = getIntList(root, minutesKey);
    seconds = getIntList(root, secondsKey);
    gpsSpeeds = getDoubleList(root, gpsSpeedKey);
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:20,代码来源:UnannotatedMeasurementsMatLoader.java

示例13: getMeasurements

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
private LinkedList<IndependentMeasurement> getMeasurements(MatFileReader matFileReader) {
    LinkedList<IndependentMeasurement> measurements = new LinkedList<IndependentMeasurement>();

    int nOfSamples = accX.size();

    for (int i = 0; i < nOfSamples; i++) {
        double x = accX.get(i);
        double y = accY.get(i);
        double z = accZ.get(i);
        DateTime timeStamp = getTimeStamp(i);
        int deviceId = deviceIds.get(i);
        int index = indices.get(i);
        double gpsSpeed = gpsSpeeds.get(i);
        double longitude = longitudes.get(i);
        double latitude = latitudes.get(i);
        double altitude = altitudes.get(i);
        IndependentMeasurement measurement = getUnannotatedMeasurement(x, y, z, timeStamp, deviceId, gpsSpeed, longitude,
                latitude, altitude);
        measurement.setIndex(index);
        if (isMeasurementValid(measurement)) {
            measurements.add(measurement);
        }
    }
    return measurements;
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:26,代码来源:UnannotatedMeasurementsMatLoader.java

示例14: testMLCharUnicode

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
@Test
public void testMLCharUnicode() throws Exception
{
    //array name
    String name = "chararr";
    //file name in which array will be storred
    String fileName = "mlcharUTF.mat";
    File outFile = temp.newFile( fileName );
    //temp
    String valueS;

    //create MLChar array of a name "chararr" containig one
    //string value "dummy"
    MLChar mlChar = new MLChar(name, new String[] { "\u017C\u00F3\u0142w", "\u017C\u00F3\u0142i"} );
    MatFileWriter writer = new MatFileWriter();
    writer.write(outFile, Arrays.asList( (MLArray) mlChar ) );
    
    MatFileReader reader = new MatFileReader( outFile );
    MLChar mlChar2 = (MLChar) reader.getMLArray(name);

    assertEquals("\u017C\u00F3\u0142w", mlChar.getString(0) );
    assertEquals("\u017C\u00F3\u0142w", mlChar2.getString(0) );
    assertEquals("\u017C\u00F3\u0142i", mlChar2.getString(1) );        
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:25,代码来源:MatIOTest.java

示例15: testDoubleFromMatlabCreatedFile

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
/**
 * Regression bug
 * 
 * @throws Exception
 */
@Test 
public void testDoubleFromMatlabCreatedFile() throws Exception
{
    //array name
    String name = "arr";
    //file name in which array will be stored
    String fileName = "src/test/resources/matnativedouble.mat";

    //test column-packed vector
    double[] src = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
    MLDouble mlDouble = new MLDouble( name, src, 3 );
    
    //read array form file
    MatFileReader mfr = new MatFileReader( fileName );
    MLArray mlArrayRetrived = mfr.getMLArray( name );
    
    //test if MLArray objects are equal
    assertEquals("Test if value red from file equals value stored", mlDouble, mlArrayRetrived);
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:25,代码来源:MatIOTest.java


注:本文中的com.jmatio.io.MatFileReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。