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


Java ImageUtilities.write方法代码示例

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


在下文中一共展示了ImageUtilities.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: main

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
/**
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
	final MBFImage image = ImageUtilities.readMBF(new File("/Users/jsh2/Pictures/08-earth_shuttle2.jpg"));

	int[] pixels = image.toPackedARGBPixels();

	Arrays.sort(pixels);
	final MBFImage sorted = new MBFImage(pixels, image.getWidth(), image.getHeight());
	ImageUtilities.write(sorted, new File("/Users/jsh2/Pictures/sorted.jpg"));

	final List<Integer> plist = Arrays.asList(ArrayUtils.toObject(pixels));
	Collections.shuffle(plist);
	pixels = ArrayUtils.toPrimitive(plist.toArray(new Integer[pixels.length]));
	final MBFImage shuffled = new MBFImage(pixels, image.getWidth(), image.getHeight());
	ImageUtilities.write(shuffled, new File("/Users/jsh2/Pictures/shuffled.jpg"));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:PixelShuffle.java

示例3: main

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

示例4: 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

示例5: main

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
/**
 * 	Default main
 *  @param args Command-line arguments
 */
public static void main( final String[] args )
   {
	// Open the audio stream
    final XuggleAudio a = new XuggleAudio( AudioWaveformPlotter.class.
    		getResource( "/org/openimaj/demos/audio/140bpm_formware_psytech.mp3" ) );

    // This is how wide we're going to draw the display
    final int w = 1920;

    // This is how high we'll draw the display
    final int h = 200;

    final MBFImage img = org.openimaj.vis.audio.AudioOverviewVisualisation.
    		getAudioWaveformImage( a, w, h, new Float[]{0f,0f,0f,1f},
    				new Float[]{1f,1f,1f,1f} );

    // Write the image to a file.
	try
	{
		ImageUtilities.write( img, "png", new File("audioWaveform.png") );
	}
	catch( final IOException e )
	{
		e.printStackTrace();
	}

	// Display the image
	DisplayUtilities.display( img );
   }
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:AudioWaveformPlotter.java

示例6: main

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws MalformedURLException, IOException {
	final FImage img = ImageUtilities.readF(new File(
			"/Volumes/Raid/face_databases/lfw/Aaron_Peirsol/Aaron_Peirsol_0002.jpg"));
	final FKEFaceDetector detector = new FKEFaceDetector(1.6f);
	final FaceAligner<KEDetectedFace> aligner = new AffineAligner(125, 160, 0.1f);

	final KEDetectedFace face = detector.detectFaces(img).get(0);

	final int facePatchSize = Math.max(160, 125);
	final double size = facePatchSize + 2.0 * facePatchSize * 0.1f;
	final double sc = 80 / size;

	final float[][] Pmu = {
			{ 25.0347f, 34.1802f, 44.1943f, 53.4623f, 34.1208f, 39.3564f, 44.9156f, 31.1454f, 47.8747f },
			{ 34.1580f, 34.1659f, 34.0936f, 33.8063f, 45.4179f, 47.0043f, 45.3628f, 53.0275f, 52.7999f } };

	FImage model = new FImage(125, 160);
	for (int i = 0; i < Pmu[0].length; i++) {
		Point2dImpl pt = new Point2dImpl(Pmu[0][i], Pmu[1][i]);

		pt = pt.transform(TransformUtilities.scaleMatrixAboutPoint(1 / sc, 1 / sc, new Point2dImpl(Pmu[0][0],
				Pmu[1][0])));

		model.drawPoint(pt, 1f, 3);
	}

	for (final FacialKeypoint kpt : face.getKeypoints())
		img.drawPoint(
				kpt.position.transform(TransformUtilities.translateMatrix(face.getBounds().x, face.getBounds().y)),
				1f, 3);
	model = model.inverse();
	ImageUtilities.write(img, new File("/Users/jsh2/keypoints.png"));
	ImageUtilities.write(model, new File("/Users/jsh2/model.png"));
	ImageUtilities.write(aligner.align(face), new File("/Users/jsh2/aligned.png"));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:Alignment.java

示例7: main

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	final ShapeModelDataset<FImage> dataset = IMMFaceDatabase.load(ImageUtilities.FIMAGE_READER);

	final PointListConnections connections = dataset.getConnections();
	final List<PointList> pointData = dataset.getPointLists();

	final int width = 200, height = 200;

	final PointDistributionModel pdm = new PointDistributionModel(pointData);
	pdm.setNumComponents(15);

	final FImage images = new FImage(4 * width, 4 * height);
	for (int j = 0; j < 4; j++) {
		for (int i = 0; i < 4; i++) {
			final ValueAnimator<double[]> a = DoubleArrayValueAnimator.makeRandomLinear(0,
					pdm.getStandardDeviations(3));
			final FImage image = new FImage(width, height);
			image.fill(1);
			final PointList newShape = pdm.generateNewShape(a.nextValue());
			final PointList tfShape = newShape.transform(TransformUtilities.translateMatrix(100, 100).times(
					TransformUtilities.scaleMatrix(50, 50)));

			final List<Line2d> lines = connections.getLines(tfShape);
			image.drawLines(lines, 1, 0f);

			images.drawImage(image, i * width, j * height);
		}
	}

	DisplayUtilities.display(images);
	ImageUtilities.write(images, new File("/Users/jsh2/Desktop/faces.png"));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:33,代码来源:PDMDisplay.java

示例8: main

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

示例9: main

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	final MBFImage sourceC = ImageUtilities.readMBF(monaLisaSource);
	final MBFImage targetC = ImageUtilities.readMBF(monaLisaTarget);
	final FImage source = sourceC.flatten();
	final FImage target = targetC.flatten();

	final DoGSIFTEngine eng = new DoGSIFTEngine();

	final LocalFeatureList<Keypoint> sourceFeats = eng.findFeatures(source);
	final LocalFeatureList<Keypoint> targetFeats = eng.findFeatures(target);

	final HomographyModel model = new HomographyModel();
	final SingleImageTransferResidual2d<HomographyModel> errorModel = new SingleImageTransferResidual2d<HomographyModel>();
	final RANSAC<Point2d, Point2d, HomographyModel> ransac = new RANSAC<Point2d, Point2d, HomographyModel>(model,
			errorModel, 5f, 1500, new RANSAC.BestFitStoppingCondition(), true);
	final ConsistentLocalFeatureMatcher2d<Keypoint> matcher = new ConsistentLocalFeatureMatcher2d<Keypoint>(
			new FastBasicKeypointMatcher<Keypoint>(8));
	matcher.setFittingModel(ransac);

	matcher.setModelFeatures(sourceFeats);
	matcher.findMatches(targetFeats);

	final Matrix boundsToPoly = model.getTransform().inverse();

	final Shape s = source.getBounds().transform(boundsToPoly);
	targetC.drawShape(s, 10, RGBColour.BLUE);
	final MBFImage matches = MatchingUtilities.drawMatches(sourceC, targetC, matcher.getMatches(), RGBColour.RED);

	matches.processInplace(new ResizeProcessor(640, 480));
	DisplayUtilities.display(matches);
	ImageUtilities.write(matches, new File("/Users/ss/Desktop/keypoint-match-example.png"));

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

示例10: main

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	final XuggleVideo xv = new XuggleVideo(new File("/Users/jon/Desktop/merlin/tunnel.mp4"));

	final List<MBFImage> frameSample = new ArrayList<MBFImage>();
	int count = 0;
	for (final MBFImage fr : xv) {
		if (count % 30 == 0)
			System.out.println(count / 30);

		if (count % 30 == 0)
			frameSample.add(fr.clone());
		count++;
	}

	final MBFImage img = new MBFImage(frameSample.get(0).getWidth(), frameSample.get(0).getHeight());
	final float[] vec = new float[frameSample.size()];
	for (int y = 0; y < img.getHeight(); y++) {
		for (int x = 0; x < img.getWidth(); x++) {
			for (int b = 0; b < 3; b++) {
				for (int i = 0; i < frameSample.size(); i++)
					vec[i] = frameSample.get(i).getBand(b).pixels[y][x];

				img.bands.get(b).pixels[y][x] = FloatArrayStatsUtils.median(vec);
			}
		}
	}

	DisplayUtilities.display(img);
	ImageUtilities.write(img, new File("/Users/jon/Desktop/merlin/tunnel-background.png"));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:BackgroundEstimator.java

示例11: ternaryPlotSearchGrid

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
private static void ternaryPlotSearchGrid(File file) throws IOException {
	final List<IndependentPair<TernaryData, String>> labels = new ArrayList<IndependentPair<TernaryData, String>>();
	final TernaryParams params = new TernaryParams();
	final List<TernaryData> data = new ArrayList<TernaryData>();
	data.add(new TernaryData(0.3f, 0.3f, 0.3f, 1f));
	final TernaryPlot plot = preparePlot(params, data);
	params.put(TernaryParams.DRAW_SCALE, false);

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				final float sum = i + j + k;
				if (sum == 0)
					continue;
				final float ip = i / sum;
				final float jp = j / sum;
				final float kp = k / sum;
				final TernaryData point = new TernaryData(ip, jp, kp, 10);
				final String label = String.format("(%2.1f,%2.1f,%2.1f)", ip, jp, kp);
				final IndependentPair<TernaryData, String> pair = IndependentPair.pair(point, label);
				labels.add(pair);
			}
		}
	}

	// labels.add(IndependentPair.pair(new TernaryData(1f,0,0,0),"f_1"));
	// labels.add(IndependentPair.pair(new TernaryData(0,1,0,0),"f_2"));
	// labels.add(IndependentPair.pair(new TernaryData(0,0,1,0),"f_3"));
	params.put(TernaryParams.LABELS, labels);
	final Map<Attribute, Object> fontAttrs = params.getTyped(TernaryParams.LABEL_FONT);
	fontAttrs.put(MathMLFontStyle.TEXT_MODE, false);
	fontAttrs.put(MathMLFontStyle.FONT_SIZE, 12);
	final MBFImage draw = plot.draw(params);
	ImageUtilities.write(draw, file);
	DisplayUtilities.display(draw);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:37,代码来源:SED2013Ternary.java

示例12: writeBinary

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
@Override
public void writeBinary(DataOutput out) throws IOException {
	out.writeInt(facePatchWidth);
	out.writeInt(facePatchHeight);
	out.writeFloat(facePatchBorderPercentage);
	ImageUtilities.write(mask, "png", out);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:AffineAligner.java

示例13: execute

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
void execute() throws IOException {
	FImage mask = FloodFill.floodFill(input, px, py, thresh);
	
	if (maskoutput != null)
		ImageUtilities.write(mask, maskoutput.getName().substring(maskoutput.getName().lastIndexOf(".") + 1), maskoutput);
	
	if (feature != null) { 
		FeatureVector fv = featureOp.execute(input, mask);
	
		if (binary)
			IOUtils.writeBinary(output, fv);
		else
			IOUtils.writeASCII(output, fv);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:16,代码来源:SegmentingGlobalFeaturesTool.java

示例14: setup

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
/**
 * Setup tests
 * 
 * @throws IOException
 */
@Before
public void setup() throws IOException {
	final InputStream is = this.getClass().getResourceAsStream("/org/openimaj/image/data/cat.jpg");
	tmpImageFile = folder.newFile("cat.jpg");
	tmpNormImageFile = folder.newFile("catIntensityNormalised.jpg");

	FileOutputStream fos = null;
	try {
		fos = new FileOutputStream(tmpImageFile);
		final byte[] arr = new byte[1024];
		int read = is.read(arr);
		while (read != -1) {
			try {
				fos.write(arr, 0, read);
				read = is.read(arr);
			} catch (final Exception e) {
				System.out.println(e);
			}
		}
	} finally {
		fos.close();
	}

	loaded = ImageUtilities.readMBF(tmpImageFile);
	normalised = Transforms.RGB_TO_RGB_NORMALISED(loaded);

	ImageUtilities.write(loaded, "jpg", tmpImageFile);
	ImageUtilities.write(normalised.getBand(1), "jpg", tmpNormImageFile);
	System.out.println("Image out: " + tmpImageFile);
	System.out.println("Normalised Image out: " + tmpNormImageFile);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:37,代码来源:LocalFeaturesToolTest.java

示例15: writeBinary

import org.openimaj.image.ImageUtilities; //导入方法依赖的package包/类
@Override
public void writeBinary(DataOutput out) throws IOException {
	out.writeInt(eyeDist);
	out.writeInt(eyePaddingLeftRight);
	out.writeInt(eyePaddingTop);

	ImageUtilities.write(mask, "png", out);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:9,代码来源:RotateScaleAligner.java


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