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


Java ConvertBufferedImage.convertFromMulti方法代码示例

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


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

示例1: independent

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 * Many operations designed to only work on {@link boofcv.struct.image.ImageSingleBand} can be applied
 * to a MultiSpectral image by feeding in each band one at a time.
 */
public static void independent( BufferedImage input ) {
	// convert the BufferedImage into a MultiSpectral
	MultiSpectral<ImageUInt8> image = ConvertBufferedImage.convertFromMulti(input,null,ImageUInt8.class);

	// declare the output blurred image
	MultiSpectral<ImageUInt8> blurred =
			new MultiSpectral<ImageUInt8>(ImageUInt8.class,image.width,image.height,image.getNumBands());
	
	// Apply Gaussian blur to each band in the image
	for( int i = 0; i < image.getNumBands(); i++ ) {
		// note that the generalized version of BlurImageOps is not being used, but the type
		// specific version.
		BlurImageOps.gaussian(image.getBand(i),blurred.getBand(i),-1,5,null);
	}
	
	// Declare the BufferedImage manually to ensure that the color bands have the same ordering on input
	// and output
	BufferedImage output = new BufferedImage(image.width,image.height,input.getType());
	ConvertBufferedImage.convertTo(blurred, output);
	ShowImages.showWindow(input,"Input");
	ShowImages.showWindow(output,"Ouput");
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:27,代码来源:ExampleMultiSpectralImages.java

示例2: convertBufferedToRGB

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 * BufferedImage support many different image formats internally.  More often than not the order
 * of its bands are not RGB, which can cause problems when you expect it to be RGB.  A function
 * is provided that will swap the bands of a MultiSpectral image created from a BufferedImage
 * to ensure that it is in RGB ordering.
 */
public static void convertBufferedToRGB( BufferedImage input ) {

	// convert the BufferedImage into a MultiSpectral
	MultiSpectral<ImageUInt8> image = ConvertBufferedImage.convertFromMulti(input,null,ImageUInt8.class);

	int x=15,y=15;
	
	// print the value of "red" at a pixel to make it easy to see the change
	System.out.print("before: ");
	for( int i = 0; i < image.getNumBands(); i++ )
		System.out.print(image.getBand(i).get(x,y)+" ");
	System.out.println();
	
	// change the bands
	ConvertBufferedImage.orderBandsIntoRGB(image,input);

	// THe value of red should be different of the BufferedImage was not in RGB format.
	System.out.print("After:  ");
	for( int i = 0; i < image.getNumBands(); i++ )
		System.out.print(image.getBand(i).get(x,y)+" ");
	System.out.println();
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:29,代码来源:ExampleMultiSpectralImages.java

示例3: pixelAccess

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 * Values of pixels can be read and modified by accessing the internal {@link boofcv.struct.image.ImageSingleBand}.
 */
public static void pixelAccess(  BufferedImage input ) {
	// convert the BufferedImage into a MultiSpectral
	MultiSpectral<ImageUInt8> image = ConvertBufferedImage.convertFromMulti(input,null,ImageUInt8.class);

	int x = 10, y = 10;

	// to access a pixel you first access the gray image for the each band
	for( int i = 0; i < image.getNumBands(); i++ )
		System.out.println("Original "+i+" = "+image.getBand(i).get(x,y));

	// change the value in each band
	for( int i = 0; i < image.getNumBands(); i++ )
		image.getBand(i).set(x, y, 100 + i);

	// to access a pixel you first access the gray image for the each band
	for( int i = 0; i < image.getNumBands(); i++ )
		System.out.println("Result   "+i+" = "+image.getBand(i).get(x,y));
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:22,代码来源:ExampleMultiSpectralImages.java

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

示例5: process

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void process( final BufferedImage image ) {
	input.reshape(image.getWidth(),image.getHeight());
	output.reshape(image.getWidth(),image.getHeight());
	storage.reshape(image.getWidth(),image.getHeight());

	ConvertBufferedImage.convertFromMulti(image, input, imageType);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			setInputImage(image);
			renderedImage = new BufferedImage(input.width, input.height,BufferedImage.TYPE_INT_BGR);
			gui.setBufferedImage(renderedImage);
			gui.setPreferredSize(new Dimension(input.width,input.height));
			gui.repaint();
			processedImage = true;
			doRefreshAll();
		}});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:19,代码来源:ShowImageBlurApp.java

示例6: saveImage

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void saveImage(BufferedImage img, String fileName) {
	try {
		String type;
		String a[] = fileName.split("[.]");
		if (a.length > 0) {
			type = a[a.length - 1];
		} else {
			type = "jpg";
		}

		if( !ImageIO.write(img, type, new File(fileName)) ) {
			if( fileName.endsWith("ppm") || fileName.endsWith("PPM") ) {
				MultiSpectral<ImageUInt8> color = ConvertBufferedImage.convertFromMulti(img,null,ImageUInt8.class);
				ConvertBufferedImage.orderBandsIntoRGB(color,img);
				savePPM(color, fileName, null);
			}else
				throw new IllegalArgumentException("No writter appropriate found");
		}
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:23,代码来源:UtilImageIO.java

示例7: process

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void process( final BufferedImage image ) {
	input.reshape(image.getWidth(),image.getHeight());
	output.reshape(image.getWidth(),image.getHeight());

	ConvertBufferedImage.convertFromMulti(image, input, imageType);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			setInputImage(image);
			outputImage = new BufferedImage(input.width, input.height,BufferedImage.TYPE_INT_BGR);
			renderedImage = new BufferedImage(input.width, input.height,BufferedImage.TYPE_INT_BGR);
			gui.setBufferedImage(outputImage);
			gui.setPreferredSize(new Dimension(input.width,input.height));
			gui.repaint();
			processedImage = true;
			doRefreshAll();
		}});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:19,代码来源:ShowLensDistortion.java

示例8: process

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void process(final BufferedImage buffLeft, final BufferedImage buffRight) {
	imageLeft.reshape(buffLeft.getWidth(), buffLeft.getHeight());
	imageRight.reshape(buffRight.getWidth(), buffRight.getHeight());
	grayLeft.reshape(buffLeft.getWidth(), buffLeft.getHeight());
	grayRight.reshape(buffRight.getWidth(), buffRight.getHeight());

	ConvertBufferedImage.convertFromMulti(buffLeft, imageLeft, imageType);
	ConvertBufferedImage.convertFromMulti(buffRight, imageRight, imageType);
	GConvertImage.average(imageLeft, grayLeft);
	GConvertImage.average(imageRight,grayRight);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			panel.setImages(buffLeft, buffRight);
			processedImage = true;
			doRefreshAll();
		}
	});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:20,代码来源:VisualizeAssociationMatchesApp.java

示例9: singleCellTriangleCase

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 *
 * this test tests if the whole shape gets filled as it should be
 *
 * result looks like this:
 * Sxxx.....
 * xxx......
 * xx.......
 * x........
 * .........
 * .........
 * .........
 * .........
 * .........
 *
 */
@Test
public void singleCellTriangleCase() {
    Extended extended = new Extended();

    extended.setImageSize(new Vector2d<>(9, 9));

    // TODO< create image for testing >
    BufferedImage testImage = new BufferedImage(9,9, BufferedImage.TYPE_INT_RGB);
    testImage.setRGB(0, 0, 0xFFFFFFFF);
    testImage.setRGB(1, 0, 0xFFFFFFFF);
    testImage.setRGB(2, 0, 0xFFFFFFFF);
    testImage.setRGB(3, 0, 0xFFFFFFFF);

    testImage.setRGB(0, 1, 0xFFFFFFFF);
    testImage.setRGB(1, 1, 0xFFFFFFFF);
    testImage.setRGB(2, 1, 0xFFFFFFFF);

    testImage.setRGB(0, 2, 0xFFFFFFFF);
    testImage.setRGB(1, 2, 0xFFFFFFFF);

    testImage.setRGB(0, 3, 0xFFFFFFFF);

    MultiSpectral<ImageFloat32> inputImage = ConvertBufferedImage.convertFromMulti(testImage, null, true, ImageFloat32.class);

    extended.set(9, inputImage);

    // we start from the right most pixel which can fill it indirectly
    boolean[] entryPixelsForTest = new boolean[8];
    entryPixelsForTest[4] = true;

    ProcessFractalFiller.FillContext fillContext = new ProcessFractalFiller.FillContext();

    extended.scanGridCell(new Vector2d<>(0, 0), new Vector2d<>(0, 1), entryPixelsForTest, fillContext);
}
 
开发者ID:PtrMan,项目名称:symVision,代码行数:51,代码来源:ProcessFractalFillerTest.java

示例10: process

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void process( final BufferedImage image ) {
	input.reshape(image.getWidth(),image.getHeight());
	output.reshape(image.getWidth(),image.getHeight());

	ConvertBufferedImage.convertFromMulti(image, input, ImageFloat32.class);

	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			setInputImage(image);
			doRefreshAll();
		}});
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:13,代码来源:ShowColorModelApp.java

示例11: showSelectedColor

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
 * Selectively displays only pixels which have a similar hue and saturation values to what is provided.
 * This is intended to be a simple example of color based segmentation.  Color based segmentation can be done
 * in RGB color, but is more problematic.  More robust techniques can use Gaussian
 * models.
 */
public static void showSelectedColor( String name , BufferedImage image , float hue , float saturation ) {
	MultiSpectral<ImageFloat32> input = ConvertBufferedImage.convertFromMulti(image,null,ImageFloat32.class);
	MultiSpectral<ImageFloat32> hsv = new MultiSpectral<ImageFloat32>(ImageFloat32.class,input.width,input.height,3);

	// Ensure the the bands are in RGB order
	ConvertBufferedImage.orderBandsIntoRGB(input,image);

	// Convert into HSV
	ColorHsv.rgbToHsv_F32(input,hsv);

	// Pixels which are more than this different from the selected color are set to black
	float maxDist2 = 0.4f*0.4f;

	// Extract hue and saturation bands which are independent of intensity
	ImageFloat32 H = hsv.getBand(0);
	ImageFloat32 S = hsv.getBand(1);

	// Adjust the relative importance of Hue and Saturation
	float adjustUnits = (float)(Math.PI/2.0);

	// step through each pixel and mark how close it is to the selected color
	BufferedImage output = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB);
	for( int y = 0; y < hsv.height; y++ ) {
		for( int x = 0; x < hsv.width; x++ ) {
			// remember Hue is an angle in radians, so simple subtraction doesn't work
			float dh = UtilAngle.dist(H.unsafe_get(x,y),hue);
			float ds = (S.unsafe_get(x,y)-saturation)*adjustUnits;

			// this distance measure is a bit naive, but good enough for this demonstration
			float dist2 = dh*dh + ds*ds;
			if( dist2 <= maxDist2 ) {
				output.setRGB(x,y,image.getRGB(x,y));
			}
		}
	}

	ShowImages.showWindow(output,"Showing "+name);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:45,代码来源:ExampleSegmentColor.java

示例12: main

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void main( String args[] ) {
	BufferedImage input = UtilImageIO.loadImage("../data/applet/road/left01.png");

	MultiSpectral<ImageUInt8> imageRGB = ConvertBufferedImage.convertFromMulti(input, null, ImageUInt8.class);
	ConvertBufferedImage.orderBandsIntoRGB(imageRGB,input);

	StereoParameters stereoParam = BoofMiscOps.loadXML("../data/applet/road/stereo01.xml");
	Se3_F64 groundToLeft = BoofMiscOps.loadXML("../data/applet/road/ground_to_left_01.xml");

	CreateSyntheticOverheadView<MultiSpectral<ImageUInt8>> generateOverhead =
			new CreateSyntheticOverheadViewMS<ImageUInt8>(TypeInterpolate.BILINEAR,3,ImageUInt8.class);

	// size of cells in the overhead image in world units
	double cellSize = 0.05;

	// You can use this to automatically select reasonable values for the overhead image
	SelectOverheadParameters selectMapSize = new SelectOverheadParameters(cellSize,20,0.5);
	selectMapSize.process(stereoParam.left,groundToLeft);

	int overheadWidth = selectMapSize.getOverheadWidth();
	int overheadHeight = selectMapSize.getOverheadHeight();

	MultiSpectral<ImageUInt8> overheadRGB =
			new MultiSpectral<ImageUInt8>(ImageUInt8.class,overheadWidth,overheadHeight,3);
	generateOverhead.configure(stereoParam.left,groundToLeft,
			selectMapSize.getCenterX(), selectMapSize.getCenterY(), cellSize,overheadRGB.width,overheadRGB.height);

	generateOverhead.process(imageRGB, overheadRGB);

	// note that the left/right values are swapped in the overhead image.  This is an artifact of the plane's
	// 2D coordinate system having +y pointing up, while images have +y pointing down.
	BufferedImage output = ConvertBufferedImage.convertTo(overheadRGB,null);

	ShowImages.showWindow(input,"Input Image");
	ShowImages.showWindow(output,"Overhead Image");
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:37,代码来源:ExampleOverheadView.java

示例13: main

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void main( String args[] ) {
	String calibDir = "../data/applet/calibration/mono/Sony_DSC-HX5V_Chess/";
	String imageDir = "../data/evaluation/structure/";

	// load calibration parameters from the previously calibrated camera
	IntrinsicParameters param = BoofMiscOps.loadXML(calibDir + "intrinsic.xml");

	// load images and convert the image into a color BoofCV format
	BufferedImage orig = UtilImageIO.loadImage(imageDir + "dist_cyto_01.jpg");
	MultiSpectral<ImageFloat32> distortedImg = ConvertBufferedImage.convertFromMulti(orig, null, ImageFloat32.class);
	ConvertBufferedImage.orderBandsIntoRGB(distortedImg,orig);

	// compute the transform to remove lens distortion
	// The inverse transformation (adds distortion) is used when apply adjusting an image.
	// In other application the forward transformation (removes distortion) is required.
	PointTransform_F32 tran = LensDistortionOps.transformPixelToRadial_F32(param);

	// create new transforms to optimize view area
	// After distortion the adjusted intrinsic camera parameters should be used.
	// Since they are not being used in this example null is passed in.
	PointTransform_F32 fullView = LensDistortionOps.fullView(param, null);
	PointTransform_F32 allInside = LensDistortionOps.allInside(param, null);

	// Set up image distort
	InterpolatePixel<ImageFloat32> interp = FactoryInterpolation.bilinearPixel(ImageFloat32.class);
	ImageDistort<ImageFloat32> distort = FactoryDistort.distort(interp,null,ImageFloat32.class);

	// render and display the different types of views in a window
	displayResults(orig, distortedImg, tran, fullView, allInside, distort);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:31,代码来源:ExampleRemoveLensDistortion.java

示例14: main

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void main( String args[] ) {
	BufferedImage image = UtilImageIO.loadImage("../data/applet/sunflowers.jpg");

	// Convert input image into a BoofCV RGB image
	MultiSpectral<ImageFloat32> rgb = ConvertBufferedImage.convertFromMulti(image, null, ImageFloat32.class);
	ConvertBufferedImage.orderBandsIntoRGB(rgb,image);

	//---- convert RGB image into different color formats
	MultiSpectral<ImageFloat32> hsv = new MultiSpectral<ImageFloat32>(ImageFloat32.class,rgb.width,rgb.height,3);
	ColorHsv.rgbToHsv_F32(rgb, hsv);

	MultiSpectral<ImageFloat32> yuv = new MultiSpectral<ImageFloat32>(ImageFloat32.class,rgb.width,rgb.height,3);
	ColorYuv.yuvToRgb_F32(rgb, yuv);

	//---- Convert individual pixels into different formats
	float[] pixelHsv = new float[3];
	ColorHsv.rgbToHsv(10,50.6f,120,pixelHsv);
	System.out.printf("Found RGB->HSV = %5.2f %5.3f %5.1f\n",pixelHsv[0],pixelHsv[1],pixelHsv[2]);

	float[] pixelRgb = new float[3];
	ColorHsv.hsvToRgb(pixelHsv[0],pixelHsv[1],pixelHsv[2],pixelRgb);
	System.out.printf("Found HSV->RGB = %5.1f %5.1f %5.1f expected 10 50.6 120\n",
			pixelRgb[0],pixelRgb[1],pixelRgb[2]);

	float[] pixelYuv = new float[3];
	ColorYuv.rgbToYuv(10,50.6f,120,pixelYuv);
	System.out.printf("Found RGB->YUV = %5.1f %5.1f %5.1f\n",pixelYuv[0],pixelYuv[1],pixelYuv[2]);

	ColorYuv.yuvToRgb(pixelYuv[0],pixelYuv[1],pixelYuv[2],pixelRgb);
	System.out.printf("Found YUV->RGB = %5.1f %5.1f %5.1f expected 10 50.6 120\n",
			pixelRgb[0],pixelRgb[1],pixelRgb[2]);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:33,代码来源:ExampleColorSpace.java

示例15: next

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
@Override
public T next() {
	try {
		imageGUI = ImageIO.read(new ByteArrayInputStream(jpegData.get(index)));
	} catch (IOException e) {
		throw new RuntimeException(e);
	}

	if(forward) {
		index++;
		if( loop && index >= jpegData.size() ) {
			index = jpegData.size()-1;
			forward = false;
		}
	} else {
		index--;
		if( loop && index < 0) {
			index = 1;
			forward = true;
		}
	}

	output.reshape(imageGUI.getWidth(),imageGUI.getHeight());
	switch( imageType.getFamily()) {
		case SINGLE_BAND:
			ConvertBufferedImage.convertFromSingle(imageGUI, (ImageSingleBand)output, imageType.getDataType().getImageClass());
		break;

		case MULTI_SPECTRAL:
			ConvertBufferedImage.convertFromMulti(imageGUI, (MultiSpectral) output, imageType.getDataType().getImageClass());
			ConvertBufferedImage.orderBandsIntoRGB((MultiSpectral) output,imageGUI);
			break;

		default:
			throw new RuntimeException("Not supported yet: "+imageType.getFamily());
	}

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


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