本文整理汇总了Java中org.openimaj.image.MBFImage.divideInplace方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.divideInplace方法的具体用法?Java MBFImage.divideInplace怎么用?Java MBFImage.divideInplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.MBFImage
的用法示例。
在下文中一共展示了MBFImage.divideInplace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawCentroids
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
MBFImage drawCentroids(double[][] centroids) {
final int wh = (int) Math.sqrt(numCentroids);
final MBFImage tmp = new MBFImage(wh * (patchSize + 1) + 1, wh * (patchSize + 1) + 1);
final float mn = -1.0f;
final float mx = +1.0f;
tmp.fill(new Float[] { mx, mx, mx });
for (int i = 0, y = 0; y < wh; y++) {
for (int x = 0; x < wh; x++, i++) {
final MBFImage p = new MBFImage(centroids[i], patchSize, patchSize, 3, false);
tmp.drawImage(p, x * (patchSize + 1) + 1, y * (patchSize + 1) + 1);
}
}
tmp.subtractInplace(mn);
tmp.divideInplace(mx - mn);
return tmp;
}
示例2: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
System.out.println("start");
final RandomPatchSampler<MBFImage> sampler = new RandomPatchSampler<MBFImage>(
CIFAR10Dataset.getTrainingImages(CIFAR10Dataset.MBFIMAGE_READER),
8, 8, 400000);
final List<MBFImage> patches = sampler.getPatches();
System.out.println("stop");
final double[][] data = new double[patches.size()][];
for (int i = 0; i < data.length; i++)
data[i] = patches.get(i).getDoublePixelVector();
// final PCAWhitening whitening = new PCAWhitening();
final ZCAWhitening whitening = new ZCAWhitening(0.1, new PerExampleMeanCenter());
whitening.train(data);
final double[][] wd = whitening.whiten(data);
final SphericalKMeans skm = new SphericalKMeans(1600, 10);
final SphericalKMeansResult res = skm.cluster(wd);
final MBFImage tmp = new MBFImage(40 * (8 + 1) + 1, 40 * (8 + 1) + 1);
tmp.fill(RGBColour.WHITE);
for (int i = 0; i < 40; i++) {
for (int j = 0; j < 40; j++) {
final MBFImage patch = new MBFImage(res.centroids[i * 40 + j], 8, 8, 3, false);
tmp.drawImage(patch, i * (8 + 1) + 1, j * (8 + 1) + 1);
}
}
tmp.subtractInplace(-1.5f);
tmp.divideInplace(3f);
DisplayUtilities.display(tmp);
}