@Override public void perform(File f) { final Matrix basis = pca.getBasis(); final Matrix tmp = new Matrix(1, 128); if (f.getName().endsWith(".bin")) { try { System.out.println("Processing " + f); final MemoryLocalFeatureList<FloatDSIFTKeypoint> feats = MemoryLocalFeatureList.read(f, FloatDSIFTKeypoint.class); final File outfile = new File(outdir, f.getAbsolutePath().replace( indir.getAbsolutePath(), "")); outfile.getParentFile().mkdirs(); for (final FloatDSIFTKeypoint kpt : feats) { tmp.getArray()[0] = ArrayUtils.convertToDouble(kpt.descriptor); final double[] proj = tmp.times(basis).getArray()[0]; kpt.descriptor = ArrayUtils.convertToFloat(proj); kpt.descriptor = Arrays.copyOf(kpt.descriptor, kpt.descriptor.length + 2); kpt.descriptor[kpt.descriptor.length - 2] = (kpt.x / 125f) - 0.5f; kpt.descriptor[kpt.descriptor.length - 1] = (kpt.y / 160f) - 0.5f; } IOUtils.writeBinary(outfile, feats); f.delete(); } catch (final Exception e) { } } } });
@Override public void perform(File f) { final Matrix basis = pca.getBasis(); final Matrix tmp = new Matrix(1, 128); if (f.getName().endsWith(".bin")) { try { System.out.println("Processing " + f); final MemoryLocalFeatureList<FloatDSIFTKeypoint> feats = MemoryLocalFeatureList.read(f, FloatDSIFTKeypoint.class); final File outfile = new File(outdir, f.getAbsolutePath().replace( indir.getAbsolutePath(), "")); outfile.getParentFile().mkdirs(); for (final FloatDSIFTKeypoint kpt : feats) { tmp.getArray()[0] = ArrayUtils.convertToDouble(kpt.descriptor); final double[] proj = tmp.times(basis).getArray()[0]; kpt.descriptor = ArrayUtils.convertToFloat(proj); kpt.descriptor = Arrays.copyOf(kpt.descriptor, kpt.descriptor.length + 2); kpt.descriptor[kpt.descriptor.length - 2] = (kpt.x / 125f) - 0.5f; kpt.descriptor[kpt.descriptor.length - 1] = (kpt.y / 160f) - 0.5f; } IOUtils.writeBinary(outfile, feats); f.delete(); } catch (final Exception e) { } } } });
invStdDev[i] = 1.0 / Math.sqrt(evs[i]); W = MatrixUtils.diag(invStdDev).times(pca.getBasis().transpose());