本文整理汇总了Java中org.openimaj.image.colour.ColourSpace.RGBA属性的典型用法代码示例。如果您正苦于以下问题:Java ColourSpace.RGBA属性的具体用法?Java ColourSpace.RGBA怎么用?Java ColourSpace.RGBA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openimaj.image.colour.ColourSpace
的用法示例。
在下文中一共展示了ColourSpace.RGBA属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
/**
*
* @param args
* @throws MalformedURLException
* @throws IOException
*/
public static void main( final String[] args ) throws MalformedURLException, IOException
{
final MBFImage img1 = ImageUtilities.readMBF( new URL("http://www.walkmag.co.uk/wp-content/uploads/2012/05/Wineglass_Bay-landscape.jpg") );
final MBFImage img2 = ImageUtilities.readMBFAlpha( new URL("http://www.openimaj.org/images/OpenImaj.png") );
final MBFImage img3 = ImageUtilities.readMBF( new URL("http://sd.keepcalm-o-matic.co.uk/i/keep-calm-and-rule-the-world-19.png") );
final FImage alpha = img3.clone().threshold( 0.7f ).flatten().inverse().
multiplyInplace( 0.4f ).inverse().addInplace( 0.6f );
img3.addBand( alpha );
img3.colourSpace = ColourSpace.RGBA;
img2.colourSpace = ColourSpace.RGBA;
img1.drawImage( img2, 1400, 50 );
img1.drawImage( img3, 800, 100 );
DisplayUtilities.display( img1 );
}
示例2: convertFromFB
/**
* Convert packed RGBA pixels in a {@link FloatBuffer} back into an
* {@link MBFImage}. The method takes the {@link MBFImage} as an argument, and
* will fill it accordingly. If the image argument is null, a new
* {@link MBFImage} with the RGBA {@link ColourSpace} will be created.
* If the given image is the wrong size, it will be resized. If the given
* image has less than four bands, then only these bands will be filled.
* Any bands above the fourth will be ignored.
*
* @param fb the {@link FloatBuffer} containing the pixels
* @param width the width
* @param height the height
* @param image the image to write to or null
* @return the image
*/
public static MBFImage convertFromFB(FloatBuffer fb, int width, int height, MBFImage image) {
if (image == null)
image = new MBFImage(width, height, ColourSpace.RGBA);
if (image.getWidth() != width || image.getHeight() != height)
image.internalAssign(image.newInstance(width, height));
final FImage[] bands = image.bands.toArray(new FImage[image.numBands()]);
final int nbands = Math.min(4, image.numBands());
final int extraBands = 4 - nbands;
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
for (int b=0; b<nbands; b++) {
bands[b].pixels[y][x] = fb.get();
}
for (int b=0; b<extraBands; b++) {
fb.get();
}
}
}
return image;
}
示例3: setPixel
@Override
public void setPixel(final int x, final int y, final Float[] val) {
// Check if we have an alpha channel. If we do, we'll use alpha
// compositing, otherwise, we'll simply copy the pixel colour into
// the pixel position.
if (this.colourSpace == ColourSpace.RGBA && this.numBands() >= 4 && val.length >= 4
&& x >= 0 && x < this.getWidth() && y >= 0 && y < this.getHeight())
{
final float[] p = ImageUtilities.alphaCompositePixel(this.getPixel(x, y), val);
this.getBand(0).pixels[y][x] = p[0];
this.getBand(1).pixels[y][x] = p[1];
this.getBand(2).pixels[y][x] = p[2];
if (this.numBands() >= 4)
this.getBand(3).pixels[y][x] = p[3];
} else
super.setPixel(x, y, val);
}
示例4: internalAssign
@Override
public MBFImage internalAssign(final int[] data, final int width, final int height) {
if (this.getWidth() != width || this.getHeight() != height)
this.internalAssign(this.newInstance(width, height));
final float[][] br = this.bands.get(0).pixels;
final float[][] bg = this.bands.get(1).pixels;
final float[][] bb = this.bands.get(2).pixels;
float[][] ba = null;
if (this.colourSpace == ColourSpace.RGBA)
ba = this.bands.get(3).pixels;
for (int i = 0, y = 0; y < height; y++) {
for (int x = 0; x < width; x++, i++) {
final int rgb = data[i];
final int alpha = ((rgb >> 24) & 0xff);
final int red = ((rgb >> 16) & 0xff);
final int green = ((rgb >> 8) & 0xff);
final int blue = ((rgb) & 0xff);
br[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[red];
bg[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[green];
bb[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[blue];
if (ba != null)
ba[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[alpha];
}
}
return this;
}
示例5: MBFImage
/**
* Construct an empty image. If the number of bands is 3, RGB is assumed, if
* the number is 4, then RGBA is assumed, otherwise the colourspace is set
* to CUSTOM.
*
* @param width
* Width of image
* @param height
* Height of image
* @param nbands
* number of bands
*/
public MBFImage(final int width, final int height, final int nbands) {
if (nbands == 3)
this.colourSpace = ColourSpace.RGB;
else if (nbands == 4)
this.colourSpace = ColourSpace.RGBA;
for (int i = 0; i < nbands; i++) {
this.bands.add(new FImage(width, height));
}
}