• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RenderHints类的典型用法和代码示例

java 1次浏览

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

RenderHints类属于org.openimaj.image.renderer包,在下文中一共展示了RenderHints类的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: beforeUpdate

点赞 3

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	tracker.track(frame);

	frame.bands.get(1).fill(0f);
	frame.bands.get(2).fill(0f);

	final FontStyle<Float[]> gfs = new GeneralFont("Bank Gothic", Font.PLAIN).createStyle(frame
			.createRenderer(RenderHints.ANTI_ALIASED));
	gfs.setFontSize(40);
	gfs.setHorizontalAlignment(HorizontalAlignment.HORIZONTAL_CENTER);

	if (tracker.getTrackedFaces().size() > 0) {
		final TrackedFace tf = tracker.getTrackedFaces().get(0);
		drawFaceModel(frame, tf, tracker.triangles, tracker.connections);
		frame.drawText("TRACKING", frame.getWidth() / 2, frame.getHeight() - 10, gfs);
	} else {
		frame.drawText("SEARCHING", frame.getWidth() / 2, frame.getHeight() / 2, gfs);
	}
}
 

开发者ID:jonhare,
项目名称:ecs-summer-school-vision-lecture,
代码行数:21,
代码来源:CLMDemo.java

示例2: redrawCircles

点赞 3

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
private void redrawCircles(MBFImage output) {
	long now = System.currentTimeMillis();
	output.fill(RGBColour.WHITE);
	MBFImageRenderer rend = output.createRenderer(RenderHints.ANTI_ALIASED);
	for (String hash: this.hashCircles.keySet()) {
		Circle circle = this.hashCircles.get(hash);
		Float[] col = this.hashColours.get(hash);
		float level = 2;
		long lastSeen = this.hashAggregations.get(hash).lastSeen;
		if(lastSeen!=0){				
			long diff = Math.abs(lastSeen - now);
			if(diff < BLIP_TIME){
				level -= (1 - ( diff / (float)BLIP_TIME));
			}
		}
		Float[] offCircleColour = dark(col,level);
		
		drawHashCircle(rend , hash, circle, offCircleColour);
	}
	for (IndependentPair<Point2dImpl, MBFImage> pTextLayer : this.textLayers) {
		
		MBFImage textLayer = pTextLayer.getSecondObject();
		Point2d p = pTextLayer.firstObject();
		output.drawImage(textLayer , (int)p.getX(), (int)p.getY());
	}
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:27,
代码来源:PrettyTagRenderer.java

示例3: render

点赞 3

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
protected FImage render(List<IndependentPair<String, Point2d>> pts, int sz) {
	FImage image = new FImage(sz, sz);
	FImageRenderer renderer = image.createRenderer(RenderHints.ANTI_ALIASED);


	for (IndependentPair<String, Point2d> pair : pts) {
		double x = pair.secondObject().getX();
		double y = pair.secondObject().getY();

		int ix = (int) Math.round((x + 0.5) * sz/2);
		int iy = (int) Math.round((y + 0.5) * sz/2);

		renderer.drawShapeFilled(new Circle(ix, iy, 2), 1f);
		renderer.drawText(pair.firstObject(), ix+5, iy, HersheyFont.TIMES_MEDIUM, 20, 1f);
	}
	
	return image;
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:19,
代码来源:MDS.java

示例4: StructureTensorDemo

点赞 3

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
public StructureTensorDemo() {
	this.image = new FImage(300, 300);
	final FImageRenderer r = image.createRenderer(RenderHints.ANTI_ALIASED);
	r.drawLine(0, 150, 75, 75, 3, 1f);
	r.drawLine(0, 0, 75, 75, 3, 1f);
	r.drawLine(0, 200, 100, 250, 3, 1f);
	r.drawLine(0, 300, 100, 250, 3, 1f);
	r.drawLine(200, 0, 200, 100, 3, 1f);
	r.drawLine(200, 100, 300, 100, 3, 1f);
	r.drawLine(250, 300, 200, 200, 3, 1f);
	r.drawLine(300, 250, 200, 200, 3, 1f);

	final FSobel fs = new FSobel();
	fs.analyseImage(image);
	this.dx = fs.dx;
	this.dy = fs.dy;
}
 

开发者ID:jonhare,
项目名称:COMP3005,
代码行数:18,
代码来源:StructureTensorDemo.java

示例5: updateImage

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
protected void updateImage() {
	xxField.setText(String.format("%2.2f", covariance.get(0, 0)));
	xyField.setText(String.format("%2.2f", covariance.get(0, 1)));
	yxField.setText(String.format("%2.2f", covariance.get(1, 0)));
	yyField.setText(String.format("%2.2f", covariance.get(1, 1)));

	image.fill(RGBColour.WHITE);

	image.drawLine(image.getWidth() / 2, 0, image.getWidth() / 2, image.getHeight(), 3, RGBColour.BLACK);
	image.drawLine(0, image.getHeight() / 2, image.getWidth(), image.getHeight() / 2, 3, RGBColour.BLACK);

	Ellipse e = EllipseUtilities.ellipseFromCovariance(image.getWidth() / 2, image.getHeight() / 2, covariance,
			100);
	e = e.transformAffine(TransformUtilities.scaleMatrixAboutPoint(1, -1, image.getWidth() / 2, image.getHeight() / 2));

	if (!Double.isNaN(e.getMajor()) && !Double.isNaN(e.getMinor()) && covariance.rank() == 2) {
		final Matrix mean = new Matrix(new double[][] { { image.getWidth() / 2, image.getHeight() / 2 } });
		final CachingMultivariateGaussian gauss = new CachingMultivariateGaussian(mean, covariance);

		if (drawData) {
			final Random rng = new Random();
			for (int i = 0; i < 1000; i++) {
				final double[] sample = gauss.sample(rng);
				Point2dImpl pt = new Point2dImpl((float) sample[0], (float) sample[1]);
				pt = pt.transform(TransformUtilities.scaleMatrixAboutPoint(40, -40, image.getWidth() / 2,
						image.getHeight() / 2));
				image.drawPoint(pt, RGBColour.BLUE, 3);
			}
		}

		if (drawEllipse)
			image.createRenderer(RenderHints.ANTI_ALIASED).drawShape(e, 3, RGBColour.RED);
	}

	this.imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
}
 

开发者ID:jonhare,
项目名称:COMP6237,
代码行数:37,
代码来源:CovarianceDemo.java

示例6: KinectDemo

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
/**
 * Default constructor
 * 
 * @param id
 *            of kinect controller
 * @throws KinectException
 */
public KinectDemo(int id) throws KinectException {
	controller = new KinectController(id, irmode, rdepth);
	currentFrame = new MBFImage(640 * 2, 480, ColourSpace.RGB);
	renderer = currentFrame.createRenderer(RenderHints.ANTI_ALIASED);

	videoFrame = VideoDisplay.createVideoDisplay(this);
	((JFrame) SwingUtilities.getRoot(videoFrame.getScreen())).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	SwingUtilities.getRoot(videoFrame.getScreen()).addKeyListener(this);

	v3d = new MBFImage(640, 480);
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:19,
代码来源:KinectDemo.java

示例7: main

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
/**
 * Just for testing render quality against AWT
 *
 * @param args
 */
public static void main(String[] args) {
	final FImage tmp = new FImage(800, 800);
	final int size = 40;
	tmp.drawText("Hello World!", 20, 20 + size, new GeneralFont("Arial", Font.PLAIN), size);

	final GeneralFontStyle<Float> gfs = new GeneralFontStyle<Float>(new GeneralFont("Arial", Font.PLAIN),
			tmp.createRenderer(RenderHints.ANTI_ALIASED));
	gfs.setFontSize(size);
	final Polygon[] polys = getPolygons("Hello World!", 20, 20 + 2 * size, gfs);
	for (final Polygon p : polys)
		tmp.drawPolygon(p, 1f);

	final Font fnt = new Font("Arial", Font.PLAIN, size);
	final BufferedImage bimg = ImageUtilities.createBufferedImage(tmp);

	final Graphics g = bimg.getGraphics();
	g.setFont(fnt);
	g.drawString("Hello World!", 20, 20 + 3 * size);

	final GlyphVector gl = fnt.createGlyphVector(new FontRenderContext(null, true, true),
			"Hello World!");
	for (int i = 0; i < gl.getNumGlyphs(); i++) {
		((Graphics2D) g).fill(gl.getGlyphOutline(i, 20, 20 + 4 * size));
	}

	DisplayUtilities.display(bimg);
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:33,
代码来源:GeneralFontRenderer.java

示例8: beforeUpdate

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	ColourSpacesDemo.convertColours(frame, colourSpace);

	lastMean = computeMean(frame, colourSpace);
	featureField.setText(SimpleMeanColourFeatureDemo.formatVector(lastMean));

	redraw();
	final Float[] col = doClassify(lastMean);

	frame.createRenderer(RenderHints.ANTI_ALIASED).drawShape(circle, 3, col);
}
 

开发者ID:jonhare,
项目名称:COMP3204,
代码行数:13,
代码来源:TomatoLinearClassifierDemo.java

示例9: beforeUpdate

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	frame.flipX();

	lastMean = computeMean(frame, colourSpace);
	featureField.setText(formatVector(lastMean));

	redraw();
	final Float[] col = doClassify(lastMean);

	frame.createRenderer(RenderHints.ANTI_ALIASED).drawShape(circle, 3, col);
}
 

开发者ID:jonhare,
项目名称:COMP3204,
代码行数:13,
代码来源:TomatoKNNClassifierDemo.java

示例10: getComponent

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 50, ColourSpace.RGB);
	renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.addMouseListener(this);
	ic.addMouseMotionListener(this);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	clearBtn = new JButton("Clear");
	clearBtn.setActionCommand("button.clear");
	clearBtn.addActionListener(this);
	controls.add(clearBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("K:"));

	kSpn = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
	controls.add(kSpn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run KMeans");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 

开发者ID:jonhare,
项目名称:COMP6208,
代码行数:58,
代码来源:KMeansDemo.java

示例11: getComponent

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 56, ColourSpace.RGB);
	som = new float[(height - 56) / somfactor][width / somfactor][rawdata.getTerms().size()];
	renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 56));
	controls.setMaximumSize(new Dimension(width, 56));
	controls.setSize(new Dimension(width, 56));

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run SOM");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 

开发者ID:jonhare,
项目名称:COMP6237,
代码行数:46,
代码来源:SOMDemo.java

示例12: getComponent

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 50, ColourSpace.RGB);
	renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.addMouseListener(this);
	ic.addMouseMotionListener(this);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	clearBtn = new JButton("Clear");
	clearBtn.setActionCommand("button.clear");
	clearBtn.addActionListener(this);
	controls.add(clearBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("K:"));

	kSpn = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
	controls.add(kSpn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("Distance:"));

	distCombo = new JComboBox<String>();
	distCombo.addItem("Euclidean");
	distCombo.addItem("Manhatten");
	distCombo.addItem("Cosine Distance");
	controls.add(distCombo);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run KMeans");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 

开发者ID:jonhare,
项目名称:COMP6237,
代码行数:67,
代码来源:KMeansDemo.java

示例13: getComponent

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 50, ColourSpace.RGB);
	renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.addMouseListener(this);
	ic.addMouseMotionListener(this);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	clearBtn = new JButton("Clear");
	clearBtn.setActionCommand("button.clear");
	clearBtn.addActionListener(this);
	controls.add(clearBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	controls.add(new JLabel("H:"));
	hSpn = new JSpinner(new SpinnerNumberModel(30, 1, 100, 5));
	controls.add(hSpn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run Mean Shift");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 

开发者ID:jonhare,
项目名称:COMP6237,
代码行数:58,
代码来源:MeanShiftDemo.java

示例14: getComponent

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 50, ColourSpace.RGB);
	renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.addMouseListener(this);
	ic.addMouseMotionListener(this);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	clearBtn = new JButton("Clear");
	clearBtn.setActionCommand("button.clear");
	clearBtn.addActionListener(this);
	controls.add(clearBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("Distance:"));

	distCombo = new JComboBox<String>();
	distCombo.addItem("Euclidean");
	distCombo.addItem("Manhatten");
	distCombo.addItem("Cosine Distance");
	controls.add(distCombo);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("Linkage:"));

	linkCombo = new JComboBox<String>();
	for (final Linkage s : Linkage.values())
		linkCombo.addItem(s.name());
	controls.add(linkCombo);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run HAC");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 

开发者ID:jonhare,
项目名称:COMP6237,
代码行数:69,
代码来源:HClusterDemo.java

示例15: updateImage

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
protected void updateImage() {
	xxField.setText(String.format("%2.2f", covariance.get(0, 0)));
	xyField.setText(String.format("%2.2f", covariance.get(0, 1)));
	yxField.setText(String.format("%2.2f", covariance.get(1, 0)));
	yyField.setText(String.format("%2.2f", covariance.get(1, 1)));

	image.fill(RGBColour.WHITE);

	image.drawLine(image.getWidth() / 2, 0, image.getWidth() / 2, image.getHeight(), 3, RGBColour.BLACK);
	image.drawLine(0, image.getHeight() / 2, image.getWidth(), image.getHeight() / 2, 3, RGBColour.BLACK);

	Ellipse e = EllipseUtilities.ellipseFromCovariance(image.getWidth() / 2, image.getHeight() / 2, covariance,
			100);
	e = e.transformAffine(TransformUtilities.scaleMatrixAboutPoint(1, -1, image.getWidth() / 2, image.getHeight() / 2));

	if (!Double.isNaN(e.getMajor()) && !Double.isNaN(e.getMinor()) && covariance.rank() == 2) {
		final EigenvalueDecomposition decomp = this.covariance.eig();
		final Matrix evecm = decomp.getV().copy();
		final Matrix evalm = decomp.getD().copy();

		// flip so biggest ev is first
		MatrixUtils.reverseColumnsInplace(evecm);
		MatrixUtils.reverseColumnsInplace(evalm);
		MatrixUtils.reverseRowsInplace(evalm);

		evec00.setText(String.format("%2.2f", evecm.get(0, 0)));
		evec01.setText(String.format("%2.2f", evecm.get(0, 1)));
		evec10.setText(String.format("%2.2f", evecm.get(1, 0)));
		evec11.setText(String.format("%2.2f", evecm.get(1, 1)));

		eval00.setText(String.format("%2.2f", evalm.get(0, 0)));
		eval01.setText(String.format("%2.2f", evalm.get(0, 1)));
		eval10.setText(String.format("%2.2f", evalm.get(1, 0)));
		eval11.setText(String.format("%2.2f", evalm.get(1, 1)));

		final Matrix mean = new Matrix(new double[][] { { image.getWidth() / 2, image.getHeight() / 2 } });
		final CachingMultivariateGaussian gauss = new CachingMultivariateGaussian(mean, covariance);

		if (drawData) {
			final Random rng = new Random();
			for (int i = 0; i < 1000; i++) {
				final double[] sample = gauss.sample(rng);
				Point2dImpl pt = new Point2dImpl((float) sample[0], (float) sample[1]);
				pt = pt.transform(TransformUtilities.scaleMatrixAboutPoint(40, -40, image.getWidth() / 2,
						image.getHeight() / 2));
				image.drawPoint(pt, RGBColour.BLUE, 3);
			}
		}

		final MBFImageRenderer renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
		if (drawEllipse)
			renderer.drawShape(e, 3, RGBColour.RED);
		int x = (int) (100 * decomp.getV().get(0, 0) * Math.sqrt(decomp.getRealEigenvalues()[0]));
		int y = (int) (100 * decomp.getV().get(1, 0) * Math.sqrt(decomp.getRealEigenvalues()[0]));
		renderer.drawLine(image.getWidth() / 2, image.getHeight() / 2, x + image.getWidth() / 2,
				image.getHeight() / 2 - y, 3, RGBColour.GREEN);

		x = (int) (100 * decomp.getV().get(0, 1) * Math.sqrt(decomp.getRealEigenvalues()[1]));
		y = (int) (100 * decomp.getV().get(1, 1) * Math.sqrt(decomp.getRealEigenvalues()[1]));
		renderer.drawLine(image.getWidth() / 2, image.getHeight() / 2, x + image.getWidth() / 2,
				image.getHeight() / 2 - y, 3, RGBColour.GREEN);
	} else {
		evec00.setText("");
		evec01.setText("");
		evec10.setText("");
		evec11.setText("");

		eval00.setText("");
		eval01.setText("");
		eval10.setText("");
		eval11.setText("");
	}

	this.imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
}
 

开发者ID:jonhare,
项目名称:COMP6237,
代码行数:77,
代码来源:EigenDecompositionDemo.java

示例16: drawCachedImage

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
private void drawCachedImage(final MBFImage img,
		final AxesRenderer2D<Float[], MBFImage> axesRenderer)
{
	synchronized (axesRenderer)
	{
		System.out.println("Drawing cached world image " + img.getWidth() + "x" + img.getHeight());
		this.cachedWorldImage = new MBFImage(img.getWidth(), img.getHeight(), 4);

		// Fill the image with the sea colour.
		// We'll draw the countries on top of this.
		this.drawSea(this.cachedWorldImage);

		// Make the image fit into the axes centred around 0,0 long/lat
		final Point2d mid = axesRenderer.calculatePosition(0, 0);
		final Point2d dateLine0 = axesRenderer.calculatePosition(180, 0);
		final Point2d northPole = axesRenderer.calculatePosition(0, -90);

		System.out.println("0,0 @ " + mid);
		System.out.println("dateLine: " + dateLine0);
		System.out.println("northpole: " + northPole);

		final double scaleX = (dateLine0.getX() - mid.getX()) / 180d;
		final double scaleY = (northPole.getY() - mid.getY()) / 90d;
		Matrix trans = Matrix.identity(3, 3);
		trans = trans.times(
				TransformUtilities.scaleMatrixAboutPoint(
						scaleX, -scaleY, mid
						)
				);

		// Translate to 0,0
		trans = trans.times(
				TransformUtilities.translateMatrix(mid.getX(), mid.getY())
				);

		// Now draw the countries onto the sea. We transform each of the
		// shapes
		// by the above transform matrix prior to plotting them to the
		// image.
		for (final WorldPlace wp : this.worldPolys.getShapes())
		{
			// Each place may have more than one polygon.
			final List<Shape> shapes = wp.getShapes();

			final MBFImageRenderer ir = this.cachedWorldImage.createRenderer(RenderHints.ANTI_ALIASED);

			// For each of the polygons... draw them to the image.
			for (Shape s : shapes)
			{
				s = s.transform(trans);

				// Fill the country with the land colour
				ir.drawShapeFilled(s, this.defaultCountryLandColour);

				// Draw the outline shape of the country
				ir.drawShape(s, 1, this.defaultCountryOutlineColour);
			}
		}
	}
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:61,
代码来源:WorldMap.java

示例17: beforeAxesRender

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.openimaj.vis.general.XYPlotVisualisation#beforeAxesRender(org.openimaj.image.MBFImage,
 *      org.openimaj.vis.general.AxesRenderer2D)
 */
@Override
synchronized public void beforeAxesRender(final MBFImage visImage,
		final AxesRenderer2D<Float[], MBFImage> axesRenderer)
{
	synchronized (axesRenderer)
	{
		// Redraw the world if the image dimensions aren't the same.
		if (this.cachedWorldImage == null ||
				visImage.getWidth() != this.cachedWorldImage.getWidth() ||
				visImage.getHeight() != this.cachedWorldImage.getHeight())
			this.drawCachedImage(visImage, axesRenderer);

		// Blat the cached image
		System.out.println("Blitting cached world image");
		visImage.drawImage(this.cachedWorldImage, 0, 0);

		// Make the image fit into the axes centred around 0,0 long/lat
		final Point2d mid = axesRenderer.calculatePosition(0, 0);
		final Point2d dateLine0 = axesRenderer.calculatePosition(180, 0);
		final Point2d northPole = axesRenderer.calculatePosition(0, -90);
		final double scaleX = (dateLine0.getX() - mid.getX()) / 180d;
		final double scaleY = (northPole.getY() - mid.getY()) / 90d;
		Matrix trans = Matrix.identity(3, 3);
		trans = trans.times(
				TransformUtilities.scaleMatrixAboutPoint(
						scaleX, -scaleY, mid
						)
				);

		// Translate to 0,0
		trans = trans.times(
				TransformUtilities.translateMatrix(mid.getX(), mid.getY())
				);

		// Now draw the countries onto the sea. We transform each of the
		// shapes
		// by the above transform matrix prior to plotting them to the
		// image.
		final HashSet<String> k = new HashSet<String>(this.activeCountries);
		for (final String countryCode : k)
		{
			final WorldPlace wp = this.worldPolys.byCountryCode(countryCode);

			// Each place may have more than one polygon.
			final List<Shape> shapes = wp.getShapes();

			final MBFImageRenderer ir = visImage.createRenderer(RenderHints.ANTI_ALIASED);

			// For each of the polygons... draw them to the image.
			for (Shape s : shapes)
			{
				s = s.transform(trans);

				// Draw the country in the highlight colour
				final Float[] col = this.countryHighlightColours.get(wp.getISOA2());
				ir.drawShapeFilled(s, col == null ? this.highlightCountryLandColour : col);

				// Draw the outline shape of the country
				ir.drawShape(s, 1, this.defaultCountryOutlineColour);
			}
		}
	}
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:70,
代码来源:WorldMap.java

示例18: plotObject

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
/**
	 *	{@inheritDoc}
	 * 	@see org.openimaj.vis.general.ItemPlotter#plotObject(org.openimaj.image.Image, org.openimaj.vis.general.XYPlotVisualisation.LocatedObject, org.openimaj.vis.general.AxesRenderer2D)
	 */
	@Override
	public void plotObject( final MBFImage visImage,
			final XYPlotVisualisation.LocatedObject<LabelledDot> object,
			final AxesRenderer2D<Float[],MBFImage> renderer )
	{
		// Get the position where we're going to place the dot
		Point2d pos = renderer.calculatePosition( object.x, object.y );

		final MBFImageRenderer ir = visImage.createRenderer( RenderHints.ANTI_ALIASED );

		// Draw the dot
		ir.drawShapeFilled(
				new Circle( pos,
					(float)(renderer.scaleDimensions( object.object.size, object.object.size )[0] ) ),
					object.object.colour );

		// Get the position where we're going the place the text
		pos = renderer.calculatePosition( object.x + object.object.size, object.y );

		// Create the font and font style
		final HersheyFont f = HersheyFont.TIMES_MEDIUM;
		final HersheyFontStyle<Float[]> fs = f.createStyle( visImage.createRenderer() );
		fs.setFontSize( 14 );

		// Calculate the bounding box of the text we're going to draw.
		final Rectangle b = fs.getRenderer( visImage.createRenderer() ).getSize(
				object.object.label, fs );

		// Bounding box is 0,0,width,height, so move it into position.
		b.translate( 0, b.height );
		b.translate( pos.getX() + 4, pos.getY() );
//		System.out.println( b );

		boolean overlap = false;
		for( final Rectangle bb : this.bounds ) {
			if( bb.isOverlapping( b ) ) {
				overlap = true; break;
			}
		}

		this.bounds.add( b );

		if( !overlap )
			ir.drawText(
					object.object.label, (int)b.x, (int)b.y + (int)b.height,
					f, 14, object.object.colour );

	}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:53,
代码来源:LabelledPointVisualisation.java

示例19: createRenderer

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public ImageRenderer<Float[], SVGImage> createRenderer(RenderHints options) {
	return this.renderer;
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:5,
代码来源:SVGImage.java

示例20: createRenderer

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public FImageRenderer createRenderer(final RenderHints options) {
	return new FImageRenderer(this, options);
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:5,
代码来源:FImage.java

示例21: createRenderer

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public MBFImageRenderer createRenderer(final RenderHints options) {
	return new MBFImageRenderer(this, options);
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:5,
代码来源:MBFImage.java

示例22: getComponent

点赞 2

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 50, ColourSpace.RGB);
	renderer = image.createRenderer(RenderHints.FAST);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.addMouseListener(this);
	ic.addMouseMotionListener(this);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	clearBtn = new JButton("Clear");
	clearBtn.setActionCommand("button.clear");
	clearBtn.addActionListener(this);
	controls.add(clearBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("K:"));

	kSpn = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
	controls.add(kSpn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run KMeans");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 

开发者ID:jonhare,
项目名称:COMP3204,
代码行数:58,
代码来源:KMeansDemo.java

示例23: createRenderer

点赞 1

import org.openimaj.image.renderer.RenderHints; //导入依赖的package包/类
/**
 * Create a {@link ImageRenderer} capable of drawing into this image.
 *
 * @param options
 *            Options for the renderer
 * @return the renderer
 */
public abstract ImageRenderer<Q, I> createRenderer(RenderHints options);
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:9,
代码来源:Image.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)