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

Java UtilImageIO类代码示例

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

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



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

示例1: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    FeatureFinder[] finders = new FeatureFinder[] {
            new FindCardColourFeatures(),
            new FindCardShadingFeatures(),
            new FindCardShapeFeatures()
    };
    for (FeatureFinder finder : finders) {
        List<String> summaries = new ArrayList<>();
        for (File file : new File("data/train-out").listFiles((dir, name) -> name.matches(".*\\.jpg"))) {
            BufferedImage image = UtilImageIO.loadImage(file.getAbsolutePath());
            double[] features = finder.find(image, false);
            if (features != null) {
                summaries.add(finder.getSummaryLine(file.getAbsolutePath(), features));
            }
        }
        Path p = Paths.get("data/train-out-" + finder.getFileSuffix());
        Files.write(p, summaries);
    }
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:20,代码来源:CreateTrainingDataV1.java


示例2: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
        FeatureFinder[] finders = new FeatureFinder[] {
                new FindCardColourFeatures(2),
//                new FindCardShadingFeatures(),
//                new FindCardShapeFeatures()
        };
        for (FeatureFinder finder : finders) {
            List<String> summaries = new ArrayList<>();
            for (File d : TrainingDataV2.LABELLED_DIRECTORY.listFiles((dir, name) -> !name.matches("\\..*"))) {
                for (File file : d.listFiles((dir, name) -> name.matches(".*\\.jpg"))) {
                    BufferedImage image = UtilImageIO.loadImage(file.getAbsolutePath());
                    double[] features = finder.find(image, false);
                    if (features != null) {
                        summaries.add(finder.getSummaryLine(file.getAbsolutePath(), features));
                    }
                }
            }
            Path p = Paths.get("data/train-out-" + finder.getFileSuffix());
            Files.write(p, summaries);
        }
    }
 
开发者ID:tomwhite,项目名称:set-game,代码行数:22,代码来源:CreateTrainingDataV2.java


示例3: computeAccuracyOnTrainingData

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static double computeAccuracyOnTrainingData() throws IOException {
    FindCardNumberFeatures cardFeatureCounter = new FindCardNumberFeatures();
    int correct = 0;
    int total = 0;
    for (File file : new File("data/train-out").listFiles((dir, name) -> name.matches(".*\\.jpg"))) {
        System.out.println(file);
        int predictedNumber = (int) cardFeatureCounter.find(UtilImageIO.loadImage(file.getAbsolutePath()), false)[0];
        int actualNumber = cardFeatureCounter.getLabelFromFilename(file.getName());
        if (predictedNumber == actualNumber) {
            correct++;
        } else {
            System.out.println("Incorrect, predicted " + predictedNumber);
        }
        total++;
    }
    System.out.println("Correct: " + correct);
    System.out.println("Total: " + total);
    double accuracy = ((double) correct)/total * 100;
    System.out.println("Accuracy: " + ((int) accuracy) + " percent");
    return accuracy;
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:22,代码来源:PredictCardNumberOnTrainingData.java


示例4: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    File testFile = new File("data/20170106_205743.jpg");
    CardDetector cardDetector = new CardDetector();
    List<CardImage> images = cardDetector.detect(testFile.getAbsolutePath(), false);
    List<Card> cards = Files.lines(Paths.get(testFile.getAbsolutePath().replace(".jpg", ".txt")))
            .map(Card::new)
            .collect(Collectors.toList());
    File outDir = new File("data/test-v2");;
    outDir.mkdirs();
    for (int i = 0; i < images.size(); i++) {
        CardImage image = images.get(i);
        Card card = cards.get(i);
        File labelledDirectory = new File(outDir, card.getDescription().replace(" ", "-"));
        labelledDirectory.mkdirs();
        File newFile = new File(labelledDirectory, testFile.getName().replace(".jpg", "_" + (i + 1) + ".jpg"));
        UtilImageIO.saveImage(image.getImage(), newFile.getAbsolutePath());
    }

}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:20,代码来源:CreateTestSetV2.java


示例5: view

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void view(File directory) {
    ListDisplayPanel panel = new ListDisplayPanel();
    int numCols = 20;

    int numImagesPerLabel = -1;
    char prevNumLabel = ' ';
    for (File d : directory.listFiles((dir, name) -> !name.matches("\\..*"))) {
        String label = d.getName();
        BufferedImage[] bufferedImages = Arrays.stream(d.listFiles((dir, name) -> name.matches(".*\\.jpg")))
                .map(f -> UtilImageIO.loadImage(f.getAbsolutePath()))
                .map(bi -> resize(bi, bi.getWidth() / 3, bi.getHeight() / 3))
                .collect(Collectors.toList())
                .toArray(new BufferedImage[0]);
        panel.addItem(new ImageGridPanel((bufferedImages.length / numCols) + 1, numCols, bufferedImages), label);
        System.out.println(label + "\t" + bufferedImages.length);
        if (prevNumLabel != label.charAt(0)) {
            numImagesPerLabel = bufferedImages.length;
            prevNumLabel = label.charAt(0);
        } else if (numImagesPerLabel != bufferedImages.length) {
            throw new IllegalStateException("Expected " + numImagesPerLabel + " images, but only found " + bufferedImages.length + " for " + label);
        }
    }

    ShowImages.showWindow(panel, ViewLabelledImagesV2.class.getSimpleName(), true);
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:26,代码来源:ViewLabelledImagesV2.java


示例6: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    if (!RAW_LABELLED_DIRECTORY.exists()) {
        CardDetector cardDetector = new CardDetector(4, 66);
        File outDir = RAW_LABELLED_DIRECTORY;
        outDir.mkdirs();
        for (File d : RAW_SORTED_DIRECTORY.listFiles((dir, name) -> name.matches("\\d"))) {
            int numberLabel = Integer.valueOf(d.getName());
            for (File file : d.listFiles((dir, name) -> name.matches(".*\\.jpg"))) {
                System.out.println(file);
                List<CardImage> images = cardDetector.detect(file.getAbsolutePath(), false, true, 3, 9);
                int i = 0;
                for (CardImage image : images) {
                    Card card = new Card(numberLabel, (i % 9) / 3, i / 9, i % 3);
                    File labelledDirectory = new File(outDir, card.getDescription().replace(" ", "-"));
                    labelledDirectory.mkdirs();
                    File newFile = new File(labelledDirectory, file.getName().replace(".jpg", "_" + numberLabel + "_" + i + ".jpg"));
                    UtilImageIO.saveImage(image.getImage(), newFile.getAbsolutePath());
                    i++;
                }
            }
        }
    }

    ViewLabelledImagesV2.view(RAW_LABELLED_DIRECTORY);
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:26,代码来源:CreateTrainingSetV2.java


示例7: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) {
    CardDetector cardDetector = new CardDetector();
    File outDir = new File("data/train-out");
    outDir.mkdirs();
    Arrays.stream(new File("data/train").listFiles((dir, name) -> name.matches(".*\\.jpg"))).forEach(
            file -> {
                try {
                    System.out.println(file);
                    List<CardImage> images = cardDetector.detect(file.getAbsolutePath());
                    int i = 1;
                    for (CardImage image : images) {
                        File newFile = new File(outDir, file.getName().replace(".jpg", "_" + i++ + ".jpg"));
                        UtilImageIO.saveImage(image.getImage(), newFile.getAbsolutePath());
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
    );
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:21,代码来源:CreateTrainingSetV1.java


示例8: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) {
    CardDetector cardDetector = new CardDetector();
    File outDir = new File("data/test-out");
    outDir.mkdirs();
    File file = new File("data/20170106_205743.jpg");
    try {
        System.out.println(file);
        List<CardImage> images = cardDetector.detect(file.getAbsolutePath());
        int i = 1;
        for (CardImage image : images) {
            File newFile = new File(outDir, file.getName().replace(".jpg", "_" + i++ + ".jpg"));
            UtilImageIO.saveImage(image.getImage(), newFile.getAbsolutePath());
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:18,代码来源:CreateTestSetV1.java


示例9: init

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
	super.init(config);
	File file = new File(GR.getGoldenDir(), goldenFileName);
	try {
		rnd = new Random(repeats);
		InputStream inImageStream = MTTestResourceManager.openFileAsInputStream(file.getPath());
		ImageUInt8 inImage = UtilImageIO.loadPGM_U8(inImageStream, (ImageUInt8) null);
		ImageFloat32 convImage = ConvertImage.convert(inImage,
				(ImageFloat32) null);
		levels = 4;
		denoiser = FactoryImageDenoise.waveletBayes(ImageFloat32.class,
				levels, 0, 255);
		noisy = convImage.clone();
		denoisy = convImage.clone();
	} catch (IOException e) {
		throw new GoldenFileNotFoundException(file, this.getClass());
	}
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:20,代码来源:DenoiseBayes.java


示例10: init

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
	super.init(config);
	File file = new File(GR.getGoldenDir(), goldenFileName);
	try {
		rnd = new Random(repeats);
		InputStream inImageStream = MTTestResourceManager.openFileAsInputStream(file.getPath());
		ImageUInt8 inImage = UtilImageIO.loadPGM_U8(inImageStream, (ImageUInt8) null);
		ImageFloat32 convImage = ConvertImage.convert(inImage, (ImageFloat32) null);
		levels = 4;
		denoiser = FactoryImageDenoise.waveletSure(ImageFloat32.class, levels, 0, 255);
		noisy = convImage.clone();
		denoisy = convImage.clone();
	} catch (IOException e) {
		throw new GoldenFileNotFoundException(file, this.getClass());
	}
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:18,代码来源:DenoiseSure.java


示例11: init

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
	super.init(config);

	File file = new File(GR.getGoldenDir(), goldenFileName);
	try {
		InputStream inImageStream = MTTestResourceManager.openFileAsInputStream(file.getPath());
		ImageUInt8 inImage = UtilImageIO.loadPGM_U8(inImageStream, (ImageUInt8) null);
		image = ConvertImage.convert(inImage, (ImageFloat32) null);
		ImageUInt8 bin = new ImageUInt8(image.width, image.height);
		double mean = ImageStatistics.mean(image);
		ThresholdImageOps.threshold(image, bin, (float) mean, true);
		filtered = BinaryImageOps.erode8(bin, 1, null);
		filtered = BinaryImageOps.dilate8(filtered, 1, null);
	} catch (IOException e) {
		throw new GoldenFileNotFoundException(file, this.getClass());
	}
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:19,代码来源:FitEllipse.java


示例12: init

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
	super.init(config);

	File file = new File(GR.getGoldenDir(), goldenFileName);
	try {
		rnd = new Random(repeats);
		InputStream inImageStream = MTTestResourceManager.openFileAsInputStream(file.getPath());
		ImageUInt8 inImage = UtilImageIO.loadPGM_U8(inImageStream, (ImageUInt8) null);
		ImageFloat32 convImage = ConvertImage.convert(inImage,
				(ImageFloat32) null);
		levels = 4;
		denoiser = FactoryImageDenoise.waveletVisu(ImageFloat32.class,
				levels, 0, 255);
		noisy = convImage.clone();
		denoisy = convImage.clone();
	} catch (IOException e) {
		throw new GoldenFileNotFoundException(file, this.getClass());
	}
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:21,代码来源:DenoiseVisu.java


示例13: processKinect

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public void processKinect(MultiSpectral<ImageUInt8> rgb, ImageUInt16 depth, long timeRgb, long timeDepth) {
	System.out.println(frameNumber+"  "+timeRgb);
	try {
		logFile.write(String.format("%10d %d %d\n",frameNumber,timeRgb,timeDepth).getBytes());
		logFile.flush();
		UtilImageIO.savePPM(rgb, String.format("log/rgb%07d.ppm", frameNumber), buffer);
		UtilOpenKinect.saveDepth(depth, String.format("log/depth%07d.depth", frameNumber), buffer);
		frameNumber++;

		if( showImage ) {
			ConvertBufferedImage.convertTo_U8(rgb,buffRgb);
			gui.repaint();
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:19,代码来源:LogKinectDataApp.java


示例14: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main( String args[] ) {

		// load images with lens distortion removed
		String dir = "../data/applet/stereo/";
		BufferedImage imageA = UtilImageIO.loadImage(dir + "mono_wall_01.jpg");
		BufferedImage imageB = UtilImageIO.loadImage(dir + "mono_wall_03.jpg");

		// Find a set of point feature matches
		List<AssociatedPair> matches = ExampleFundamentalMatrix.computeMatches(imageA,imageB);

		// Prune matches using the epipolar constraint
		List<AssociatedPair> inliers = new ArrayList<AssociatedPair>();
		DenseMatrix64F F = ExampleFundamentalMatrix.robustFundamental(matches, inliers);

		// display the inlier matches found using the robust estimator
		AssociationPanel panel = new AssociationPanel(20);
		panel.setAssociation(inliers);
		panel.setImages(imageA,imageB);

		ShowImages.showWindow(panel, "Inlier Pairs");

		rectify(F,inliers,imageA,imageB);
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:24,代码来源:ExampleRectifyUncalibratedStereo.java


示例15: sharpen

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
/**
	 * When an image is sharpened the intensity of edges are made more extreme while flat regions remain unchanged.
	 */
	public static void sharpen() {
//		BufferedImage buffered = UtilImageIO.loadImage("../data/applet/enhance/dull.jpg");
		BufferedImage buffered = UtilImageIO.loadImage("../data/applet/enhance/dark.jpg");
		ImageUInt8 gray = ConvertBufferedImage.convertFrom(buffered,(ImageUInt8)null);
		ImageUInt8 adjusted = new ImageUInt8(gray.width, gray.height);


		ListDisplayPanel panel = new ListDisplayPanel();

		EnhanceImageOps.sharpen4(gray, adjusted);
		panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-4");

		EnhanceImageOps.sharpen8(gray, adjusted);
		panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-8");

		panel.addImage(ConvertBufferedImage.convertTo(gray,null),"Original");

		panel.setPreferredSize(new Dimension(gray.width,gray.height));
		ShowImages.showWindow(panel,"Sharpen");
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:24,代码来源:ExampleImageEnhancement.java


示例16: loadObservations

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
/**
 * Detects calibration points found in several images and returned as a list. Not the focus of this example.
 */
public static List<List<Point2D_F64>> loadObservations() {

	String directory = "../data/evaluation/calibration/stereo/Bumblebee2_Chess";
	List<String> imageNames = BoofMiscOps.directoryList(directory,"left");

	PlanarCalibrationDetector detector = FactoryPlanarCalibrationTarget.
			detectorChessboard(new ConfigChessboard(5, 7));

	List<List<Point2D_F64>> ret = new ArrayList<List<Point2D_F64>>();

	for( String n : imageNames ) {
		BufferedImage img = UtilImageIO.loadImage(n);
		ImageFloat32 input = ConvertBufferedImage.convertFrom(img,(ImageFloat32)null);

		if( !detector.process(input) )
			throw new RuntimeException("Detection failed!");

		ret.add(detector.getPoints());
	}

	return ret;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:26,代码来源:ExampleCalibrateMonocularPoints.java


示例17: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main(String[] args) {

		BufferedImage image = UtilImageIO.loadImage("/home/pja/projects/ValidationBoof/data/track_rect/TLD/01_david/00001.jpg");
		new VisualizeTldDetectionApp(image,ImageUInt8.class);

//		String fileName = "/home/pja/Downloads/multi_face_turning/motinas_multi_face_turning.avi";

//		SimpleImageSequence<ImageUInt8> sequence =
//				new XugglerSimplified<ImageUInt8>(fileName, ImageDataType.single(ImageUInt8.class));
//
//		sequence.hasNext();
//		sequence.next();
//		sequence.hasNext();
//		sequence.next();
//
//		new VisualizeTldDetectionApp((BufferedImage)sequence.getGuiImage(),ImageUInt8.class);
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:18,代码来源:VisualizeTldDetectionApp.java


示例18: keyTyped

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
	if (e.getKeyChar() == 'p') {
		paused = false;
	} else if (e.getKeyChar() == 's') {
		System.out.println("Saving image");
		String name = String.format("image%05d.jpg", savedIndex++);

		BufferedImage img = ConvertBufferedImage.convertTo(image,null);
		UtilImageIO.saveImage(img, name);

	} else {
		paused = true;
		step = true;
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:17,代码来源:ProcessImageSequence.java


示例19: openImage

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
@Override
public BufferedImage openImage(String fileName) {
	
	BufferedImage b = cachedImage.get(fileName);
	
	if( b == null ) {
		b = UtilImageIO.loadImage(fileName);
		
		if( b == null )
			throw new RuntimeException("Image cannot be found! "+fileName);
		
		cachedImage.put(fileName,b);
	}

	// return a copy of the image so that if it is modified strangeness won't happen
	BufferedImage c = new BufferedImage(b.getWidth(),b.getHeight(),b.getType());
	Graphics2D g2 = c.createGraphics();
	g2.drawImage(b,0,0,null);
	return c;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:21,代码来源:DefaultMediaManager.java


示例20: main

import boofcv.io.image.UtilImageIO; //导入依赖的package包/类
public static void main( String args[] ) {
		BufferedImage in = UtilImageIO.loadImage("data/standard/lena512.bmp");
		WaveletVisualizeApp app = new WaveletVisualizeApp(ImageFloat32.class);
//		WaveletVisualizeApp app = new WaveletVisualizeApp(ImageUInt8.class);

		java.util.List<PathLabel> inputs = new ArrayList<PathLabel>();
		inputs.add(new PathLabel("lena","../data/evaluation/standard/lena512.bmp"));
		inputs.add(new PathLabel("boat","../data/evaluation/standard/boat.png"));
		inputs.add(new PathLabel("fingerprint","../data/evaluation/standard/fingerprint.png"));
		inputs.add(new PathLabel("shapes","../data/evaluation/shapes01.png"));
		inputs.add(new PathLabel("sunflowers","../data/evaluation/sunflowers.png"));

		app.setInputList(inputs);

		// wait for it to process one image so that the size isn't all screwed up
		while( !app.getHasProcessedImage() ) {
			Thread.yield();
		}

		ShowImages.showWindow(app,"Wavelet Transforms");
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:22,代码来源:WaveletVisualizeApp.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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