本文整理汇总了Java中org.openimaj.image.MBFImage.clone方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.clone方法的具体用法?Java MBFImage.clone怎么用?Java MBFImage.clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.MBFImage
的用法示例。
在下文中一共展示了MBFImage.clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructDepthFrame
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private IndependentPair<FImage, MBFImage> constructDepthFrame() {
FImage compiledDepth = null;
MBFImage compiledRGB = null;
for (IndependentPair<FImage, MBFImage> heldFrame : this.heldDepthFrames) {
FImage heldDepth = heldFrame.firstObject();
MBFImage heldRGB = heldFrame.secondObject();
if(compiledDepth == null){
compiledDepth = heldDepth.clone();
compiledRGB = heldRGB .clone();
continue;
}
for (int y = 0; y < heldDepth.height; y++) {
for (int x = 0; x < heldDepth.width; x++) {
if (compiledDepth.pixels[y][x] == 0 || (heldDepth.pixels[y][x] != 0 && compiledDepth.pixels[y][x] > heldDepth.pixels[y][x])) {
compiledDepth.pixels[y][x] = heldDepth.pixels[y][x];
compiledRGB.setPixel(x, y, heldRGB.getPixel(x, y));
}
}
}
}
return IndependentPair.pair(compiledDepth, compiledRGB);
}
示例2: projectHS
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Transform the Hue and Saturation components of a MBFImage by projecting
* them from a radial coordinate system to Cartesian coordinates. Assumes
* the Hue is the first band and Saturation is the second band. Any
* additional bands will be cloned to the result image.
*
* @param in
* input image
* @return Multi-band image with coupled first and second bands calculated
* by projecting from radial to Cartesian coordinates.
*/
public static MBFImage projectHS(final MBFImage in) {
if (in.colourSpace != ColourSpace.HS && in.colourSpace != ColourSpace.HSI &&
in.colourSpace != ColourSpace.HSV && in.colourSpace != ColourSpace.HSY)
throw new IllegalArgumentException("HS* colourspace is required");
final MBFImage out = in.clone();
final float[][] h = in.getBand(0).pixels;
final float[][] s = in.getBand(1).pixels;
final float[][] o1 = out.getBand(0).pixels;
final float[][] o2 = out.getBand(1).pixels;
for (int r = 0; r < in.getHeight(); r++) {
for (int c = 0; c < in.getWidth(); c++) {
o1[r][c] = (float) (s[r][c] * Math.cos(2.0 * Math.PI * h[r][c]));
o2[r][c] = (float) (s[r][c] * Math.sin(2.0 * Math.PI * h[r][c]));
}
}
out.colourSpace = ColourSpace.CUSTOM;
return out;
}
示例3: beforeUpdate
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
panLabel.setText(String.format("Pan = %04d", pan.getPW()));
tiltLabel.setText(String.format("Tilt = %04d", tilt.getPW()));
final MBFImage outframe = frame.clone();
if (doFaces) {
processFaces(frame, outframe);
}
if (doCounting) {
processCount(frame, outframe);
}
frame.internalAssign(outframe);
}
示例4: beforeUpdate
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
synchronized (this) {
if (frame == null)
currentFrame = null;
else
currentFrame = frame.clone();
}
}
示例5: addMustaches
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Detect faces in the image and render mustaches.
*
* @param image
* @return image with rendered mustaches
*/
public MBFImage addMustaches(MBFImage image) {
MBFImage cimg;
if (image.getWidth() > image.getHeight() && image.getWidth() > 640) {
cimg = image.process(new ResizeProcessor(640, 480));
} else if (image.getHeight() > image.getWidth() && image.getHeight() > 640) {
cimg = image.process(new ResizeProcessor(480, 640));
} else {
cimg = image.clone();
}
final FImage img = Transforms.calculateIntensityNTSC(cimg);
final List<KEDetectedFace> faces = detector.detectFaces(img);
final MBFImageRenderer renderer = cimg.createRenderer();
for (final KEDetectedFace face : faces) {
final Matrix tf = AffineAligner.estimateAffineTransform(face);
final Shape bounds = face.getBounds();
final MBFImage m = mustache.transform(tf.times(TransformUtilities.scaleMatrix(1f / 4f, 1f / 4f)));
renderer.drawImage(m, (int) bounds.minX(), (int) bounds.minY());
}
return cimg;
}
示例6: 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);
}
示例7: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Main method
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// Load the image
final MBFImage image = ImageUtilities.readMBF(new URL("http://static.openimaj.org/media/tutorial/sinaface.jpg"));
// Print colour space
System.out.println(image.colourSpace);
// Display the image
DisplayUtilities.display(image);
DisplayUtilities.display(image.getBand(0), "Red Channel");
// Set blue and green pixels to black, and draw
final MBFImage clone = image.clone();
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
clone.getBand(1).pixels[y][x] = 0;
clone.getBand(2).pixels[y][x] = 0;
}
}
DisplayUtilities.display(clone);
// Find edges
image.processInplace(new CannyEdgeDetector());
DisplayUtilities.display(image);
// Draw some stuff
image.drawShapeFilled(new Ellipse(700f, 450f, 20f, 10f, 0f), RGBColour.WHITE);
image.drawShapeFilled(new Ellipse(650f, 425f, 25f, 12f, 0f), RGBColour.WHITE);
image.drawShapeFilled(new Ellipse(600f, 380f, 30f, 15f, 0f), RGBColour.WHITE);
image.drawShapeFilled(new Ellipse(500f, 300f, 100f, 70f, 0f), RGBColour.WHITE);
image.drawText("OpenIMAJ is", 425, 300, HersheyFont.ASTROLOGY, 20, RGBColour.BLACK);
image.drawText("Awesome", 425, 330, HersheyFont.ASTROLOGY, 20, RGBColour.BLACK);
DisplayUtilities.display(image);
}
示例8: updateVis
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Update the visualisation using the given image as the base image
* on which to overlay.
* @param overlay The overlay
*/
public void updateVis( final MBFImage overlay )
{
if( overlay != null )
this.overlayImage = overlay.clone();
else this.overlayImage = null;
this.updateVis();
}
示例9: capturePImage
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Given an initialised video capture, capture a {@link PImage}
* @param setToCurrentFrame whether the current openimaj frame (for analysis) should be set from capture
* @return capture
*/
public PImage capturePImage(boolean setToCurrentFrame){
MBFImage frame = this.capture.getNextFrame();
if(setToCurrentFrame){
this.oiImage = frame.clone();
}
return asPImage(frame);
}
示例10: capture
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public MBFImage capture(boolean setToCurrentFrame){
MBFImage frame = this.capture.getNextFrame();
if(setToCurrentFrame){
this.oiImage = frame.clone();
}
return frame;
}
示例11: RGB_TO_HSL
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Transform 3 band RGB image to HSL
*
* @param in
* RGB or RGBA image
* @return HSL image
*/
public static MBFImage RGB_TO_HSL(final MBFImage in) {
if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
throw new IllegalArgumentException("RGB or RGBA colourspace is required");
final MBFImage out = in.clone();
final float[] pix = new float[in.numBands()];
for (int y = 0; y < in.getHeight(); y++) {
for (int x = 0; x < in.getWidth(); x++) {
for (int b = 0; b < in.numBands(); b++)
pix[b] = in.getBand(b).pixels[y][x];
Transforms.RGB_TO_HSL(pix, pix);
for (int b = 0; b < in.numBands(); b++)
out.getBand(b).pixels[y][x] = pix[b];
}
}
// final MBFImage out = Transforms.RGB_TO_HSV(in);
//
// final FImage R = in.getBand(0);
// final FImage G = in.getBand(1);
// final FImage B = in.getBand(2);
//
// final FImage L = out.getBand(2);
// for (int y = 0; y < L.height; y++) {
// for (int x = 0; x < L.width; x++) {
// final float max = Math.max(Math.max(R.pixels[y][x], G.pixels[y][x]),
// B.pixels[y][x]);
// final float min = Math.min(Math.min(R.pixels[y][x], G.pixels[y][x]),
// B.pixels[y][x]);
// L.pixels[y][x] = 0.5f * (max - min);
// }
// }
out.colourSpace = ColourSpace.HSL;
return out;
}
示例12: addToCache
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void addToCache(MBFImage frame) {
final MBFImage f = frame.clone();
final float[][][] entry = new float[3][][];
entry[0] = f.getBand(0).pixels;
entry[1] = f.getBand(1).pixels;
entry[2] = f.getBand(2).pixels;
cache.addFirst(entry);
}
示例13: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main( String[] args ) {
// compare collections
try {
System.out.println("*********************************************");
System.out.println(" FIND FINGERS ON SCANS ");
System.out.println("*********************************************\n");
long initTime = System.currentTimeMillis();
//String pathLeft = "samplesV2"; // 15 samples collection
//String pathLeft = "fingers2Db"; // 26 additional samples collection
//String pathLeft = "fingersDbOrigin"; // 160 samples collection
String pathLeft = "Z151694702jpg730"; // finger free test collection
File[] listOfFilesLeft = listFilesInDirectory(pathLeft);
int fingerImageCount = 0;
for( int i = 0; i < listOfFilesLeft.length; i++ ) {
System.out.println("query collection image i: " + i);
if (i < listOfFilesLeft.length) {
String fileNameLeft = pathLeft + "\\" + listOfFilesLeft[i].getName();
MBFImage query = ImageUtilities.readMBF(new File(fileNameLeft));
ResizeProcessor resize = new ResizeProcessor(400, 200);
query.processInline(resize);
MBFImage clone = query.clone ();
query.processInline(new CannyEdgeDetector2());
FImage res = query.flatten();
// Extract gray scale image with edge detection
// DisplayUtilities.display(res);
analyse(res);
if (resFingerList.size() > 0) {
System.out.println(resFingerList.size() + " finger in current scan detected!\n");
fingerImageCount++;
Iterator<Finger> itr = resFingerList.iterator();
while (itr.hasNext()) {
Finger finger = itr.next();
finger.evalBounds(res);
// System.out.println("minX: " + finger.getMinX() + ", minY: " + finger.getMinY() +
// ", maxX: " + finger.getMaxX() + ", maxY: " + finger.getMaxY());
int offsetX = 0;
int offsetY = 0;
if (finger.getMinX() == finger.getMaxX()) {
offsetX = 10;
}
if (finger.getMinY() == finger.getMaxY()) {
offsetY = 10;
}
// draw green rectangle around the detected finger area
clone.drawShape(new Rectangle (finger.getMinX(), finger.getMinY(),
offsetX + finger.getMaxX() - finger.getMinX(),
offsetY + finger.getMaxY() - finger.getMinY()), 4, RGBColour.GREEN);
// clone.drawShape(new Rectangle (finger.getMinX(), finger.getMinY(),
// offsetX + finger.getMaxX() - finger.getMinX(),
// offsetY + finger.getMaxY() - finger.getMinY()), RGBColour.GREEN);
} // end while
// display image with green rectangles
DisplayUtilities.display(res); //tmp
DisplayUtilities.display(clone);
} // end if finger list size
resFingerList.clear();
fingerList.clear();
// display resulting edges after analysis
// DisplayUtilities.display(res);
} // offset if i
} // for i
long endTime = System.currentTimeMillis();
long resTime = endTime - initTime;
System.out.println("calculation time: " + resTime);
System.out.println("finger list size: " + fingerImageCount +
" of total " + listOfFilesLeft.length + " files\n");
System.out.println("**********************************************\n\n");
} catch (Exception e) {
System.out.println("error: " + e);
}
}
示例14: snapshot
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void snapshot() {
MBFImage[] images = new MBFImage[captureComponents.size()];
for (CaptureComponent cc : captureComponents) {
int id = Integer.parseInt(cc.getTitle().substring(cc.getTitle().indexOf("#")+1)) - 1;
MBFImage f = cc.getCurrentFrame();
if( f != null )
images[id] = f.clone();
}
// Write all the images
for (int i=0; i<images.length; i++) {
try {
if( images[i] != null )
{
System.out.println( "Writing image "+captureCount+"-"+i );
File captureDir = new File(this.imageDir, ""+captureCount);
captureDir.mkdirs();
ImageUtilities.write(images[i], new File(captureDir, i+".png"));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// Get some data together
ArrayList<String> dataList = new ArrayList<String>();
dataList.add( ""+captureCount );
dataList.add( ""+gpsComp.getGPS().getLatitude() );
dataList.add( ""+gpsComp.getGPS().getLongitude() );
dataList.add( ""+new DateTime() );
CompassData c = compassComp.getCompass().getCompassData();
if( c != null )
{
dataList.add( ""+c.compass );
dataList.add( ""+c.pitch );
dataList.add( ""+c.roll );
dataList.add( ""+c.ax );
dataList.add( ""+c.ay );
dataList.add( ""+c.az );
}
else
{
dataList.add( "" );
dataList.add( "" );
dataList.add( "" );
dataList.add( "" );
dataList.add( "" );
dataList.add( "" );
}
dataList.add( "Notes" );
// Write the data
System.out.println( "Writing CSV File: "+this.imageMetadata );
CSVWriter.writeLine( this.imageMetadata, dataList.toArray( new String[0] ) );
captureCount++;
}
示例15: addToCache
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void addToCache( final MBFImage frame )
{
final MBFImage f = frame.clone();
this.cache.addFirst( f );
}