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


Java FImage.divideInplace方法代码示例

本文整理汇总了Java中org.openimaj.image.FImage.divideInplace方法的典型用法代码示例。如果您正苦于以下问题:Java FImage.divideInplace方法的具体用法?Java FImage.divideInplace怎么用?Java FImage.divideInplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openimaj.image.FImage的用法示例。


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

示例1: processImage

import org.openimaj.image.FImage; //导入方法依赖的package包/类
@Override
public void processImage(FImage image) {
	//1st pass
	image.divideInplace(firstPassDivisor(image, mask));
	
	//2nd pass
	image.divideInplace(secondPassDivisor(image, mask));
	
	//3rd pass
	for (int y=0; y<image.height; y++) {
		for (int x=0; x<image.width; x++) {
			if (mask.pixels[y][x] == 1) {
				image.pixels[y][x] = (float) (tau * Math.tanh(image.pixels[y][x] / tau));
			} else {
				image.pixels[y][x] = 0;
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:MaskedRobustContrastEqualisation.java

示例2: createKernelImage

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * Create a kernel image with given kernel size and variance.
 * 
 * @param width
 *            image width.
 * @param height
 *            image height.
 * @param sigma
 *            variance.
 * @return new kernel image.
 */
public static FImage createKernelImage(int width, int height, float sigma) {
	final FImage f = new FImage(width, height);
	final int hw = (width - 1) / 2;
	final int hh = (height - 1) / 2;
	final float sigmasq = sigma * sigma;

	for (int y = -hh, j = 0; y <= hh; y++, j++) {
		for (int x = -hw, i = 0; x <= hw; x++, i++) {
			final int radsqrd = x * x + y * y;
			f.pixels[j][i] = (float) exp(-radsqrd / (2 * sigmasq));
		}
	}
	final float sum = FloatArrayStatsUtils.sum(f.pixels);
	return f.divideInplace(sum);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:Gaussian2D.java

示例3: createKernelImage

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * Makes a disk averaging filter with the given radius.
 * @param radius
 * @return the filter image
 */
public static FImage createKernelImage(int radius) {
	int sze = 2*radius+1;
	FImage f = new FImage(sze, sze);
	int hsz = (sze-1)/2;
	
	for (int y=-hsz, j=0; y<hsz; y++, j++) {
		for (int x=-hsz, i=0; x<hsz; x++, i++) {
			double rad = Math.sqrt(x*x + y*y);
			f.pixels[j][i] = rad < radius ? 1 : 0; 				
		}
	}
	float sum = FloatArrayStatsUtils.sum(f.pixels);
	return f.divideInplace(sum);		
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:Disk.java

示例4: main

import org.openimaj.image.FImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	final TestImageClass tic = new TestImageClass();

	final FImage trainPhoto = ResizeProcessor.halfSize(ResizeProcessor.halfSize(ImageUtilities.readF(new File(
			"/Users/jon/Desktop/images50cm4band/sp7034.jpeg"))));
	final FImage trainClass = ResizeProcessor.halfSize(ResizeProcessor.halfSize(ImageUtilities.readF(new File(
			"/Users/jon/Desktop/images50cm4band/sp7034-classes.PNG"))));

	tic.extractFeaturePatches(trainPhoto, 20000, 8);
	tic.extractClassifierTrainingPatches(trainPhoto, trainClass, 1000, 32);
	tic.learnDictionary(100);

	// Note: should really use sparse version!!
	/*
	 * final LiblinearAnnotator<FImage, Boolean> ann = new
	 * LiblinearAnnotator<FImage, Boolean>(tic, Mode.MULTICLASS,
	 * SolverType.L2R_L2LOSS_SVC, 1, 0.0001);
	 * 
	 * final MapBackedDataset<Boolean, ListBackedDataset<FImage>, FImage>
	 * data = new MapBackedDataset<Boolean, ListBackedDataset<FImage>,
	 * FImage>(); data.add(true, new
	 * ListBackedDataset<FImage>(Arrays.asList(tic.ruralPatches)));
	 * data.add(false, new
	 * ListBackedDataset<FImage>(Arrays.asList(tic.urbanPatches)));
	 * ann.train(data);
	 */
	final FImage test = ResizeProcessor.halfSize(ResizeProcessor.halfSize(ImageUtilities.readF(new File(
			"/Users/jon/Desktop/images50cm4band/test.jpeg")))).normalise();

	/*
	 * final FImage result = test.extractCenter(test.width - 32, test.height
	 * - 32); final FImage tmp = new FImage(32, 32); for (int y = 0; y <
	 * test.height - 32; y++) { for (int x = 0; x < test.width - 32; x++) {
	 * test.extractROI(x, y, tmp);
	 * 
	 * final ClassificationResult<Boolean> r = ann.classify(tmp); final
	 * Boolean clz = r.getPredictedClasses().iterator().next();
	 * 
	 * if (clz) result.pixels[y][x] = 1;
	 * 
	 * DisplayUtilities.displayName(result, "result"); } }
	 */

	final FImage tmp = new FImage(8 * 10, 8 * 10);
	for (int i = 0, y = 0; y < 10; y++) {
		for (int x = 0; x < 10; x++, i++) {
			final FImage p = new FImage(tic.dictionary[i], 8, 8);
			p.divideInplace(2 * Math.max(p.min(), p.max()));
			p.addInplace(0.5f);
			tmp.drawImage(p, x * 8, y * 8);
		}
	}
	DisplayUtilities.display(tmp);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:55,代码来源:TestImageClass.java

示例5: main

import org.openimaj.image.FImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	final File patchesFile = new File("patches.bin");

	// final RandomPatchSampler sampler =
	// new
	// RandomPatchSampler(Caltech101.getImages(ImageUtilities.FIMAGE_READER),
	// 8, 8, 100000);
	// sampler.save(patchesFile);
	final List<FImage> patches = RandomPatchSampler.loadPatches(patchesFile);

	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 WhiteningTransform whitening = new ZCAWhitening(0.1, new PerExampleMeanCenterVar(10f / 255f));
	whitening.train(data);
	final double[][] wd = whitening.whiten(data);

	// final double[][] comps =
	// whitening.getTransform().transpose().getArray();
	// for (int i = 0; i < comps.length; i++)
	// DisplayUtilities.di play(ResizeProcessor.resample(new
	// FImage(comps[i], 8, 8).normalise(), 128, 128));

	// final FImage tmp1 = new FImage(100 * 8, 100 * 8);
	// final FImage tmp2 = new FImage(100 * 8, 100 * 8);
	// final FImage tmp3 = new FImage(100 * 8, 100 * 8);
	// for (int i = 0; i < 100; i++) {
	// for (int j = 0; j < 100; j++) {
	// final double[] d = new PerExampleMeanCenterVar(10f /
	// 255f).normalise(patches.get(i * 100 + j)
	// .getDoublePixelVector());
	// FImage patch = new FImage(d, 8, 8);
	// patch.divideInplace(2 * Math.max(patch.min(), patch.max()));
	// patch.addInplace(0.5f);
	// tmp2.drawImage(patch, i * 8, j * 8);
	//
	// tmp3.drawImage(patches.get(i * 100 + j), i * 8, j * 8);
	//
	// patch = new FImage(wd[i * 100 + j], 8, 8);
	// patch.divideInplace(2 * Math.max(patch.min(), patch.max()));
	// patch.addInplace(0.5f);
	// tmp1.drawImage(patch, i * 8, j * 8);
	// }
	// }
	// DisplayUtilities.display(tmp3);
	// DisplayUtilities.display(tmp2);
	// DisplayUtilities.display(tmp1);

	final SphericalKMeans skm = new SphericalKMeans(2500, 10);
	final SphericalKMeansResult res = skm.cluster(wd);
	final FImage tmp = new FImage(50 * (8 + 1) + 1, 50 * (8 + 1) + 1);
	tmp.fill(1f);
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			final FImage patch = ResizeProcessor
					.resample(
							new FImage(res.centroids[i * 50 + j], 8, 8),
							8, 8);
			patch.divideInplace(2 * Math.max(Math.abs(patch.min()),
					Math.abs(patch.max())));
			patch.addInplace(0.5f);
			tmp.drawImage(patch, i * (8 + 1) + 1, j * (8 + 1) + 1);
		}
	}
	DisplayUtilities.display(tmp);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:69,代码来源:Test.java

示例6: sum2one

import org.openimaj.image.FImage; //导入方法依赖的package包/类
final void sum2one(FImage M) {
	M.divideInplace(M.sum());
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:4,代码来源:MPatch.java

示例7: normalise

import org.openimaj.image.FImage; //导入方法依赖的package包/类
protected static FImage normalise(FImage f) {
	final float mean = FloatArrayStatsUtils.mean(f.pixels);
	f.subtractInplace(mean);
	final float sumabs = FloatArrayStatsUtils.sumAbs(f.pixels);
	return f.divideInplace(sumabs);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:7,代码来源:LeungMalikFilterBank.java


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