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


Java ConvertBufferedImage.convertTo方法代码示例

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


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

示例1: addUndistorted

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private void addUndistorted(final String name, final PointTransform_F32 model) {
	// Set up image distort
	InterpolatePixel<ImageFloat32> interp = FactoryInterpolation.bilinearPixel(ImageFloat32.class);
	ImageDistort<ImageFloat32> undistorter = FactoryDistort.distort(interp, null, ImageFloat32.class);
	undistorter.setModel(new PointToPixelTransform_F32(model));

	// Fill the image with all black then render it
	GImageMiscOps.fill(undist, 0);
	DistortImageOps.distortMS(dist, undist, undistorter);

	final BufferedImage out = ConvertBufferedImage.convertTo(undist,null);

	// Add this rectified image
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			gui.addItem(new ImagePanel(out), name);
		}});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:19,代码来源:RemoveLensDistortionApp.java

示例2: convertToGray

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 * There is no real perfect way that everyone agrees on for converting color images into gray scale
 * images.  Two examples of how to convert a MultiSpectral image into a gray scale image are shown 
 * in this example.
 */
public static void convertToGray( BufferedImage input ) {
	// convert the BufferedImage into a MultiSpectral
	MultiSpectral<ImageUInt8> image = ConvertBufferedImage.convertFromMulti(input,null,ImageUInt8.class);
	
	ImageUInt8 gray = new ImageUInt8( image.width,image.height);
	
	// creates a gray scale image by averaging intensity value across pixels
	GPixelMath.averageBand(image, gray);
	BufferedImage outputAve = ConvertBufferedImage.convertTo(gray,null);

	// create an output image just from the first band
	BufferedImage outputBand0 = ConvertBufferedImage.convertTo(image.getBand(0),null);

	ShowImages.showWindow(outputAve,"Average");
	ShowImages.showWindow(outputBand0,"Band 0");
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:22,代码来源:ExampleMultiSpectralImages.java

示例3: setActiveAlgorithm

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
@Override
public void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
	if( image == null )
		return;

	WaveletDescription<C> desc = (WaveletDescription<C>)cookie;
	WaveletTransform<T,W,C> waveletTran =
			FactoryWaveletTransform.create((Class)image.getClass(),desc,numLevels,0,255);

	panel.reset();

	W imageWavelet = waveletTran.transform(image,null);

	waveletTran.invert(imageWavelet,imageInv);

	// adjust the values inside the wavelet transform to make it easier to see
	UtilWavelet.adjustForDisplay(imageWavelet, waveletTran.getLevels(), 255);
	BufferedImage buffWavelet = VisualizeImageData.grayMagnitude(imageWavelet,null,255);
	BufferedImage buffInv = ConvertBufferedImage.convertTo(imageInv,null);

	panel.addImage(buffWavelet,"Transform");
	panel.addImage(buffInv,"Inverse");
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:24,代码来源:WaveletVisualizeApp.java

示例4: scaleUpLayers

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private void scaleUpLayers() {
	T l = pyramid.getLayer(0);
	if( upscale == null ) {
		interp = (InterpolatePixel<T>) FactoryInterpolation.nearestNeighborPixel(l.getClass());
		upscale = (T)l._createNew(l.width,l.height);
	} else {
		upscale.reshape(l.width,l.height);
	}

	int N = pyramid.getNumLayers();

	for( int i = 0; i < N; i++ ) {
		DistortImageOps.scale(pyramid.getLayer(i),upscale, TypeInterpolate.NEAREST_NEIGHBOR);
		BufferedImage b = ConvertBufferedImage.convertTo(upscale,null);
		if( showScales )
			addImage(b,String.format("%5.2f",pyramid.getScale(i)));
		else
			addImage(b,String.format("%5.2f",pyramid.getSigma(i)));
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:21,代码来源:ImagePyramidPanel.java

示例5: colorizeSign

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 * <p>
 * Renders a colored image where the color indicates the sign and intensity its magnitude.   The input is divided
 * by normalize to render it in the appropriate scale.
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image. If <= 0 then the max value will be used
 * @return Rendered image.
 */
public static BufferedImage colorizeSign(ImageSingleBand src, BufferedImage dst, double normalize) {
	dst = checkInputs(src, dst);

	if (normalize <= 0) {
		normalize = GImageStatistics.maxAbs(src);
	}

	if (normalize == 0) {
		// sets the output to black
		ConvertBufferedImage.convertTo(src,dst);
		return dst;
	}

	if (src.getClass().isAssignableFrom(ImageFloat32.class)) {
		return colorizeSign((ImageFloat32) src, dst, (float) normalize);
	} else {
		return colorizeSign((ImageInteger) src, dst, (int) normalize);
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:31,代码来源:VisualizeImageData.java

示例6: keyTyped

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的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

示例7: undoRadialDistortion

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private void undoRadialDistortion(BufferedImage image) {
	ConvertBufferedImage.convertFromMulti(image, origMS, ImageFloat32.class);

	for( int i = 0; i < origMS.getNumBands(); i++ ) {
		ImageFloat32 in = origMS.getBand(i);
		ImageFloat32 out = correctedMS.getBand(i);

		undoRadial.apply(in,out);
	}
	if( correctedMS.getNumBands() == 3 )
		ConvertBufferedImage.convertTo(correctedMS,undistorted);
	else if( correctedMS.getNumBands() == 1 )
		ConvertBufferedImage.convertTo(correctedMS.getBand(0),undistorted);
	else
		throw new RuntimeException("What kind of image has "+correctedMS.getNumBands()+"???");
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:17,代码来源:CalibratedImageGridPanel.java

示例8: process

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void process( final BufferedImage input ) {
	setInputImage(input);
	this.input = ConvertBufferedImage.convertFromSingle(input, this.input, ImageUInt8.class);
	this.enhanced = new ImageUInt8(input.getWidth(),input.getHeight());
	this.output = new BufferedImage( input.getWidth(), input.getHeight(), BufferedImage.TYPE_INT_RGB);

	// over write input image so that it's gray scale
	ConvertBufferedImage.convertTo(this.input,input);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			setPreferredSize(new Dimension(input.getWidth(),input.getHeight()));
			processImage = true;
		}});
	doRefreshAll();
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:17,代码来源:ImageEnhanceApp.java

示例9: addRectified

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private void addRectified( final String name , final DenseMatrix64F rect1 , final DenseMatrix64F rect2 ) {
	// Will rectify the image
	ImageDistort<ImageFloat32> imageDistortLeft =
			RectifyImageOps.rectifyImage(param.getLeft(), rect1, ImageFloat32.class);
	ImageDistort<ImageFloat32> imageDistortRight =
			RectifyImageOps.rectifyImage(param.getRight(), rect2,ImageFloat32.class);

	// Fill the image with all black
	GImageMiscOps.fill(rectLeft, 0);
	GImageMiscOps.fill(rectRight,0);

	// Render the rectified image
	DistortImageOps.distortMS(distLeft, rectLeft, imageDistortLeft);
	DistortImageOps.distortMS(distRight, rectRight, imageDistortRight);

	// convert for output
	final BufferedImage outLeft = ConvertBufferedImage.convertTo(rectLeft,null);
	final BufferedImage outRight = ConvertBufferedImage.convertTo(rectRight, null);

	// Add this rectified image
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			gui.addItem(new RectifiedPairPanel(true, outLeft, outRight), name);
		}});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:26,代码来源:ShowRectifyCalibratedApp.java

示例10: main

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

		// Load image and templates
		String directory = "../data/applet/template/";

		ImageFloat32 image = UtilImageIO.loadImage(directory + "desktop.png", ImageFloat32.class);
		ImageFloat32 templateX = UtilImageIO.loadImage(directory + "x.png", ImageFloat32.class);
		ImageFloat32 templatePaint = UtilImageIO.loadImage(directory + "paint.png", ImageFloat32.class);
		ImageFloat32 templateBrowser = UtilImageIO.loadImage(directory + "browser.png", ImageFloat32.class);

		// create output image to show results
		BufferedImage output = new BufferedImage(image.width, image.height, BufferedImage.TYPE_INT_BGR);
		ConvertBufferedImage.convertTo(image, output);
		Graphics2D g2 = output.createGraphics();

		// Searches for a small 'x' that indicates where a window can be closed
		// Only two such objects are in the image so at best there will be one false positive
		g2.setColor(Color.RED);
		drawRectangles(g2, image, templateX, 3);
		// show match intensity image for this template
		showMatchIntensity(image, templateX);

		// Now it searches for a specific icon for which there is only one match
		g2.setColor(Color.BLUE);
		drawRectangles(g2, image, templatePaint, 1);

		// Look for the Google Chrome browser icon. There is no match for this icon..
		g2.setColor(Color.ORANGE);
		drawRectangles(g2, image, templateBrowser, 1);

		// False positives can some times be pruned using the error score.  In photographs taken
		// in the real world template matching tends to perform very poorly

		ShowImages.showWindow(output, "Found Matches");
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:36,代码来源:ExampleTemplateMatching.java

示例11: performUpdate

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private synchronized void performUpdate() {
	if( input == null || output == null )
		return;

	progress = 0;

	ProgressMonitorThread thread = new MyMonitorThread(this);
	thread.start();

	PointTransform_F32 ptran =
			new AddRadialPtoP_F32(input.width*0.8,input.width*0.8,0,
					input.width/2,input.height/2,radial1,radial2);
	PixelTransform_F32 tran=new PointToPixelTransform_F32(ptran);

	for( int i = 0; i < input.getNumBands(); i++ , progress++ ) {
		T bandIn = input.getBand(i);
		T bandOut = output.getBand(i);

		DistortImageOps.distortSingle(bandIn,bandOut,tran,false, TypeInterpolate.BILINEAR);
	}
	thread.stopThread();
	ConvertBufferedImage.convertTo(output, renderedImage);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			outputImage.createGraphics().drawImage(renderedImage,0,0,null);
			gui.repaint();
		}
	});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:31,代码来源:ShowLensDistortion.java

示例12: doNotScaleLayers

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private void doNotScaleLayers() {
	int N = pyramid.getNumLayers();

	for( int i = 0; i < N; i++ ) {
		BufferedImage b = ConvertBufferedImage.convertTo(pyramid.getLayer(i),null);
		addImage(b,String.format("%5.2f",pyramid.getScale(i)));
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:9,代码来源:ImagePyramidPanel.java

示例13: setActiveAlgorithm

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
@Override
public void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
	if( input == null )
		return;

	int active = (Integer)cookie;
	if( active == 0 ) {
		ImageStatistics.histogram(input,histogram);
		EnhanceImageOps.equalize(histogram, transform);
		EnhanceImageOps.applyTransform(input, transform, enhanced);
	} else if( active == 1 ) {
		EnhanceImageOps.equalizeLocal(input, radius, enhanced, histogram, transform);
	} else if( active == 2 ) {
		EnhanceImageOps.sharpen4(input, enhanced);
	} else if( active == 3 ) {
		EnhanceImageOps.sharpen8(input, enhanced);
	}

	if( previousActive != active ) {
		if( active == 1 ) {
			addToToolbar(selectRadius);
		} else {
			removeFromToolbar(selectRadius);
		}
		previousActive = active;
	}

	ConvertBufferedImage.convertTo(enhanced, output);

	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			gui.setBufferedImage(output);
			gui.repaint();
			gui.requestFocusInWindow();
		}
	});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:39,代码来源:ImageEnhanceApp.java

示例14: main

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void main(String[] args) throws FileNotFoundException {
		MediaManager media = DefaultMediaManager.INSTANCE;

//		String fileName0 = "images/dogdance07.png";
//		String fileName1 = "images/dogdance08.png";

		String fileName0 = "images/Urban2_07.png";
		String fileName1 = "images/Urban2_08.png";

//		String fileName0 = "images/Grove2_07.png";
//		String fileName1 = "images/Grove2_09.png";

		DenseOpticalFlow<ImageFloat32> denseFlow =
//				new IpolHornSchunkPyramid_to_DenseOpticalFlow();
				new IpolBroxSpacial_to_DenseOpticalFlow();

		BufferedImage buff0 = media.openImage(fileName0);
		BufferedImage buff1 = media.openImage(fileName1);


		// Dense optical flow is very computationally expensive.  Just process the image at 1/2 resolution
		ImageFloat32 previous = new ImageFloat32(buff0.getWidth(),buff0.getHeight());
		ImageFloat32 current = new ImageFloat32(previous.width,previous.height);
		ImageFlow flow = new ImageFlow(previous.width,previous.height);

		ConvertBufferedImage.convertFrom(buff0, previous);
		ConvertBufferedImage.convertFrom(buff1, current);

		// compute dense motion
		long start = System.currentTimeMillis();
		denseFlow.process(previous, current, flow);
		long stop = System.currentTimeMillis();
		System.out.println(" elapsed "+(stop-start));

		UtilOpticalFlow.saveFlow(flow,"denseflow.bflow");

		// Visualize the results
		PanelGridPanel gui = new PanelGridPanel(1,2);

		BufferedImage converted0 = new BufferedImage(current.width,current.height, BufferedImage.TYPE_INT_RGB);
		BufferedImage converted1 = new BufferedImage(current.width,current.height, BufferedImage.TYPE_INT_RGB);
		BufferedImage visualized = new BufferedImage(current.width,current.height, BufferedImage.TYPE_INT_RGB);

		ConvertBufferedImage.convertTo(previous, converted0, true);
		ConvertBufferedImage.convertTo(current, converted1, true);
		VisualizeOpticalFlow.colorized(flow, 10, visualized);

		AnimatePanel animate = new AnimatePanel(150,converted0,converted1);
		gui.add(animate);
		gui.add(visualized);
		animate.start();

		ShowImages.showWindow(gui,"Dense Optical Flow");
	}
 
开发者ID:lessthanoptimal,项目名称:IpolOpticalFlow,代码行数:55,代码来源:ExampleDenseOpticalFlow.java

示例15: performUpdate

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
private synchronized void performUpdate() {
	if( input == null || output == null )
		return;

	progress = 0;

	ProgressMonitorThread monitor = new MyMonitor(this,"");
	monitor.start();

	final String names[] = new String[3];
	final BufferedImage out[] = new BufferedImage[3];

	for( int i = 0; i < 3; i++ ) {
		out[i] = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB);
	}

	switch (active) {
		case 0:
			names[0] = "Red";
			names[1] = "Green";
			names[2] = "Blue";
			output.setTo(input);
			ConvertBufferedImage.convertTo(output.getBand(0),out[0]);
			ConvertBufferedImage.convertTo(output.getBand(1),out[1]);
			ConvertBufferedImage.convertTo(output.getBand(2),out[2]);
			break;

		case 1:
			names[0] = "Hue";
			names[1] = "Saturation";
			names[2] = "Value";
			ColorHsv.rgbToHsv_F32(input, output);
			setNaN(output.getBand(0));
			PixelMath.multiply(output.getBand(0), (float) (255.0 / (2 * Math.PI)), output.getBand(0));
			PixelMath.multiply(output.getBand(1), 255.0f, output.getBand(1));
			ConvertBufferedImage.convertTo(output.getBand(0),out[0]);
			ConvertBufferedImage.convertTo(output.getBand(1),out[1]);
			ConvertBufferedImage.convertTo(output.getBand(2),out[2]);
			break;

		case 2:
			names[0] = "Y";
			names[1] = "U";
			names[2] = "V";
			ColorYuv.rgbToYuv_F32(input, output);
			ConvertBufferedImage.convertTo(output.getBand(0),out[0]);
			VisualizeImageData.colorizeSign(output.getBand(1), out[1],-1);
			VisualizeImageData.colorizeSign(output.getBand(2), out[2], -1);
			break;
	}
	monitor.stopThread();

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			gui.reset();
			for( int i = 0; i < 3; i++ ) {
				gui.addImage(out[i],names[i]);
			}
			gui.setPreferredSize(new Dimension(input.width,input.height));
			gui.repaint();
			processedImage = true;
		}
	});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:65,代码来源:ShowColorModelApp.java


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