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

Java ColourSpace类代码示例

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

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



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

示例1: actionPerformed

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	final String rawcmd = e.getActionCommand();
	final String cmd = rawcmd.substring(rawcmd.indexOf(".") + 1);

	if (rawcmd.startsWith("ColourSpace.")) {
		// change the colour space to the one selected
		this.colourSpace = ColourSpace.valueOf(cmd);
		this.classes.clear();
		this.points.clear();
	} else if (rawcmd.startsWith("button.")) {
		if (cmd.equals("learn")) {
			doLearn(lastMean, this.classType.getSelectedIndex());
		}
	}
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:17,代码来源:LinearClassifierDemo.java


示例2: getComponent

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
@Override
public JPanel getComponent(int width, int height) throws IOException {
	final JPanel base = super.getComponent(width, height);

	// add a listener for new video frames
	vc.getDisplay().addVideoListener(this);

	// the controls panel
	final JPanel controlsPanel = new JPanel(new GridLayout(0, 1));
	controlsPanel.setOpaque(false);
	final ButtonGroup group = new ButtonGroup();

	for (final ColourSpace c : colourSpaces)
		createRadioButton(controlsPanel, group, c);

	base.add(controlsPanel);

	return base;
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:20,代码来源:ColourSpacesDemo.java


示例3: convertColours

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * Convert the colour space of an image, maintaining three bands so it can
 * be displayed
 *
 * @param frame
 * @param colourSpace
 */
public static void convertColours(MBFImage frame, ColourSpace colourSpace) {
	// update the frame from the camera by converting to the selected colour
	// space before display
	final MBFImage cvt = colourSpace.convert(frame);

	// if the converted image has fewer than 3 bands, add more so it can be
	// displayed as RGB.
	if (cvt.numBands() == 1) {
		// this makes a three-band grey-level image, where all the bands are
		// the same
		cvt.bands.add(cvt.getBand(0).clone());
		cvt.bands.add(cvt.getBand(0).clone());
	} else if (cvt.numBands() == 2) {
		// this adds a third zero band to a two-band image
		cvt.bands.add(new FImage(cvt.getWidth(), cvt.getHeight()));
	}

	// this sets the frame to the colour converted version
	frame.internalAssign(cvt);
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:28,代码来源:ColourSpacesDemo.java


示例4: makeVideo

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
AnimatedVideo<MBFImage> makeVideo(final Scene scene) {
	return new AnimatedVideo<MBFImage>(new MBFImage(500, 500, ColourSpace.RGB)) {
		float angle = 0;

		@Override
		protected void updateNextFrame(MBFImage frame) {
			frame.fill(RGBColour.BLACK);
			scene.renderOrtho(
					Simple3D.euler2Rot(Math.PI / 4, angle, 0),
					frame);
			angle += (2 * Math.PI / 360);
			if (angle >= Math.PI * 2)
				angle -= 2 * Math.PI;
		}
	};
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:17,代码来源:PCADemo.java


示例5: plot2d

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
MBFImage plot2d(double[][] data) {
	final MBFImage img = new MBFImage(500, 500, ColourSpace.RGB);

	img.drawLine(img.getWidth() / 2, img.getHeight() - 50, img.getWidth() / 2, 50, 3, RGBColour.RED);
	img.drawLine(img.getWidth() / 2 - 10, 70, img.getWidth() / 2, 50, 3, RGBColour.RED);
	img.drawLine(img.getWidth() / 2 + 10, 70, img.getWidth() / 2, 50, 3, RGBColour.RED);
	img.drawText("EV2", img.getWidth() / 2 - 80, 70, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);

	img.drawLine(50, img.getHeight() / 2, img.getWidth() - 50, img.getHeight() / 2, 3, RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 + 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 - 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawText("EV1", img.getWidth() - 70, img.getHeight() / 2 + 50, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);

	for (final double[] d : data) {
		img.drawPoint(new Point2dImpl(img.getWidth() / 2 - (float) d[0], img.getHeight() / 2 - (float) d[1]),
				RGBColour.GREEN, 3);
	}

	return img;
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:23,代码来源:PCADemo.java


示例6: plot1d

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
MBFImage plot1d(double[][] data) {
	final MBFImage img = new MBFImage(500, 500, ColourSpace.RGB);

	img.drawLine(50, img.getHeight() / 2, img.getWidth() - 50, img.getHeight() / 2, 3, RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 + 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 - 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawText("EV1", img.getWidth() - 70, img.getHeight() / 2 + 50, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);

	for (final double[] d : data) {
		img.drawPoint(new Point2dImpl(img.getWidth() / 2 - (float) d[0], img.getHeight() / 2),
				RGBColour.GREEN, 3);
	}

	return img;
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:18,代码来源:PCADemo.java


示例7: MSEREllipseFinder

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * Construct demo
 */
public MSEREllipseFinder() {
	final MBFImage image = new MBFImage(400, 400, ColourSpace.RGB);
	final MBFImageRenderer renderer = image.createRenderer();

	image.fill(RGBColour.WHITE);
	final List<Ellipse> ellipses = new ArrayList<Ellipse>();
	ellipses.add(new Ellipse(200, 100, 100, 80, Math.PI / 4));
	ellipses.add(new Ellipse(200, 300, 50, 30, -Math.PI / 4));
	ellipses.add(new Ellipse(100, 300, 30, 50, -Math.PI / 3));

	for (final Ellipse ellipse : ellipses) {
		renderer.drawShapeFilled(ellipse, RGBColour.BLACK);
	}

	final MSERFeatureGenerator mser = new MSERFeatureGenerator(MomentFeature.class);
	final List<Component> features = mser.generateMSERs(Transforms
			.calculateIntensityNTSC(image));
	for (final Component c : features) {
		final MomentFeature feature = c.getFeature(MomentFeature.class);
		renderer.drawShape(feature.getEllipse(2), RGBColour.RED);
		renderer.drawShape(feature.getEllipse(2)
				.calculateOrientedBoundingBox(), RGBColour.GREEN);
	}
	DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:MSEREllipseFinder.java


示例8: main

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * 	Default main
 *  @param args Command-line arguments
 */
public static void main(String args[]){
	ellipse = new Ellipse(400,400,100,50,0);
	image = new MBFImage(800,800,ColourSpace.RGB);
	frame = DisplayUtilities.display(image);
	displayUpdater = new Runnable(){
		@Override
		public void run() {
			while(true){
				DisplayUtilities.display(image,frame);
				update();
				try {
					Thread.sleep(1000/30);
				} catch (InterruptedException e) {
				}
			}
		}
		
	};
	Thread t = new Thread(displayUpdater);
	t.start();
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:TestShapeTransforms.java


示例9: buildBinCols

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
void buildBinCols() {
	this.binCols = new Float[4 * 4 * 4][];
	for (int k = 0; k < 4; k++) {
		for (int j = 0; j < 4; j++) {
			for (int i = 0; i < 4; i++) {
				final float h = (float) i / 4 + (0.5f / 4);
				final float s = (float) j / 4 + (0.5f / 4);
				final float v = (float) k / 4 + (0.5f / 4);

				MBFImage img = new MBFImage(1, 1, ColourSpace.HSV);
				img.setPixel(0, 0, new Float[] { h, s, v });

				img = Transforms.HSV_TO_RGB(img);

				this.binCols[k * 4 * 4 + j * 4 + i] = img.getPixel(0, 0);
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:VideoFeatureExtraction.java


示例10: doTutorial

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
	final MBFImage space = ColourSpace.convert(toDraw, ColourSpace.CIE_Lab);

	if (cluster == null)
		cluster = clusterPixels(space);

	if (cluster == null)
		return;

	final float[][] centroids = cluster.getCentroids();

	final ExactFloatAssigner assigner = new ExactFloatAssigner(cluster);

	for (int y = 0; y < space.getHeight(); y++) {
		for (int x = 0; x < space.getWidth(); x++) {
			final float[] pixel = space.getPixelNative(x, y);
			final int centroid = assigner.assign(pixel);
			space.setPixelNative(x, y, centroids[centroid]);
		}
	}

	toDraw.internalAssign(ColourSpace.convert(space, ColourSpace.RGB));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:SegmentationTutorial.java


示例11: drawMkpLine

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
private static void drawMkpLine(DoubleArrayKernelPerceptron mkp) {
	final MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);

	final List<double[]> sup = mkp.getSupports();
	final List<Double> weights = mkp.getWeights();
	final double bias = mkp.getBias();
	System.out.println("Bias: " + bias);
	double[] startD = null;
	double[] endD = null;

	double[] mean = new double[2];
	if (mkp instanceof MeanCenteredKernelPerceptron) {
		mean = ((MeanCenteredKernelPerceptron) mkp).getMean();
	} else if (mkp instanceof MeanCenteredProjectron) {
		mean = ((MeanCenteredProjectron) mkp).getMean();
	}
	startD = LinearVectorKernel.getPlanePoint(sup, weights, bias, -mean[0], Double.NaN);
	endD = LinearVectorKernel.getPlanePoint(sup, weights, bias, img.getWidth() - mean[0], Double.NaN);
	startD[0] += mean[0];
	startD[1] += mean[1];
	endD[0] += mean[0];
	endD[1] += mean[1];
	drawLine(img, startD, endD);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:DrawLinearData.java


示例12: drawPoints

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
private static void drawPoints(Stream<IndependentPair<double[], PerceptronClass>> dataStream, Line2d line) {
	final MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);

	img.drawLine(line, 3, RGBColour.BLUE);

	for (final IndependentPair<double[], PerceptronClass> pointClass : dataStream) {

		final double[] pc = pointClass.firstObject();
		final Point2dImpl point = new Point2dImpl((float) pc[0], (float) pc[1]);
		final PerceptronClass cls = pointClass.getSecondObject();
		switch (cls) {
		case TRUE:
			img.drawShapeFilled(new Circle(point, 5), RGBColour.GREEN);
			break;
		case FALSE:
			img.drawShape(new Circle(point, 5), 3, RGBColour.RED);
			break;
		case NONE:
			throw new RuntimeException("NOPE");
		}
	}
	DisplayUtilities.displayName(img, "random");
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:DrawLinearData.java


示例13: main

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 *
 *	@param args
 *	@throws MalformedURLException
 *	@throws IOException
 */
public static void main( final String[] args ) throws MalformedURLException, IOException
{
	final MBFImage img1 = ImageUtilities.readMBF( new URL("http://www.walkmag.co.uk/wp-content/uploads/2012/05/Wineglass_Bay-landscape.jpg") );
	final MBFImage img2 = ImageUtilities.readMBFAlpha( new URL("http://www.openimaj.org/images/OpenImaj.png") );
	final MBFImage img3 = ImageUtilities.readMBF( new URL("http://sd.keepcalm-o-matic.co.uk/i/keep-calm-and-rule-the-world-19.png") );

	final FImage alpha = img3.clone().threshold( 0.7f ).flatten().inverse().
		multiplyInplace( 0.4f ).inverse().addInplace( 0.6f );
	img3.addBand( alpha );
	img3.colourSpace = ColourSpace.RGBA;
	img2.colourSpace = ColourSpace.RGBA;

	img1.drawImage( img2, 1400, 50 );
	img1.drawImage( img3, 800, 100 );

	DisplayUtilities.display( img1 );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:AlphaCompositeTest.java


示例14: main

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
public static void main(String[] args) {
	final MBFImage image = new MBFImage(400, 400, ColourSpace.RGB);
	final MBFImageRenderer renderer = image.createRenderer();

	image.fill(RGBColour.BLACK);
	final List<Ellipse> ellipses = new ArrayList<Ellipse>();
	ellipses.add(new Ellipse(200, 100, 10, 8, Math.PI / 4));
	ellipses.add(new Ellipse(200, 300, 5, 3, -Math.PI / 4));
	ellipses.add(new Ellipse(100, 300, 3, 5, -Math.PI / 3));

	for (final Ellipse ellipse : ellipses) {
		renderer.drawShapeFilled(ellipse, RGBColour.WHITE);
	}

	final LOCKY locky = new LOCKY();
	locky.findInterestPoints(image.flatten());
	final List<EllipticInterestPointData> pts = locky.getInterestPoints();
	for (final EllipticInterestPointData pt : pts) {
		image.drawShape(pt.getEllipse(), RGBColour.RED);
	}

	DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:LOCKY.java


示例15: main

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * Main method
 * 
 * @param args
 */
public static void main(String[] args) {
	// Create an image
	final MBFImage image = new MBFImage(320, 70, ColourSpace.RGB);

	// Fill the image with white
	image.fill(RGBColour.WHITE);

	// Render some test into the image
	image.drawText("Hello World", 10, 60, HersheyFont.CURSIVE, 50, RGBColour.BLACK);

	// Apply a Gaussian blur
	image.processInplace(new FGaussianConvolve(2f));

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


示例16: draw

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * @param params
 * @return draw the plot
 */
public MBFImage draw(TernaryParams params) {

	final int padding = (Integer) params.getTyped(TernaryParams.PADDING);
	final Float[] bgColour = params.getTyped(TernaryParams.BG_COLOUR);

	final MBFImage ret = new MBFImage((int) width + padding * 2, (int) height + padding * 2, ColourSpace.RGB);
	ret.fill(bgColour);
	drawTernaryPlot(ret, params);
	drawTriangle(ret, params);
	drawBorder(ret, params);
	drawScale(ret, params);
	drawLabels(ret, params);

	return ret;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:TernaryPlot.java


示例17: convertFromFB

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * Convert packed RGBA pixels in a {@link FloatBuffer} back into an
 * {@link MBFImage}. The method takes the {@link MBFImage} as an argument, and
 * will fill it accordingly. If the image argument is null, a new
 * {@link MBFImage} with the RGBA {@link ColourSpace} will be created. 
 * If the given image is the wrong size, it will be resized. If the given
 * image has less than four bands, then only these bands will be filled. 
 * Any bands above the fourth will be ignored.  
 * 
 * @param fb the {@link FloatBuffer} containing the pixels 
 * @param width the width
 * @param height the height
 * @param image the image to write to or null
 * @return the image
 */
public static MBFImage convertFromFB(FloatBuffer fb, int width, int height, MBFImage image) {
	if (image == null)
		image = new MBFImage(width, height, ColourSpace.RGBA);
	
	if (image.getWidth() != width || image.getHeight() != height)
		image.internalAssign(image.newInstance(width, height));
	
	final FImage[] bands = image.bands.toArray(new FImage[image.numBands()]);

	final int nbands = Math.min(4, image.numBands());
	final int extraBands = 4 - nbands;
	
	for (int y=0; y<height; y++) {
		for (int x=0; x<width; x++) {
			for (int b=0; b<nbands; b++) { 
				bands[b].pixels[y][x] = fb.get();
			}
			for (int b=0; b<extraBands; b++) {
				fb.get();
			}
		}
	}

	return image;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:41,代码来源:CLImageConversion.java


示例18: main

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
public static void main( String[] args ) {
	//Create an image
    MBFImage image = new MBFImage(320,70, ColourSpace.RGB);

    //Fill the image with white
    image.fill(RGBColour.WHITE);
    		        
    //Render some test into the image
    image.drawText("Hello World", 10, 60, HersheyFont.CURSIVE, 50, RGBColour.BLACK);

    //Apply a Gaussian blur
    image.processInplace(new FGaussianConvolve(2f));
    
    //Display the image
    DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:App.java


示例19: detectFaces

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * 	Takes a single image and detects faces, returning a map that maps
 * 	a number (the face number) to the rectangle of the detected face.
 * 
 *  @param img The image to detect faces within
 *  @param minSize The minimum size a face is allowed to be
 *  @param displayResults Whether to display the result of detection
 *  @return A list of rectangles delineating the faces
 */
public List<DetectedFace> detectFaces( FImage img,
		int minSize, boolean displayResults )
{
	try
       {
        HaarCascadeDetector hcd = new HaarCascadeDetector("haarcascade_frontalface_alt.xml");
        hcd.setMinSize( minSize );
        
           List<DetectedFace> faces = hcd.detectFaces( img );
           if( displayResults )
           {
           	MBFImage m = new MBFImage( ColourSpace.RGB, img,img,img );
           	MBFImageRenderer renderer = m.createRenderer();
           	
           	for( DetectedFace df : faces )
           		renderer.drawShape( df.getBounds(), RGBColour.RED );
           	
           	DisplayUtilities.display( m );
           }
           
           return faces;
       }
       catch( Exception e )
       {
       	System.err.println( "Could not load HAAR Cascade." );
        e.printStackTrace();
       }
	
	return null;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:40,代码来源:FaceDetectorTool.java


示例20: makeDisparityMap

import org.openimaj.image.colour.ColourSpace; //导入依赖的package包/类
/**
 * Compute the disparity map between two images. If the images
 * are not in Lab colour space, then copies in lab space will
 * be created.
 * @param im1 The first image.
 * @param im2 The second image.
 * @return the disparity map between the colours in the two images.
 */
public static FImage makeDisparityMap(MBFImage im1, MBFImage im2) {
	if (im1.colourSpace != ColourSpace.CIE_Lab) {
		im1 = ColourSpace.convert(im1, ColourSpace.CIE_Lab);
	}
	
	if (im2.colourSpace != ColourSpace.CIE_Lab) {
		im2 = ColourSpace.convert(im2, ColourSpace.CIE_Lab);
	}
	
	FImage disparity = new FImage(im1.getWidth(), im1.getHeight());
	for (int y=0; y<disparity.height; y++) {
		for (int x=0; x<disparity.width; x++) {
			disparity.pixels[y][x] = calculateDeltaE(im1.getPixel(x, y), im2.getPixel(x, y));
		}
	}
	
	return disparity;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:CIEDE2000.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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