当前位置: 首页>>代码示例>>Java>>正文


Java MBFImage类代码示例

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


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

示例1: run

import org.openimaj.image.MBFImage; //导入依赖的package包/类
@Override
public void run() {
    final FImage fImage = ImageUtilities.createFImage(buffImg);
    final List<KEDetectedFace> faces = DETECTOR.detectFaces(fImage);
    if(!faces.isEmpty()){
        CameraManager.INSTANCE.addFaces(faces.size());
        final MBFImage mbf = ImageUtilities.createMBFImage(buffImg, true);
        LOG.info("Found {} faces at {}", faces.size(), when);
        faces.stream().forEach(f -> KERenderer.drawDetectedFace(mbf, 5, f));
        final String filename = Formats.toTaken(when) + ".jpeg";
        final Path outPath = ImagesEndpoint.getIMAGES_ROOT().resolve(filename);
        try(OutputStream out = Files.newOutputStream(outPath)){
            ImageUtilities.write(mbf, "JPG", out);
        } catch (IOException ex) {
            LOG.warn("Error scanning for faces", ex);
        }
    }
}
 
开发者ID:erikcostlow,项目名称:PiCameraProject,代码行数:19,代码来源:FaceScanTask.java

示例2: main

import org.openimaj.image.MBFImage; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	final RandomPatchSampler<MBFImage> ps = new RandomPatchSampler<MBFImage>(
			Caltech101.getImages(ImageUtilities.MBFIMAGE_READER), 28, 28, 70000);

	final File TRAINING = new File("/Users/jon/Data/caltech101-patches/training/");
	final File TESTING = new File("/Users/jon/Data/caltech101-patches/testing/");

	TRAINING.mkdirs();
	TESTING.mkdirs();

	int i = 0;
	for (final MBFImage patch : ps) {
		System.out.println(i);
		if (i < 60000) {
			ImageUtilities.write(patch, new File(TRAINING, i + ".png"));
		} else {
			ImageUtilities.write(patch, new File(TESTING, (i - 60000) + ".png"));
		}
		i++;
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:RandomPatchSampler.java

示例3: imageToVector

import org.openimaj.image.MBFImage; //导入依赖的package包/类
@Override
protected float[][] imageToVector(MBFImage image) {
	final int height = image.getHeight();
	final int width = image.getWidth();
	final int bands = image.numBands();

	final float[][] f = new float[height * width][bands + 2];
	for (int b = 0; b < bands; b++) {
		final float[][] band = image.getBand(b).pixels;
		final float w = scaling == null ? 1 : scaling[b];

		for (int y = 0; y < height; y++)
			for (int x = 0; x < width; x++)
				f[x + y * width][b] = band[y][x] * w;
	}
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			f[x + y * width][bands] = ((float) x / (float) width) * (scaling == null ? 1 : scaling[bands]);
			f[x + y * width][bands + 1] = ((float) y / (float) height) * (scaling == null ? 1 : scaling[bands + 1]);
		}
	}

	return f;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:KMSpatialColourSegmenter.java

示例4: calculateIntensityNTSC

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * Calculate intensity by a weighted average of the R, G, B planes. Assumes
 * planes are all in the same magnitude, and NTSC weighting coefficients.
 * 
 * @param in
 *            MBFImage with 3 bands
 * @return intensity image
 */
public static FImage calculateIntensityNTSC(final MBFImage in) {
	if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
		throw new UnsupportedOperationException("Can only convert RGB or RGBA images");

	final FImage out = new FImage(in.getWidth(), in.getHeight());

	for (int r = 0; r < in.getHeight(); r++) {
		for (int c = 0; c < in.getWidth(); c++) {
			out.pixels[r][c] = (0.299f * in.getBand(0).pixels[r][c] +
					0.587f * in.getBand(1).pixels[r][c] +
					0.114f * in.getBand(2).pixels[r][c]);
		}
	}

	return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:Transforms.java

示例5: calculateSaturation

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * Calculate Saturation image from a 3-band RGB MBFImage
 * 
 * @param in
 *            RGB or RGBA image
 * @return Saturation image
 */
public static FImage calculateSaturation(final MBFImage in) {
	if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
		throw new IllegalArgumentException("RGB or RGBA colourspace is required");

	final FImage out = new FImage(in.getWidth(), in.getHeight());

	final float[][] ra = in.getBand(0).pixels;
	final float[][] ga = in.getBand(1).pixels;
	final float[][] ba = in.getBand(2).pixels;

	for (int rr = 0; rr < in.getHeight(); rr++) {
		for (int c = 0; c < in.getWidth(); c++) {
			final double r = ra[rr][c];
			final double g = ga[rr][c];
			final double b = ba[rr][c];

			out.pixels[rr][c] = (float) (1.0 - ((3.0 / (r + g + b)) * Math.min(r, Math.min(g, b))));
			if (Float.isNaN(out.pixels[rr][c]))
				out.pixels[rr][c] = 0;
		}
	}

	return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:32,代码来源:Transforms.java

示例6: getNextFrame

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @see org.openimaj.video.Video#getNextFrame()
 */
@Override
public MBFImage getNextFrame() {
	if (this.nextFrame != null) {
		// We've already read the next frame, so we simply move on.
		this.currentMBFImage = this.nextFrame;
		this.timestamp = this.nextFrameTimestamp;
		this.currentFrameIsKeyFrame = this.nextFrameIsKeyFrame;
		this.nextFrame = null;
	} else {
		// Read a frame from the stream.
		this.currentMBFImage = this.readFrame(false);
	}

	if (this.currentMBFImage != null) {
		// Increment frame counter
		this.currentFrame++;
	}

	return this.currentMBFImage;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:XuggleVideo.java

示例7: ByteArrayInputStream

import org.openimaj.image.MBFImage; //导入依赖的package包/类
@Override
protected void
		map(Text key, BytesWritable value, Mapper<Text, BytesWritable, Text, BytesWritable>.Context context)
				throws InterruptedException
{
	try {
		final MBFImage img = ImageUtilities.readMBF(new ByteArrayInputStream(value.getBytes()));
		final FeatureVector fv = options.featureOp.extract(img);

		final ByteArrayOutputStream baos = new ByteArrayOutputStream();
		if (options.binary)
			IOUtils.writeBinary(baos, fv);
		else
			IOUtils.writeASCII(baos, fv);

		context.write(key, new BytesWritable(baos.toByteArray()));
	} catch (final Exception e) {
		logger.warn("Problem processing image " + key + " (" + e + ")");
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:HadoopGlobalFeaturesTool.java

示例8: calculateIntensity

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * Calculate Intensity image from an RGB or RGBA MBFImage with given
 * weightings for R, G and B
 * 
 * @param in
 *            input image
 * @param wR
 *            red weight
 * @param wG
 *            green weight
 * @param wB
 *            blue weight
 * @return Intensity image
 */
public static FImage calculateIntensity(final MBFImage in, final float wR, final float wG, final float wB) {
	if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
		throw new UnsupportedOperationException("Can only convert RGB or RGBA images");

	final FImage out = new FImage(in.getWidth(), in.getHeight());

	final float[][] ra = in.getBand(0).pixels;
	final float[][] ga = in.getBand(1).pixels;
	final float[][] ba = in.getBand(2).pixels;

	for (int rr = 0; rr < in.getHeight(); rr++) {
		for (int c = 0; c < in.getWidth(); c++) {
			final double r = ra[rr][c];
			final double g = ga[rr][c];
			final double b = ba[rr][c];

			out.pixels[rr][c] = (float) (wR * r + wG * g + wB * b);
			if (Float.isNaN(out.pixels[rr][c]))
				out.pixels[rr][c] = 0;
		}
	}

	return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:39,代码来源:Transforms.java

示例9: 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 );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:AlphaCompositeTest.java

示例10: crop

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * Returns an image containing just the connected component cropped from the
 * original image. Although that the result image is necessarily
 * rectangular, the pixels which are not part of the connected component
 * will be transparent.
 * 
 * @param input
 *            The input image from which to take the pixels
 * @param blackout
 *            Whether to blackout pixels that are not part of the region or
 *            whether to mark them as transparent
 * @return An image with the component's pixels cropped
 */
public MBFImage crop(MBFImage input, boolean blackout) {
	final Rectangle bb = this.calculateRegularBoundingBox();

	final MBFImage output = new MBFImage((int) bb.width, (int) bb.height, input.numBands());

	for (int y = 0; y < (int) bb.height; y++) {
		for (int x = 0; x < (int) bb.width; x++) {
			for (int b = 0; b < input.numBands(); b++) {
				if (!blackout || this.pixels.contains(new Pixel(x + (int) bb.x, y + (int) bb.y)))
					output.getBand(b).setPixel(x, y, input.getBand(b).getPixel(x + (int) bb.x, y + (int) bb.y));
				else
					output.getBand(b).setPixel(x, y, 0f);
			}
		}
	}

	return output;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:32,代码来源:PixelSet.java

示例11: useFile

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * 	Set the processing source to be the file
 *  @param f
 */
public void useFile( final File f )
{
	// Stop any existing video
	this.stopVideo();

	// Setup a new video from the video file
	this.video = new XuggleVideo( f , false);

	// Reset the video displayer to use the file video
	this.videoDisplay = new VideoDisplay<MBFImage>( this.video, this.ic );
	this.videoDisplay.setEndAction( EndAction.LOOP );

	// Make sure all the listeners are added to this new display
	this.addListeners();
	this.addVideoFileListeners();

	// Start the new video playback thread
	this.videoThread = new Thread(this.videoDisplay);
	this.videoThread.start();
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:VideoProcessingDemo.java

示例12: buildBinCols

import org.openimaj.image.MBFImage; //导入依赖的package包/类
Float[][] buildBinCols(MultidimensionalHistogram feature) {
		Float[][] binCols = new Float[10*4*1][];
		double maxFeature = feature.max();
		if(maxFeature == 0) maxFeature = 1;
		for (int k=0; k<10; k++) {
			for (int j=0; j<4; j++) {
				float s = (float)j/4 + (0.5f/4);
				float h = (float)k/10 + (0.5f/10);
				
				MBFImage img = new MBFImage(1,1,ColourSpace.HSV);
				img.setPixel(0, 0, new Float[] {h,s,(float) (feature.get(k,j,0) / maxFeature)});
//				img.setPixel(0, 0, new Float[] {h,s,1f});
				
				img = Transforms.HSV_TO_RGB(img);
				
				binCols[j* 10 + k] = img.getPixel(0, 0);
			}
		}
		return binCols;
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:ColourHistogramGrid.java

示例13: Pong

import org.openimaj.image.MBFImage; //导入依赖的package包/类
public Pong(final int width, final int height) {

		this.redText = new HashMap<Attribute, Object>();
		this.redText.put(FontStyle.COLOUR, RGBColour.RED);

		this.blueText = new HashMap<Attribute, Object>();
		this.blueText.put(FontStyle.COLOUR, RGBColour.BLUE);

		this.allFont = new HashMap<Attribute, Object>();
		this.allFont.put(FontStyle.FONT, HersheyFont.ROMAN_SIMPLEX);
		this.allFont.put(FontStyle.FONT_SIZE, 40);

		this.frame_height = height;
		this.frame_width = width;
		this.lastFrame = new MBFImage(width, height, ColourSpace.RGB);
		this.frame = new MBFImage(width, height, ColourSpace.RGB);
		this.renderer = this.frame.createRenderer();

		this.borderTop = new Rectangle(0, 0, width, height * Pong.BORDER_TOP);
		this.borderBottom = new Rectangle(0, height * (1 - Pong.BORDER_BOTTOM), width, height * Pong.BORDER_BOTTOM);

		this.initMatch();

		this.getNextFrame();
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:Pong.java

示例14: extract

import org.openimaj.image.MBFImage; //导入依赖的package包/类
@Override
public LocalFeatureList<Keypoint> extract(byte[] image) throws IOException {
	LocalFeatureList<Keypoint> keys = null;

	switch (this.cm) {
	case SINGLE_COLOUR:
	case INTENSITY:
		final BasicASIFT basic = new BasicASIFT(!noDoubleImageSize);
		basic.detectFeatures((FImage) itOp.transform(cmOp.process(image)), ntilts);
		keys = basic.getFeatures();
		break;
	case INTENSITY_COLOUR:
		final ColourASIFT colour = new ColourASIFT(!noDoubleImageSize);
		colour.detectFeatures((MBFImage) itOp.transform(cmOp.process(image)), ntilts);
	}
	return keys;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:LocalFeatureMode.java

示例15: getAndExportBravoFaridClutter

import org.openimaj.image.MBFImage; //导入依赖的package包/类
/**
 * Compute the Bravo & Farid (2008) scale invariant clutter (see
 * getBravoFaridClutter()) and exports the segmented image as a file.
 * @param k
 * @param minSize
 * @param sigma
 * @param output the file in which the image is written.
 * @return
 * @throws IOException
 */
public int getAndExportBravoFaridClutter(float k, int minSize, float sigma,
    File output) throws IOException {
  MBFImage fImage = ImageUtilities.createMBFImage(image.getAsBufferedImage(),
      true);
  FelzenszwalbHuttenlocherSegmenter<MBFImage> segmenter = new FelzenszwalbHuttenlocherSegmenter<>(
      sigma, k, minSize);
  List<ConnectedComponent> components = segmenter.segment(fImage);
  MBFImage segImage = SegmentationUtilities
      .renderSegments(fImage, components);
  ImageUtilities.write(segImage, output);
  return components.size();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:23,代码来源:RasterClutterMethod.java


注:本文中的org.openimaj.image.MBFImage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。