• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MatFileReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testDoubleFromMatlabCreatedFile2

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
/**
 * Regression bug.
 
 * <pre><code>
 * Matlab code:
 * >> arr = [1.1, 4.4; 2.2, 5.5; 3.3, 6.6];
 * >> save('matnativedouble2', arr);
 * </code></pre>
 * 
 * @throws IOException
 */
@Test 
public void testDoubleFromMatlabCreatedFile2() throws IOException
{
    //array name
    String name = "arr";
    //file name in which array will be stored
    String fileName = "src/test/resources/matnativedouble2.mat";

    //test column-packed vector
    double[] src = new double[] { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 };
    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,代码行数:31,代码来源:MatIOTest.java


示例17: testInt32

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
@Test 
public void testInt32() throws IOException
{
    //array name
    String name = "a";
    //file name in which array will be stored
    String fileName = "src/test/resources/int32.mat";

    //test column-packed vector
    int[] src = new int[] { 1, 2, 3, 4 };
    MLInt32 mlDouble = new MLInt32( name, src, 1 );
    
    //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,代码行数:20,代码来源:MatIOTest.java


示例18: MCSMatFileReader

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public MCSMatFileReader(Path matFile) throws Exception {
    Objects.requireNonNull(matFile, "mat file is null");
    MatFileReader sampledDataFileReader = new MatFileReader();
    matFileContent = sampledDataFileReader.read(matFile.toFile());
    String errorMessage = Utils.MLCharToString((MLChar) matFileContent.get("errmsg"));
    if (!("Ok".equalsIgnoreCase(errorMessage))) {
        throw new MatlabException(errorMessage);
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:10,代码来源:MCSMatFileReader.java


示例19: readDoublesMatrixFromMat

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public static double[][] readDoublesMatrixFromMat(Path matFile, String doublesMatrixName) throws IOException {
    Objects.requireNonNull(matFile, "mat file is null");
    MatFileReader matFileReader = new MatFileReader();
    Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile());
    MLDouble doublesMatrix = (MLDouble) matFileContent.get(doublesMatrixName);
    double[][] doubles = null;
    if (doublesMatrix != null) {
        doubles = doublesMatrix.getArray();
    }
    return doubles;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:12,代码来源:Utils.java


示例20: computeBinSampling

import com.jmatio.io.MatFileReader; //导入依赖的package包/类
public double[][] computeBinSampling(double[] marginalExpectations, int nSamples) throws Exception {
    Objects.requireNonNull(marginalExpectations);
    if (marginalExpectations.length == 0) {
        throw new IllegalArgumentException("empty marginalExpectations array");
    }
    if (nSamples <= 0) {
        throw new IllegalArgumentException("number of samples must be positive");
    }
    try (CommandExecutor executor = computationManager.newCommandExecutor(createEnv(), WORKING_DIR_PREFIX, config.isDebug())) {

        Path workingDir = executor.getWorkingDir();
        Utils.writeWP41BinaryIndependentSamplingInputFile(workingDir.resolve(B1INPUTFILENAME), marginalExpectations);

        LOGGER.info("binsampler, asking for {} samples", nSamples);

        Command cmd = createBinSamplerCmd(workingDir.resolve(B1INPUTFILENAME), nSamples);
        ExecutionReport report = executor.start(new CommandExecution(cmd, 1, priority));
        report.log();

        LOGGER.debug("Retrieving binsampler results from file {}", B1OUTPUTFILENAME);
        MatFileReader mfr = new MatFileReader();
        Map<String, MLArray> content;
        content = mfr.read(workingDir.resolve(B1OUTPUTFILENAME).toFile());
        String errMsg = Utils.MLCharToString((MLChar) content.get("errmsg"));
        if (!("Ok".equalsIgnoreCase(errMsg))) {
            throw new MatlabException(errMsg);
        }
        MLArray xNew = content.get("STATUS");
        Objects.requireNonNull(xNew);
        MLDouble mld = (MLDouble) xNew;
        double[][] retMat = mld.getArray();
        return retMat;
    }


}
 
开发者ID:itesla,项目名称:ipst,代码行数:37,代码来源:SamplerWp41.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PseudoDelegationTokenAuthenticationHandler类代码示例发布时间:2022-05-23
下一篇:
Java EventPrinter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap