本文整理汇总了Java中org.openimaj.image.colour.ColourSpace类的典型用法代码示例。如果您正苦于以下问题:Java ColourSpace类的具体用法?Java ColourSpace怎么用?Java ColourSpace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColourSpace类属于org.openimaj.image.colour包,在下文中一共展示了ColourSpace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
final String rawcmd = e.getActionCommand();
final String cmd = rawcmd.substring(rawcmd.indexOf(".") + 1);
if (rawcmd.startsWith("ColourSpace.")) {
// change the colour space to the one selected
this.colourSpace = ColourSpace.valueOf(cmd);
this.classes.clear();
this.points.clear();
} else if (rawcmd.startsWith("button.")) {
if (cmd.equals("learn")) {
doLearn(lastMean, this.classType.getSelectedIndex());
}
}
}
示例2: getComponent
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
@Override
public JPanel getComponent(int width, int height) throws IOException {
final JPanel base = super.getComponent(width, height);
// add a listener for new video frames
vc.getDisplay().addVideoListener(this);
// the controls panel
final JPanel controlsPanel = new JPanel(new GridLayout(0, 1));
controlsPanel.setOpaque(false);
final ButtonGroup group = new ButtonGroup();
for (final ColourSpace c : colourSpaces)
createRadioButton(controlsPanel, group, c);
base.add(controlsPanel);
return base;
}
示例3: convertColours
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
* Convert the colour space of an image, maintaining three bands so it can
* be displayed
*
* @param frame
* @param colourSpace
*/
public static void convertColours(MBFImage frame, ColourSpace colourSpace) {
// update the frame from the camera by converting to the selected colour
// space before display
final MBFImage cvt = colourSpace.convert(frame);
// if the converted image has fewer than 3 bands, add more so it can be
// displayed as RGB.
if (cvt.numBands() == 1) {
// this makes a three-band grey-level image, where all the bands are
// the same
cvt.bands.add(cvt.getBand(0).clone());
cvt.bands.add(cvt.getBand(0).clone());
} else if (cvt.numBands() == 2) {
// this adds a third zero band to a two-band image
cvt.bands.add(new FImage(cvt.getWidth(), cvt.getHeight()));
}
// this sets the frame to the colour converted version
frame.internalAssign(cvt);
}
示例4: makeVideo
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
AnimatedVideo<MBFImage> makeVideo(final Scene scene) {
return new AnimatedVideo<MBFImage>(new MBFImage(500, 500, ColourSpace.RGB)) {
float angle = 0;
@Override
protected void updateNextFrame(MBFImage frame) {
frame.fill(RGBColour.BLACK);
scene.renderOrtho(
Simple3D.euler2Rot(Math.PI / 4, angle, 0),
frame);
angle += (2 * Math.PI / 360);
if (angle >= Math.PI * 2)
angle -= 2 * Math.PI;
}
};
}
示例5: plot2d
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
MBFImage plot2d(double[][] data) {
final MBFImage img = new MBFImage(500, 500, ColourSpace.RGB);
img.drawLine(img.getWidth() / 2, img.getHeight() - 50, img.getWidth() / 2, 50, 3, RGBColour.RED);
img.drawLine(img.getWidth() / 2 - 10, 70, img.getWidth() / 2, 50, 3, RGBColour.RED);
img.drawLine(img.getWidth() / 2 + 10, 70, img.getWidth() / 2, 50, 3, RGBColour.RED);
img.drawText("EV2", img.getWidth() / 2 - 80, 70, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);
img.drawLine(50, img.getHeight() / 2, img.getWidth() - 50, img.getHeight() / 2, 3, RGBColour.RED);
img.drawLine(img.getWidth() - 70, img.getHeight() / 2 + 10, img.getWidth() - 50, img.getHeight() / 2, 3,
RGBColour.RED);
img.drawLine(img.getWidth() - 70, img.getHeight() / 2 - 10, img.getWidth() - 50, img.getHeight() / 2, 3,
RGBColour.RED);
img.drawText("EV1", img.getWidth() - 70, img.getHeight() / 2 + 50, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);
for (final double[] d : data) {
img.drawPoint(new Point2dImpl(img.getWidth() / 2 - (float) d[0], img.getHeight() / 2 - (float) d[1]),
RGBColour.GREEN, 3);
}
return img;
}
示例6: plot1d
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
MBFImage plot1d(double[][] data) {
final MBFImage img = new MBFImage(500, 500, ColourSpace.RGB);
img.drawLine(50, img.getHeight() / 2, img.getWidth() - 50, img.getHeight() / 2, 3, RGBColour.RED);
img.drawLine(img.getWidth() - 70, img.getHeight() / 2 + 10, img.getWidth() - 50, img.getHeight() / 2, 3,
RGBColour.RED);
img.drawLine(img.getWidth() - 70, img.getHeight() / 2 - 10, img.getWidth() - 50, img.getHeight() / 2, 3,
RGBColour.RED);
img.drawText("EV1", img.getWidth() - 70, img.getHeight() / 2 + 50, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);
for (final double[] d : data) {
img.drawPoint(new Point2dImpl(img.getWidth() / 2 - (float) d[0], img.getHeight() / 2),
RGBColour.GREEN, 3);
}
return img;
}
示例7: MSEREllipseFinder
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
* Construct demo
*/
public MSEREllipseFinder() {
final MBFImage image = new MBFImage(400, 400, ColourSpace.RGB);
final MBFImageRenderer renderer = image.createRenderer();
image.fill(RGBColour.WHITE);
final List<Ellipse> ellipses = new ArrayList<Ellipse>();
ellipses.add(new Ellipse(200, 100, 100, 80, Math.PI / 4));
ellipses.add(new Ellipse(200, 300, 50, 30, -Math.PI / 4));
ellipses.add(new Ellipse(100, 300, 30, 50, -Math.PI / 3));
for (final Ellipse ellipse : ellipses) {
renderer.drawShapeFilled(ellipse, RGBColour.BLACK);
}
final MSERFeatureGenerator mser = new MSERFeatureGenerator(MomentFeature.class);
final List<Component> features = mser.generateMSERs(Transforms
.calculateIntensityNTSC(image));
for (final Component c : features) {
final MomentFeature feature = c.getFeature(MomentFeature.class);
renderer.drawShape(feature.getEllipse(2), RGBColour.RED);
renderer.drawShape(feature.getEllipse(2)
.calculateOrientedBoundingBox(), RGBColour.GREEN);
}
DisplayUtilities.display(image);
}
示例8: main
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
* Default main
* @param args Command-line arguments
*/
public static void main(String args[]){
ellipse = new Ellipse(400,400,100,50,0);
image = new MBFImage(800,800,ColourSpace.RGB);
frame = DisplayUtilities.display(image);
displayUpdater = new Runnable(){
@Override
public void run() {
while(true){
DisplayUtilities.display(image,frame);
update();
try {
Thread.sleep(1000/30);
} catch (InterruptedException e) {
}
}
}
};
Thread t = new Thread(displayUpdater);
t.start();
}
示例9: buildBinCols
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
void buildBinCols() {
this.binCols = new Float[4 * 4 * 4][];
for (int k = 0; k < 4; k++) {
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
final float h = (float) i / 4 + (0.5f / 4);
final float s = (float) j / 4 + (0.5f / 4);
final float v = (float) k / 4 + (0.5f / 4);
MBFImage img = new MBFImage(1, 1, ColourSpace.HSV);
img.setPixel(0, 0, new Float[] { h, s, v });
img = Transforms.HSV_TO_RGB(img);
this.binCols[k * 4 * 4 + j * 4 + i] = img.getPixel(0, 0);
}
}
}
}
示例10: doTutorial
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
final MBFImage space = ColourSpace.convert(toDraw, ColourSpace.CIE_Lab);
if (cluster == null)
cluster = clusterPixels(space);
if (cluster == null)
return;
final float[][] centroids = cluster.getCentroids();
final ExactFloatAssigner assigner = new ExactFloatAssigner(cluster);
for (int y = 0; y < space.getHeight(); y++) {
for (int x = 0; x < space.getWidth(); x++) {
final float[] pixel = space.getPixelNative(x, y);
final int centroid = assigner.assign(pixel);
space.setPixelNative(x, y, centroids[centroid]);
}
}
toDraw.internalAssign(ColourSpace.convert(space, ColourSpace.RGB));
}
示例11: drawMkpLine
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
private static void drawMkpLine(DoubleArrayKernelPerceptron mkp) {
final MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);
final List<double[]> sup = mkp.getSupports();
final List<Double> weights = mkp.getWeights();
final double bias = mkp.getBias();
System.out.println("Bias: " + bias);
double[] startD = null;
double[] endD = null;
double[] mean = new double[2];
if (mkp instanceof MeanCenteredKernelPerceptron) {
mean = ((MeanCenteredKernelPerceptron) mkp).getMean();
} else if (mkp instanceof MeanCenteredProjectron) {
mean = ((MeanCenteredProjectron) mkp).getMean();
}
startD = LinearVectorKernel.getPlanePoint(sup, weights, bias, -mean[0], Double.NaN);
endD = LinearVectorKernel.getPlanePoint(sup, weights, bias, img.getWidth() - mean[0], Double.NaN);
startD[0] += mean[0];
startD[1] += mean[1];
endD[0] += mean[0];
endD[1] += mean[1];
drawLine(img, startD, endD);
}
示例12: drawPoints
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
private static void drawPoints(Stream<IndependentPair<double[], PerceptronClass>> dataStream, Line2d line) {
final MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);
img.drawLine(line, 3, RGBColour.BLUE);
for (final IndependentPair<double[], PerceptronClass> pointClass : dataStream) {
final double[] pc = pointClass.firstObject();
final Point2dImpl point = new Point2dImpl((float) pc[0], (float) pc[1]);
final PerceptronClass cls = pointClass.getSecondObject();
switch (cls) {
case TRUE:
img.drawShapeFilled(new Circle(point, 5), RGBColour.GREEN);
break;
case FALSE:
img.drawShape(new Circle(point, 5), 3, RGBColour.RED);
break;
case NONE:
throw new RuntimeException("NOPE");
}
}
DisplayUtilities.displayName(img, "random");
}
示例13: main
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
*
* @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 );
}
示例14: main
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
public static void main(String[] args) {
final MBFImage image = new MBFImage(400, 400, ColourSpace.RGB);
final MBFImageRenderer renderer = image.createRenderer();
image.fill(RGBColour.BLACK);
final List<Ellipse> ellipses = new ArrayList<Ellipse>();
ellipses.add(new Ellipse(200, 100, 10, 8, Math.PI / 4));
ellipses.add(new Ellipse(200, 300, 5, 3, -Math.PI / 4));
ellipses.add(new Ellipse(100, 300, 3, 5, -Math.PI / 3));
for (final Ellipse ellipse : ellipses) {
renderer.drawShapeFilled(ellipse, RGBColour.WHITE);
}
final LOCKY locky = new LOCKY();
locky.findInterestPoints(image.flatten());
final List<EllipticInterestPointData> pts = locky.getInterestPoints();
for (final EllipticInterestPointData pt : pts) {
image.drawShape(pt.getEllipse(), RGBColour.RED);
}
DisplayUtilities.display(image);
}
示例15: main
import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
* Main method
*
* @param args
*/
public static void main(String[] args) {
// Create an image
final MBFImage image = new MBFImage(320, 70, ColourSpace.RGB);
// Fill the image with white
image.fill(RGBColour.WHITE);
// Render some test into the image
image.drawText("Hello World", 10, 60, HersheyFont.CURSIVE, 50, RGBColour.BLACK);
// Apply a Gaussian blur
image.processInplace(new FGaussianConvolve(2f));
// Display the image
DisplayUtilities.display(image);
}