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


Java ColourSpace.getNumBands方法代码示例

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


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

示例1: computeMean

import org.openimaj.image.colour.ColourSpace; //导入方法依赖的package包/类
/**
 * Compute the mean of the image
 *
 * @param frame
 * @param colourSpace
 * @return
 */
public static double[] computeMean(MBFImage frame, ColourSpace colourSpace) {
	final double[] vector = new double[colourSpace.getNumBands()];

	for (int b = 0; b < colourSpace.getNumBands(); b++) {
		final float[][] pix = frame.getBand(b).pixels;

		vector[b] = FloatArrayStatsUtils.mean(pix);
	}
	return vector;
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:18,代码来源:SimpleMeanColourFeatureDemo.java

示例2: test2way

import org.openimaj.image.colour.ColourSpace; //导入方法依赖的package包/类
/**
 * Test the 3 band conversions
 */
@Test
public void test2way() {
	final double eps = 0.05;

	for (final ColourSpace cs : ColourSpace.values()) {
		if (cs.getNumBands() == 3 && cs != ColourSpace.RGB_INTENSITY_NORMALISED) {
			try {
				final MBFImage rgbIn = MBFImage.randomImage(100, 100);

				final MBFImage cvt = cs.convertFromRGB(rgbIn);
				final MBFImage rgbOut = cs.convertToRGB(cvt);

				for (int y = 0; y < 100; y++) {
					for (int x = 0; x < 100; x++) {
						final float rin = rgbIn.getBand(0).pixels[y][x];
						final float gin = rgbIn.getBand(1).pixels[y][x];
						final float bin = rgbIn.getBand(2).pixels[y][x];

						final float rout = rgbOut.getBand(0).pixels[y][x];
						final float gout = rgbOut.getBand(1).pixels[y][x];
						final float bout = rgbOut.getBand(2).pixels[y][x];

						assertTrue(Math.abs(rin - rout) < eps);
						assertTrue(Math.abs(gin - gout) < eps);
						assertTrue(Math.abs(bin - bout) < eps);
					}
				}
			} catch (final UnsupportedOperationException e) {
				// ignore
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:37,代码来源:ColourSpaceTest.java

示例3: KMColourSegmenter

import org.openimaj.image.colour.ColourSpace; //导入方法依赖的package包/类
/**
 * Construct using the given colour space, number of segments, and distance
 * measure. The elements of each colour band are by the corresponding
 * elements in the given scaling vector, and the k-means algorithm will
 * iterate at most <code>maxIters</code> times.
 * 
 * @param colourSpace
 *            the colour space
 * @param scaling
 *            the scaling vector
 * @param K
 *            the number of segments
 * @param distance
 *            the distance measure
 * @param maxIters
 *            the maximum number of iterations to perform
 */
public KMColourSegmenter(ColourSpace colourSpace, float[] scaling, int K, FloatFVComparator distance, int maxIters) {
	if (scaling != null && scaling.length < colourSpace.getNumBands())
		throw new IllegalArgumentException(
				"Scaling vector must have the same length as the number of dimensions of the target colourspace (or more)");

	this.colourSpace = colourSpace;
	this.scaling = scaling;

	final KMeansConfiguration<FloatNearestNeighbours, float[]> conf =
			new KMeansConfiguration<FloatNearestNeighbours, float[]>(
					K,
					new FloatNearestNeighboursExact.Factory(distance),
					maxIters);

	this.kmeans = new FloatKMeans(conf);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:KMColourSegmenter.java

示例4: MBFImage

import org.openimaj.image.colour.ColourSpace; //导入方法依赖的package包/类
/**
 * Construct an empty image
 *
 * @param width
 *            Width of image
 * @param height
 *            Height of image
 * @param colourSpace
 *            the colourspace
 */
public MBFImage(final int width, final int height, final ColourSpace colourSpace) {
	this.colourSpace = colourSpace;

	for (int i = 0; i < colourSpace.getNumBands(); i++) {
		this.bands.add(new FImage(width, height));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:MBFImage.java


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