• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ImageUtilities类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

import org.openimaj.image.ImageUtilities; //导入依赖的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: doClassify

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
private void doClassify(double[] mean) {
	final HashSet<Integer> clzCount = new HashSet<Integer>();
	clzCount.addAll(classes);

	if (points.size() > 0 && clzCount.size() == 2) {
		final double[] p1 = new double[] { 0, 0 };
		p1[1] = (float) classifier.computeHyperplanePoint(0);

		final double[] p2 = new double[] { 1, 0 };
		p2[1] = (float) classifier.computeHyperplanePoint(1);

		image.drawLine(projectPoint(p1), projectPoint(p2), 3, RGBColour.BLACK);

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

		guess.setText(this.classType.getItemAt(classifier.predict(mean)));
		return;
	}
	guess.setText("unknown");
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:21,代码来源:LinearClassifierDemo.java


示例3: calculateIntensityNTSC_LUT

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * Calculate intensity by a weighted average of the R, G, B planes. Assumes
 * planes are all in 0..1, and NTSC weighting coefficients. Assignment to
 * graylevels is done using a LUT, so greys will have one of 256 discrete
 * levels. The primary purpose of this is to be compatible with
 * {@link FImage#FImage(int[], int, int)} and give exactly the same result.
 * 
 * @param in
 *            MBFImage with 3 bands
 * @return intensity image
 */
public static FImage calculateIntensityNTSC_LUT(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] = ImageUtilities.BYTE_TO_FLOAT_LUT[(int) ((
					0.299f * (255 * in.getBand(0).pixels[r][c]) +
							0.587f * (255 * in.getBand(1).pixels[r][c]) +
					0.114f * (255 * in.getBand(2).pixels[r][c])))];
		}
	}

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


示例4: setImage

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
@Override
public void setImage() {
	final ByteBuffer buf = buffer.duplicate();

	final int width = stream.width;
	final int height = stream.height;

	final float[][] r = nextFrame.bands.get(0).pixels;
	final float[][] g = nextFrame.bands.get(1).pixels;
	final float[][] b = nextFrame.bands.get(2).pixels;

	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			final int red = buf.get() & 0xFF;
			final int green = buf.get() & 0xFF;
			final int blue = buf.get() & 0xFF;
			r[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[red];
			g[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[green];
			b[y][x] = ImageUtilities.BYTE_TO_FLOAT_LUT[blue];
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:KinectRGBVideoStream.java


示例5: render

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
@Override
public void render(final MBFImageRenderer renderer, final Matrix transform, final Rectangle rectangle) {
	if (this.toRender == null) {
		try {
			this.toRender = ImageUtilities.readMBF(VideoColourSIFT.class
					.getResource("/org/openimaj/demos/OpenIMAJ.png"));
		} catch (final IOException e) {
			System.err.println("Can't load image to render");
		}
		this.renderToBounds = TransformUtilities.makeTransform(this.toRender.getBounds(), rectangle);
	}

	final MBFProjectionProcessor mbfPP = new MBFProjectionProcessor();
	mbfPP.setMatrix(transform.times(this.renderToBounds));
	mbfPP.accumulate(this.toRender);
	mbfPP.performProjection(0, 0, renderer.getImage());

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


示例6: main

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
	 * Test the distance transform
	 * @param args
	 * @throws IOException
	 */
	public static void main(String args[]) throws IOException{
		FImage i = ImageUtilities.readF(new File("/Users/ss/Desktop/tache.jpg"));
		EuclideanDistanceTransform etrans = new EuclideanDistanceTransform();
//		i.processInplace(new CannyEdgeDetector());
		i.inverse();
		for(int x = 0;x < i.width; x++)
			for(int y = 0; y < i.height; y++) 
				if(i.pixels[y][x] == 1.0f) 
					i.setPixel(x, y, Float.MAX_VALUE);
		DisplayUtilities.display(i);
		i.analyseWith(etrans);
		i = etrans.getDistances();
		i.normalise();
		DisplayUtilities.display(i);
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:EuclideanDistanceTransform.java


示例7: main

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * @param args
 * @throws IOException
 */
public static void main(String [] args) throws IOException {
	int nFeatures = 100;

	TrackingContext tc = new TrackingContext();
	FeatureList fl = new FeatureList(nFeatures);
	KLTTracker tracker = new KLTTracker(tc, fl);

	FImage img1 = ImageUtilities.readF(Example1.class.getResourceAsStream("img0.pgm"));
	FImage img2 = ImageUtilities.readF(Example1.class.getResourceAsStream("img1.pgm"));

	tracker.selectGoodFeatures(img1);

	DisplayUtilities.display(fl.drawFeatures(img1));
	fl.writeFeatureList(null, "%3d");

	tracker.trackFeatures(img1, img2);
	tracker.replaceLostFeatures(img2);

	DisplayUtilities.display(fl.drawFeatures(img1));
	fl.writeFeatureList(null, "%3d");
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:Example2.java


示例8: consumeFrequency

import org.openimaj.image.ImageUtilities; //导入依赖的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 ));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:AudioOutroSlide.java


示例9: main

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * Main method
 * 
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
	// Load the image
	final URL[] imageURLs = new URL[] {
			new URL("http://users.ecs.soton.ac.uk/dpd/projects/openimaj/tutorial/hist1.jpg"),
			new URL("http://users.ecs.soton.ac.uk/dpd/projects/openimaj/tutorial/hist2.jpg"),
			new URL("http://users.ecs.soton.ac.uk/dpd/projects/openimaj/tutorial/hist3.jpg")
	};

	final List<MultidimensionalHistogram> histograms = new ArrayList<MultidimensionalHistogram>();
	final HistogramModel model = new HistogramModel(4, 4, 4);

	for (final URL u : imageURLs) {
		model.estimateModel(ImageUtilities.readMBF(u));
		histograms.add(model.histogram.clone());
	}

	for (int i = 0; i < histograms.size(); i++) {
		for (int j = i; j < histograms.size(); j++) {
			final double distance = histograms.get(i).compare(histograms.get(j), DoubleFVComparison.EUCLIDEAN);
			System.out.println(distance);
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:App.java


示例10: testLandscapeDetection

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * Test landscape classifications
 */
@Test
public void testLandscapeDetection()
{
	try
	{
		FImage cityImage = ImageUtilities.readF( 
				new File( "src/test/resources/landscape.jpg" ) );
		String classification = clt.classifyImage( cityImage, 1 );
		System.out.println( classification );
		Assert.assertEquals( LANDSCAPE_STRING, classification );
	}
	catch( IOException e )
	{
		e.printStackTrace();
	}		
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:CityLandscapeTreeTest.java


示例11: SandeepFaceDetector

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * Construct a new {@link SandeepFaceDetector} with the default skin-tone
 * model.
 */
public SandeepFaceDetector() {
	ccl = new ConnectedComponentLabeler(ConnectMode.CONNECT_8);

	try {
		if (this.getClass().getResource(DEFAULT_MODEL) == null) {
			// This is to create the skin model
			skinModel = new HistogramPixelModel(16, 6);
			final MBFImage rgb = ImageUtilities.readMBF(this.getClass().getResourceAsStream("skin.png"));
			skinModel.learnModel(Transforms.RGB_TO_HS(rgb));
			// final ObjectOutputStream oos = new ObjectOutputStream(new
			// FileOutputStream(new File(
			// "src/main/resources" + DEFAULT_MODEL)));
			// oos.writeObject(skinModel);
			// oos.close();
		} else {
			// Load in the skin model
			final ObjectInputStream ois = new ObjectInputStream(this.getClass().getResourceAsStream(DEFAULT_MODEL));
			skinModel = (MBFPixelClassificationModel) ois.readObject();
		}
	} catch (final Exception e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:SandeepFaceDetector.java


示例12: drawBothAlpha

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
private void drawBothAlpha(final int x, final int y, final int stopx,
		final int stopy, final int startx, final int starty,
		final float[][][] thisPixels, final float[][][] thatPixels) {
	float[] out = new float[4];
	for (int yy = starty; yy < stopy; yy++) {
		final int thatY = yy - y;

		for (int xx = startx; xx < stopx; xx++) {

			final int thatX = xx - x;
			float thisA = thisPixels[3][yy][xx] ;
			float thatA = thatPixels[3][thatY][thatX] ;
			ImageUtilities.alphaCompositePixel(out,
				thisPixels[0][yy][xx], thisPixels[1][yy][xx], thisPixels[2][yy][xx], thisA,
				thatPixels[0][thatY][thatX], thatPixels[1][thatY][thatX], thatPixels[2][thatY][thatX], thatA
			);

			thisPixels[0][yy][xx] = out[0];
			thisPixels[1][yy][xx] = out[1];
			thisPixels[2][yy][xx] = out[2];
			thisPixels[3][yy][xx] = out[3];
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:MBFImageRenderer.java


示例13: process

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
@Override
public void process(SimilarityMatrix matrix, File output) throws Exception {
	MultidimensionalScaling mds = new MultidimensionalScaling(numIterations, rate);
	matrix.processInplace(mds);

	if (output == null) {
		if (imageOutputMode) { 
			ImageUtilities.write(render(mds.getPoints(), imageSize), "png", System.out);
		} else {
			System.out.println(mds);
		}
	} else {
		if (imageOutputMode) {
			ImageUtilities.write(render(mds.getPoints(), imageSize), output);
		} else {
			BufferedWriter bw = new BufferedWriter(new FileWriter(output));
			bw.write(mds.toString());
			bw.close();
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:MDS.java


示例14: displayQueryResults

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * 
 * @param resource
 * @return The displayed image
 * @throws Exception
 */
public static MBFImage displayQueryResults(final URL resource) throws Exception
{
	System.out.println("----------- QUERYING ----------- ");
	final FImage fi = ImageUtilities.readF(resource);
	final PersonMatcher pm = new PersonMatcher(new File(PersonMatcher.RECOGNISER_FILE));
	final List<? extends IndependentPair<? extends DetectedFace, ScoredAnnotation<String>>> l = pm.query(fi);

	final MBFImage m = new MBFImage(fi.getWidth(), fi.getHeight(), 3);
	m.addInplace(fi);
	int count = 1;
	for (final IndependentPair<? extends DetectedFace, ScoredAnnotation<String>> i : l)
	{
		final Rectangle b = i.firstObject().getBounds();
		m.drawShape(b, RGBColour.RED);
		final String name = count + " : " +
				(i.secondObject() == null ? "Unknown" : i.secondObject().annotation);
		m.drawText(name, (int) b.x, (int) b.y,
				HersheyFont.TIMES_MEDIUM, 12, RGBColour.GREEN);
		count++;
	}
	DisplayUtilities.display(m);
	return m;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:PersonMatcher.java


示例15: main

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	final int seed = 43;

	final MBFImage input = ImageUtilities.readMBF(new File("/Users/jsh2/Data/ukbench/full/ukbench00000.jpg"));

	// Simulation sim = new CropSimulation(seed);
	// Simulation sim = new ArbitaryRotateSimulation(seed);
	// Simulation sim = new Rotate90Simulation(seed);
	// Simulation sim = new CompressSimulation(seed);
	// Simulation sim = new UniformScaleSimulation(seed);
	// Simulation sim = new ArbitaryStretchSimulation(seed);
	// Simulation sim = new GreyscaleSimulation(seed);
	// Simulation sim = new WatermarkSimulation(seed);

	final Simulation sim = new ComboSimulation(seed,
			new Rotate90Simulation(seed),
			new CropSimulation(seed),
			new WatermarkSimulation(seed),
			new CompressSimulation(seed)
			);

	for (int i = 0; i < 10; i++) {
		DisplayUtilities.display(sim.applySimulation(input));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:SimulationDriver.java


示例16: next

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
@Override
public ImageCollectionEntry<MBFImage> next() {
	IndependentPair<URL, Map<String, String>> urlMeta = imageList.next();
	URL u = urlMeta.firstObject();
	try {
		MBFImage image = ImageUtilities.readMBF(u.openConnection().getInputStream());
		ImageCollectionEntry<MBFImage> entry = new ImageCollectionEntry<MBFImage>();
		entry.image = image;
		entry.meta = urlMeta.secondObject();
		entry.accepted = true;
		if(this.selection!=null) entry.accepted  = selection.acceptEntry(image);
		return entry;
	} catch (IOException e) {
	}
	return null;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:URLImageIterator.java


示例17: getAndExportBravoFaridClutter

import org.openimaj.image.ImageUtilities; //导入依赖的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


示例18: main

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * @param args
 * @throws IOException
 */
public static void main(String [] args) throws IOException {
	  FImage img1, img2;
	  
	  int nFeatures = 100;
	  TrackingContext tc = new TrackingContext();
	  FeatureList fl = new FeatureList(nFeatures);
	  KLTTracker tracker = new KLTTracker(tc, fl);
	  
	  System.out.println(tc);
	  
	  img1 = ImageUtilities.readF(Example1.class.getResourceAsStream("img0.pgm"));
	  img2 = ImageUtilities.readF(Example1.class.getResourceAsStream("img1.pgm"));

	  tracker.selectGoodFeatures(img1);

	  System.out.println("\nIn first image:\n");
	  for (int i = 0 ; i < fl.features.length ; i++)  {
		  System.out.format("Feature #%d:  (%f,%f) with value of %d\n", i, fl.features[i].x, fl.features[i].y, fl.features[i].val);
	  }

	  DisplayUtilities.display(fl.drawFeatures(img1));
	  fl.writeFeatureList(null, "%3d");

	  tracker.trackFeatures(img1, img2);

	  System.out.println("\nIn second image:\n");
	  for (int i = 0; i < fl.features.length; i++)  {
		  System.out.format("Feature #%d:  (%f,%f) with value of %d\n", i, fl.features[i].x, fl.features[i].y, fl.features[i].val);
	  }

	  DisplayUtilities.display(fl.drawFeatures(img2));
	  fl.writeFeatureList(null, "%5.1f");
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:38,代码来源:Example1.java


示例19: setup

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**
 * Setup
 * @throws Exception
 */
@Before public void setup() throws Exception {
	engine = new FKEFaceDetector();
	noface = ImageUtilities.readF(this.getClass().getResourceAsStream("/org/openimaj/image/data/cat.jpg"));
	face = ImageUtilities.readF(this.getClass().getResourceAsStream("/org/openimaj/image/data/face/ss.jpg"));
	
	k1 = engine.detectFaces(noface);
	k2 = engine.detectFaces(face);	
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:13,代码来源:FacialKeypointTest.java


示例20: getImage

import org.openimaj.image.ImageUtilities; //导入依赖的package包/类
/**	
 * 	Reads the actual flickr image. If it's cached then it will read
 * 	the cache, otherwise it will contact Flickr.
 *	@return The image
 *	@throws IOException
 */
public MBFImage getImage() throws IOException
{
	if( localFile != null )
			return ImageUtilities.readMBF( localFile );
	else	return ImageUtilities.readMBF( url.toURL() );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:13,代码来源:FlickrImage.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileTypeDetector类代码示例发布时间:2022-05-21
下一篇:
Java AbstractSaslImpl类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap