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


Java ConvertBufferedImage.orderBandsIntoRGB方法代码示例

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


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

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

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

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

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

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

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

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

示例8: configure

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void configure( final BufferedImage orig , IntrinsicParameters param )
{
	this.param = param;

	// distorted image
	dist = ConvertBufferedImage.convertFromMulti(orig, null, ImageFloat32.class);
	ConvertBufferedImage.orderBandsIntoRGB(dist,orig);

	// storage for undistorted image
	undist = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
			dist.getWidth(),dist.getHeight(),dist.getNumBands());

	// show results and draw a horizontal line where the user clicks to see rectification easier
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			gui.reset();
			gui.addItem(new ImagePanel(orig), "Original");
		}
	});

	// add different types of adjustments
	PointTransform_F32 tran = LensDistortionOps.transformPixelToRadial_F32(param);
	addUndistorted("No Adjustment", tran);
	PointTransform_F32 allInside = LensDistortionOps.allInside(param, null);
	addUndistorted("All Inside", allInside);
	PointTransform_F32 fullView = LensDistortionOps.fullView(param, null);
	addUndistorted("Full View", fullView);

	hasProcessed = true;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:31,代码来源:RemoveLensDistortionApp.java

示例9: process

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void process(BufferedImage image) {
	setInputImage(image);

	color.reshape(image.getWidth(),image.getHeight());
	ConvertBufferedImage.convertFromMulti(image,color,imageType);
	ConvertBufferedImage.orderBandsIntoRGB(color,image);

	hasProcessed = true;
	doRefreshAll();
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:11,代码来源:EvaluateInterpolateEnlargeApp.java

示例10: rectify

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
/**
	 * Rectifies the image using the provided fundamental matrix.  Both the fundamental matrix
	 * and set of inliers need to be accurate.  Small errors will cause large distortions.
	 *
	 * @param F Fundamental matrix
	 * @param inliers Set of associated pairs between the two images.
	 * @param origLeft Original input image.  Used for output purposes.
	 * @param origRight Original input image.  Used for output purposes.
	 */
	public static void rectify( DenseMatrix64F F , List<AssociatedPair> inliers ,
								BufferedImage origLeft , BufferedImage origRight ) {
		// distorted images
		MultiSpectral<ImageFloat32> distLeft = ConvertBufferedImage.convertFromMulti(origLeft, null, ImageFloat32.class);
		MultiSpectral<ImageFloat32> distRight = ConvertBufferedImage.convertFromMulti(origRight, null, ImageFloat32.class);

		// storage for rectified images
		MultiSpectral<ImageFloat32> rectLeft = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
				distLeft.getWidth(),distLeft.getHeight(),distLeft.getNumBands());
		MultiSpectral<ImageFloat32> rectRight = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
				distRight.getWidth(),distRight.getHeight(),distRight.getNumBands());
		ConvertBufferedImage.orderBandsIntoRGB(distLeft,origLeft);
		ConvertBufferedImage.orderBandsIntoRGB(distRight,origRight);

		// Compute rectification
		RectifyFundamental rectifyAlg = RectifyImageOps.createUncalibrated();

		rectifyAlg.process(F,inliers,origLeft.getWidth(),origLeft.getHeight());

		// rectification matrix for each image
		DenseMatrix64F rect1 = rectifyAlg.getRect1();
		DenseMatrix64F rect2 = rectifyAlg.getRect2();

		// Adjust the rectification to make the view area more useful
		RectifyImageOps.fullViewLeft(origLeft.getWidth(),origLeft.getHeight(), rect1, rect2 );
//		RectifyImageOps.allInsideLeft(origLeft.getWidth(),origLeft.getHeight(), rect1, rect2 );

		// undistorted and rectify images
		ImageDistort<ImageFloat32> imageDistortLeft =
				RectifyImageOps.rectifyImage(rect1,ImageFloat32.class);
		ImageDistort<ImageFloat32> imageDistortRight =
				RectifyImageOps.rectifyImage(rect2,ImageFloat32.class);

		DistortImageOps.distortMS(distLeft, rectLeft, imageDistortLeft);
		DistortImageOps.distortMS(distRight, rectRight, imageDistortRight);

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

		// show results and draw a horizontal line where the user clicks to see rectification easier
		// Don't worry if the image appears upside down
		ShowImages.showWindow(new RectifiedPairPanel(true, outLeft,outRight),"Rectified");
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:54,代码来源:ExampleRectifyUncalibratedStereo.java

示例11: main

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void main( String args[] ) {
		String dir = "../data/applet/calibration/stereo/Bumblebee2_Chess/";

		StereoParameters param = BoofMiscOps.loadXML(dir+"stereo.xml");

		// load images
		BufferedImage origLeft = UtilImageIO.loadImage(dir+"left05.jpg");
		BufferedImage origRight = UtilImageIO.loadImage(dir+"right05.jpg");

		// distorted images
		MultiSpectral<ImageFloat32> distLeft = ConvertBufferedImage.convertFromMulti(origLeft, null, ImageFloat32.class);
		MultiSpectral<ImageFloat32> distRight = ConvertBufferedImage.convertFromMulti(origRight, null, ImageFloat32.class);
		ConvertBufferedImage.orderBandsIntoRGB(distLeft,origLeft);
		ConvertBufferedImage.orderBandsIntoRGB(distRight,origRight);

		// storage for undistorted + rectified images
		MultiSpectral<ImageFloat32> rectLeft = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
				distLeft.getWidth(),distLeft.getHeight(),distLeft.getNumBands());
		MultiSpectral<ImageFloat32> rectRight = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
				distRight.getWidth(),distRight.getHeight(),distRight.getNumBands());

		// Compute rectification
		RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated();
		Se3_F64 leftToRight = param.getRightToLeft().invert(null);

		// original camera calibration matrices
		DenseMatrix64F K1 = PerspectiveOps.calibrationMatrix(param.getLeft(), null);
		DenseMatrix64F K2 = PerspectiveOps.calibrationMatrix(param.getRight(), null);

		rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight);

		// rectification matrix for each image
		DenseMatrix64F rect1 = rectifyAlg.getRect1();
		DenseMatrix64F rect2 = rectifyAlg.getRect2();
		// New calibration matrix,
		// Both cameras have the same one after rectification.
		DenseMatrix64F rectK = rectifyAlg.getCalibrationMatrix();

		// Adjust the rectification to make the view area more useful
		RectifyImageOps.fullViewLeft(param.left, rect1, rect2, rectK);
//		RectifyImageOps.allInsideLeft(param.left, leftHanded, rect1, rect2, rectK);

		// undistorted and rectify images
		ImageDistort<ImageFloat32> imageDistortLeft =
				RectifyImageOps.rectifyImage(param.getLeft(), rect1, ImageFloat32.class);
		ImageDistort<ImageFloat32> imageDistortRight =
				RectifyImageOps.rectifyImage(param.getRight(), rect2, ImageFloat32.class);

		DistortImageOps.distortMS(distLeft, rectLeft, imageDistortLeft);
		DistortImageOps.distortMS(distRight, rectRight, imageDistortRight);

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

		// show results and draw a horizontal line where the user clicks to see rectification easier
		ListDisplayPanel panel = new ListDisplayPanel();
		panel.addItem(new RectifiedPairPanel(true, origLeft, origRight), "Original");
		panel.addItem(new RectifiedPairPanel(true, outLeft, outRight), "Rectified");

		ShowImages.showWindow(panel,"Stereo Rectification Calibrated");
	}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:63,代码来源:ExampleRectifyCalibratedStereo.java

示例12: main

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public static void main( String args[] ) throws IOException {
	String baseDir = "../data/applet/kinect/basket/";

	String nameRgb = baseDir+"basket_rgb.png";
	String nameDepth = baseDir+"basket_depth.png";
	String nameCalib = baseDir+"visualdepth.xml";

	VisualDepthParameters param = BoofMiscOps.loadXML(nameCalib);

	BufferedImage buffered = UtilImageIO.loadImage(nameRgb);
	MultiSpectral<ImageUInt8> rgb = ConvertBufferedImage.convertFromMulti(buffered,null,ImageUInt8.class);
	ConvertBufferedImage.orderBandsIntoRGB(rgb,buffered);
	ImageUInt16 depth =
			ConvertBufferedImage.convertFrom(UtilImageIO.loadImage(nameDepth),null,ImageUInt16.class);

	FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class,true);
	FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);

	VisualDepthOps.depthTo3D(param.visualParam, rgb, depth, cloud, cloudColor);

	DenseMatrix64F K = PerspectiveOps.calibrationMatrix(param.visualParam,null);

	PointCloudViewer viewer = new PointCloudViewer(K,10);
	viewer.setPreferredSize(new Dimension(rgb.width,rgb.height));

	for( int i = 0; i < cloud.size; i++ ) {
		Point3D_F64 p = cloud.get(i);
		int[] color = cloudColor.get(i);
		int c = (color[0] << 16 ) | (color[1] << 8) | color[2];
		viewer.addPoint(p.x,p.y,p.z,c);
	}

	// ---------- Display depth image
	// use the actual max value in the image to maximize its appearance
	int maxValue = ImageStatistics.max(depth);
	BufferedImage depthOut = VisualizeImageData.disparity(depth, null, 0, maxValue, 0);
	ShowImages.showWindow(depthOut,"Depth Image");

	// ---------- Display colorized point cloud
	ShowImages.showWindow(viewer,"Point Cloud");
	System.out.println("Total points = "+cloud.size);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:43,代码来源:ExampleDepthPointCloud.java

示例13: configure

import boofcv.core.image.ConvertBufferedImage; //导入方法依赖的package包/类
public void configure( final BufferedImage origLeft , final BufferedImage origRight , StereoParameters param )
{
	this.param = param;

	// distorted images
	distLeft = ConvertBufferedImage.convertFromMulti(origLeft, null, ImageFloat32.class);
	distRight = ConvertBufferedImage.convertFromMulti(origRight, null, ImageFloat32.class);
	ConvertBufferedImage.orderBandsIntoRGB(distLeft,origLeft);
	ConvertBufferedImage.orderBandsIntoRGB(distRight,origRight);

	// storage for undistorted + rectified images
	rectLeft = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
			distLeft.getWidth(),distLeft.getHeight(),distLeft.getNumBands());
	rectRight = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
			distRight.getWidth(),distRight.getHeight(),distRight.getNumBands());

	// Compute rectification
	RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated();
	Se3_F64 leftToRight = param.getRightToLeft().invert(null);

	// original camera calibration matrices
	DenseMatrix64F K1 = PerspectiveOps.calibrationMatrix(param.getLeft(), null);
	DenseMatrix64F K2 = PerspectiveOps.calibrationMatrix(param.getRight(), null);

	rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight);

	// rectification matrix for each image
	DenseMatrix64F rect1 = rectifyAlg.getRect1();
	DenseMatrix64F rect2 = rectifyAlg.getRect2();
	DenseMatrix64F rectK = rectifyAlg.getCalibrationMatrix();

	// show results and draw a horizontal line where the user clicks to see rectification easier
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			gui.reset();
			gui.addItem(new RectifiedPairPanel(true, origLeft, origRight), "Original");
		}
	});

	// add different types of adjustments
	addRectified("No Adjustment", rect1,rect2);
	RectifyImageOps.allInsideLeft(param.left, rect1, rect2, rectK);
	addRectified("All Inside", rect1,rect2);
	RectifyImageOps.fullViewLeft(param.left, rect1, rect2, rectK);
	addRectified("Full View", rect1,rect2);

	hasProcessed = true;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:49,代码来源:ShowRectifyCalibratedApp.java


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