本文整理汇总了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;
}
示例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
}
}
}
}
示例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);
}
示例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));
}
}