本文整理汇总了Java中org.openimaj.image.MBFImage.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.drawImage方法的具体用法?Java MBFImage.drawImage怎么用?Java MBFImage.drawImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.MBFImage
的用法示例。
在下文中一共展示了MBFImage.drawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTutorial
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void doTutorial(MBFImage image) {
HistogramModel model = new HistogramModel(10,4,1);
MBFImage space = Transforms.RGB_TO_HSV(image);
model.estimateModel(space);
MultidimensionalHistogram feature = model.histogram;
Float[][] colours = buildBinCols(feature);
MBFImage colourGrid = new MBFImage(80,image.getHeight(),3);
int sqW = (colourGrid.getWidth()/4);
int sqH = (colourGrid.getHeight()/10);
for(int y = 0; y < 4; y++){
for(int k = 0; k < 10; k++){
Rectangle draw = new Rectangle(y * sqW,sqH*k,sqW,sqH);
colourGrid.drawShapeFilled(draw, colours[y * 10 + k]);
}
}
// DisplayUtilities.displayName(colourGrid, "wang");
image.drawImage(colourGrid, image.getWidth()-colourGrid.getWidth(), 0);
}
示例2: consumeFrequency
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void consumeFrequency(final float[] fftReal, final float[] fftImag,final int low,final int high) {
final int blockWidth = 10;
final int blockHeight = 5;
if( this.spectra == null || this.spectra.getHeight() != (high-low) * blockHeight )
{
this.spectra = new FImage( this.mbfImage.getWidth(), (high-low)*blockHeight);
}
this.spectra.shiftLeftInplace(blockWidth);
// Draw the spectra
for( int i = low; i < high; i++ )
{
final float re = fftReal[i];
final float im = fftImag[i];
float mag = (float)Math.log(Math.sqrt( re*re + im*im )+1)/5;
if( mag > 1 ) mag = 1;
this.spectra.drawShapeFilled(new Rectangle(this.spectra.getWidth()-blockWidth, this.spectra.getHeight()-(i * blockHeight), blockWidth,blockHeight), mag );
}
final MBFImage toDraw = this.mbfImage.clone();
toDraw.drawImage(new MBFImage(this.spectra,this.spectra,this.spectra), (this.mbfImage.getWidth() - this.spectra.width)/2, this.mbfImage.getHeight() - this.spectra.height);
this.ic.setImage(this.buf = ImageUtilities.createBufferedImageForDisplay( toDraw, this.buf ));
}
示例3: redrawCircles
import org.openimaj.image.MBFImage; //导入方法依赖的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());
}
}
示例4: main
import org.openimaj.image.MBFImage; //导入方法依赖的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 );
}
示例5: drawCentroids
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
MBFImage drawCentroids(double[][] centroids) {
final int wh = (int) Math.sqrt(numCentroids);
final MBFImage tmp = new MBFImage(wh * (patchSize + 1) + 1, wh * (patchSize + 1) + 1);
final float mn = -1.0f;
final float mx = +1.0f;
tmp.fill(new Float[] { mx, mx, mx });
for (int i = 0, y = 0; y < wh; y++) {
for (int x = 0; x < wh; x++, i++) {
final MBFImage p = new MBFImage(centroids[i], patchSize, patchSize, 3, false);
tmp.drawImage(p, x * (patchSize + 1) + 1, y * (patchSize + 1) + 1);
}
}
tmp.subtractInplace(mn);
tmp.divideInplace(mx - mn);
return tmp;
}
示例6: plotObject
import org.openimaj.image.MBFImage; //导入方法依赖的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 org.openimaj.vis.general.XYPlotVisualisation.LocatedObject<TimelineObject> object,
final AxesRenderer2D<Float[], MBFImage> renderer )
{
// Work out where we're going to plot this timeline object.
final Point2d p = renderer.calculatePosition( object.x, object.y );
// Reset its size, if we need to then update the visualisation
object.object.setRequiredSize( new Dimension(
object.object.getRequiredSize().width, this.bandSize ) );
object.object.updateVis();
// Now get the image and draw it in the correct place.
final MBFImage i = object.object.getVisualisationImage();
if( i != null )
visImage.drawImage( i, (int)p.getX(), (int)p.getY() );
}
示例7: beforeUpdate
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(final MBFImage frame) {
if (!this.videoFrame.isPaused())
this.currentFrame = frame.clone();
else {
frame.drawImage(currentFrame, 0, 0);
}
this.polygonListener.drawPoints(frame);
}
示例8: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Main method
*
* @param args
* ignored
* @throws IOException
* if image can't be loaded
*/
public static void main(final String[] args) throws IOException
{
final URL imgurl = new URL("http://www.sableandhogg-gallery.co.uk/shop/images/autumn%20landscape,%20beacons.jpg");
// ------------------------------------------------------------------
// FImage test
// ------------------------------------------------------------------
final FImage fi1 = ImageUtilities.readF(imgurl);
final FImage fi2 = new FImage(300, 100);
fi2.drawText("HELLO", 0, 35, new GeneralFont("Arial", Font.BOLD), 48);
final FImage alpha = fi2.clone().multiplyInplace(0.5f);
fi1.overlayInplace(fi2, alpha, 200, 200);
DisplayUtilities.display(fi1, "Composite");
// ------------------------------------------------------------------
// MBFImage test
// ------------------------------------------------------------------
final MBFImage i1 = ImageUtilities.readMBF(imgurl);
final MBFImage i2 = new MBFImage(300, 100, 3);
i2.drawText("HELLO", 0, 35, new GeneralFont("Arial", Font.BOLD), 48);
i2.addBand(alpha);
i1.overlayInplace(i2, 200, 200);
DisplayUtilities.display(i1, "Multiband Composite");
final MBFImage i1b = ImageUtilities.readMBF(imgurl);
i1b.drawImage(i2, 200, 200);
DisplayUtilities.display(i1b, "Multiband Composite");
}
示例9: beforeUpdate
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
// Rectangle extractionArea = new
// Rectangle(100,100,IMAGE_WIDTH-200,IMAGE_HEIGHT-200);
if (this.mode == DebugMode.DEBUG_DISPLAY)
return;
final FImage grey = frame.extractROI(extractionArea).flatten();
if (!this.backgroundLearner.ready()) {
grey.process(this.backgroundLearner);
frame.fill(RGBColour.BLACK);
frame.drawImage(new MBFImage(grey, grey, grey), (int) extractionArea.x, (int) extractionArea.y);
return;
}
grey.addInplace(this.backgroundLearner.getBackground());
grey.threshold(0.07f);
// grey.processInplace(new OtsuThreshold());
// if(grey.sum() > BIGGEST_POINT_AREA * 2 ){
// this.backgroundLearner.relearn();
// return;
// }
// List<Circle> filtered = getFilteredCircles(grey);
final List<Touch> filtered = getFilteredTouchesFast(grey);
if (filtered.size() != 0)
this.fireTouchEvent(filtered);
frame.fill(RGBColour.BLACK);
frame.drawImage(new MBFImage(grey, grey, grey), (int) extractionArea.x, (int) extractionArea.y);
}
示例10: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws MalformedURLException, IOException {
// Load the image
FImage img = ImageUtilities.readF(new URL("file:///Users/ss/Desktop/Barack-Obama-02.jpg"));
img.processInplace(new ResizeProcessor(640, 480));
MBFImage mbfAll = new MBFImage(img.width*3, img.height, ColourSpace.RGB);
MBFImage mbf;
// A simple Haar-Cascade face detector
HaarCascadeDetector det1 = new HaarCascadeDetector();
DetectedFace face1 = det1.detectFaces(img).get(0);
mbf = MBFImage.createRGB(img);
new SimpleDetectedFaceRenderer().drawDetectedFace(mbf,10,face1);
mbfAll.drawImage(mbf, 0, 0);
// Get the facial keypoints
FKEFaceDetector det2 = new FKEFaceDetector();
KEDetectedFace face2 = det2.detectFaces(img).get(0);
mbf = MBFImage.createRGB(img);
new KEDetectedFaceRenderer().drawDetectedFace(mbf,10,face2);
mbfAll.drawImage(mbf, img.width, 0);
// With the CLM Face Model
CLMFaceDetector det3 = new CLMFaceDetector();
CLMDetectedFace face3 = det3.detectFaces(img).get(0);
mbf = MBFImage.createRGB(img);
new CLMDetectedFaceRenderer().drawDetectedFace(mbf,10,face3);
mbfAll.drawImage(mbf, img.width*2, 0);
mbfAll.processInplace(new ResizeProcessor(320,240));
DisplayUtilities.display(mbfAll);
ImageUtilities.write(mbfAll, new File("/Users/ss/Desktop/barack-detected.png"));
}
示例11: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
System.out.println("start");
final RandomPatchSampler<MBFImage> sampler = new RandomPatchSampler<MBFImage>(
CIFAR10Dataset.getTrainingImages(CIFAR10Dataset.MBFIMAGE_READER),
8, 8, 400000);
final List<MBFImage> patches = sampler.getPatches();
System.out.println("stop");
final double[][] data = new double[patches.size()][];
for (int i = 0; i < data.length; i++)
data[i] = patches.get(i).getDoublePixelVector();
// final PCAWhitening whitening = new PCAWhitening();
final ZCAWhitening whitening = new ZCAWhitening(0.1, new PerExampleMeanCenter());
whitening.train(data);
final double[][] wd = whitening.whiten(data);
final SphericalKMeans skm = new SphericalKMeans(1600, 10);
final SphericalKMeansResult res = skm.cluster(wd);
final MBFImage tmp = new MBFImage(40 * (8 + 1) + 1, 40 * (8 + 1) + 1);
tmp.fill(RGBColour.WHITE);
for (int i = 0; i < 40; i++) {
for (int j = 0; j < 40; j++) {
final MBFImage patch = new MBFImage(res.centroids[i * 40 + j], 8, 8, 3, false);
tmp.drawImage(patch, i * (8 + 1) + 1, j * (8 + 1) + 1);
}
}
tmp.subtractInplace(-1.5f);
tmp.divideInplace(3f);
DisplayUtilities.display(tmp);
}
示例12: setup
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void setup(Image<?, ?> image1, Image<?, ?> image2,
List<Ellipse> image1Points, List<Ellipse> image2Points,
Matrix homography)
{
this.homography = homography;
this.validImage2Points = IPDRepeatability.validPoints(image2Points,
image1, homography);
this.validImage1Points = IPDRepeatability.validPoints(image1Points,
image2, homography.inverse());
this.imageWidth = image1.getWidth();
this.imageHeight = image1.getHeight();
if (logger.getLevel() == Level.DEBUG) {
final MBFImage combined = new MBFImage(image1.getWidth()
+ image2.getWidth(), Math.max(image1.getHeight(),
image2.getHeight()), ColourSpace.RGB);
final InterestPointVisualiser<Float[], MBFImage> ipdv1 = new InterestPointVisualiser<Float[], MBFImage>(
(MBFImage) image1, this.validImage1Points);
combined.drawImage(
ipdv1.drawPatches(RGBColour.RED, RGBColour.BLUE), 0, 0);
final InterestPointVisualiser<Float[], MBFImage> ipdv2 = new InterestPointVisualiser<Float[], MBFImage>(
(MBFImage) image2, this.validImage2Points);
combined.drawImage(
ipdv2.drawPatches(RGBColour.RED, RGBColour.BLUE),
image1.getWidth(), 0);
// DisplayUtilities.displayName(combined, "valid points");
}
}
示例13: drawToImage
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void drawToImage(MBFImage image) {
final MBFImage gFrame = getNextFrame();
image.drawImage(gFrame, 0, 0);
}
示例14: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final FlickrAPIToken token = DefaultTokenFactory.getInstance().getToken(FlickrAPIToken.class);
final int numImages = 20;
final FlickrImageDataset<MBFImage> dataset = FlickrImageDataset.create(ImageUtilities.MBFIMAGE_READER, token,
"colorful", numImages);
dataset.getPhotos().set(1, dataset.getPhoto(0));
final DoubleFV[] features = new DoubleFV[numImages];
for (int i = 0; i < numImages; i++) {
features[i] = extractFeature(dataset.get(i));
}
final SimilarityMatrix matrix = new SimilarityMatrix(numImages);
for (int i = 0; i < numImages; i++) {
matrix.setIndexValue(i, dataset.getID(i));
final DoubleFV fi = features[i];
for (int j = 0; j < numImages; j++) {
final DoubleFV fj = features[j];
matrix.set(i, j, fi.compare(fj, DoubleFVComparison.COSINE_SIM));
}
}
System.out.println(matrix);
final MultidimensionalScaling mds = new MultidimensionalScaling();
mds.process(matrix);
System.out.println(mds.getPoints());
final MBFImage img = new MBFImage(1000, 1000, ColourSpace.RGB);
for (final IndependentPair<String, Point2d> pt : mds.getPoints()) {
// img.drawPoint(pt.getSecondObject(), RGBColour.RED, 3);
final int idx = dataset.indexOfID(pt.firstObject());
final MBFImage thumb = ImageUtilities.readMBF(new URL(dataset.getPhoto(idx).getThumbnailUrl()));
img.drawImage(thumb, pt.getSecondObject().transform(TransformUtilities.scaleMatrix(1000, 1000)));
}
DisplayUtilities.display(img);
}
示例15: beforeAxesRender
import org.openimaj.image.MBFImage; //导入方法依赖的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);
}
}
}
}