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


Java MBFImage.setPixel方法代码示例

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


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

示例1: buildBinCols

import org.openimaj.image.MBFImage; //导入方法依赖的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

示例2: buildBinCols

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
Float[][] buildBinCols(MultidimensionalHistogram feature) {
		Float[][] binCols = new Float[10*4*1][];
		double maxFeature = feature.max();
		if(maxFeature == 0) maxFeature = 1;
		for (int k=0; k<10; k++) {
			for (int j=0; j<4; j++) {
				float s = (float)j/4 + (0.5f/4);
				float h = (float)k/10 + (0.5f/10);
				
				MBFImage img = new MBFImage(1,1,ColourSpace.HSV);
				img.setPixel(0, 0, new Float[] {h,s,(float) (feature.get(k,j,0) / maxFeature)});
//				img.setPixel(0, 0, new Float[] {h,s,1f});
				
				img = Transforms.HSV_TO_RGB(img);
				
				binCols[j* 10 + k] = img.getPixel(0, 0);
			}
		}
		return binCols;
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:ColourHistogramGrid.java

示例3: constructDepthFrame

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private IndependentPair<FImage, MBFImage> constructDepthFrame() {
	FImage compiledDepth = null;
	MBFImage compiledRGB = null;
	for (IndependentPair<FImage, MBFImage> heldFrame : this.heldDepthFrames) {
		
		FImage heldDepth = heldFrame.firstObject();
		MBFImage heldRGB = heldFrame.secondObject();
		if(compiledDepth == null){
			
			compiledDepth = heldDepth.clone();
			compiledRGB = heldRGB .clone();
			continue;
		}
		
		for (int y = 0; y < heldDepth.height; y++) {
			for (int x = 0; x < heldDepth.width; x++) {
				if (compiledDepth.pixels[y][x] == 0 || (heldDepth.pixels[y][x] != 0 && compiledDepth.pixels[y][x] > heldDepth.pixels[y][x])) {
					compiledDepth.pixels[y][x] = heldDepth.pixels[y][x];
					compiledRGB.setPixel(x, y, heldRGB.getPixel(x, y));
				}
			}
		}
	}
	return IndependentPair.pair(compiledDepth, compiledRGB);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:KinectDepthSnapshot.java

示例4: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	if(learnMode){
		System.out.println("Adding frame");
		if(this.learningFrames.size()>5)
			this.learningFrames.remove(0);
		this.learningFrames.add(frame.process(new PolygonExtractionProcessor<Float[],MBFImage>(this.polygonListener.getPolygon(),RGBColour.BLACK)));
		
	}
	if(viewMode){
		FImage guess = this.hmodel.classifyImage(frame).normalise();
		FImage greyFrame = Transforms.calculateIntensity(frame);
		for(int y = 0; y < guess.height; y++){
			for(int x = 0; x < guess.width; x++){
				if(guess.pixels[y][x] < 0.1){
					Float greyP = greyFrame.getPixel(x, y);
					frame.setPixel(x, y, new Float[]{greyP,greyP,greyP});
				}
				
			}
		}
	}
	this.polygonListener.drawPoints(frame);
	
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:VideoPixelHistogram.java

示例5: drawTernaryPlot

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void drawTernaryPlot(MBFImage ret, TernaryParams params) {
	final ColourMap cm = params.getTyped(TernaryParams.COLOUR_MAP);
	final int padding = (Integer) params.getTyped(TernaryParams.PADDING);
	final Float[] bgColour = params.getTyped(TernaryParams.BG_COLOUR);
	for (int y = 0; y < height + padding; y++) {
		for (int x = 0; x < width + padding; x++) {
			final int xp = x - padding;
			final int yp = y - padding;
			final Point2dImpl point = new Point2dImpl(xp, yp);
			if (this.tri.isInside(point)) {
				final TernaryData closest = weightThreeClosest(point);
				Float[] apply = null;
				if (cm != null)
					apply = cm.apply(1 - closest.value);
				else {
					apply = new Float[] { closest.value, closest.value, closest.value };
				}

				ret.setPixel(x, y, apply);
			}
			else {
				ret.setPixel(x, y, bgColour);
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:TernaryPlot.java

示例6: ColourSpaceAnimator

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 *	Construct the animator using the start and end colours and a duration (milliseconds)
 *	@param start Start colour (RGB)
 *	@param end End colour (RGB)
 *	@param duration The duration (milliseconds)
 */
public ColourSpaceAnimator( final Float[] start, final Float[] end, final long duration )
{
	final MBFImage startImg = new MBFImage( 1, 1, 3 );
	startImg.setPixel( 0, 0, start );
	final MBFImage endImg = new MBFImage( 1, 1, 3 );
	this.buffer = new MBFImage( 1, 1, 3 );
	endImg.setPixel( 0, 0, end );

	System.out.println( "In buffer: "+Arrays.toString( end ) );
	System.out.println( "In buffer: "+Arrays.toString( endImg.getPixel( 0,0 ) ) );

	final Float[] labstart = this.colourspace.convertFromRGB( startImg ).getPixel( 0, 0 );
	final Float[] labend = this.colourspace.convertFromRGB( endImg ).getPixel( 0, 0 );

	this.c1 = new LinearTimeBasedFloatValueAnimator( labstart[0], labend[0], duration );
	this.c2 = new LinearTimeBasedFloatValueAnimator( labstart[1], labend[1], duration );
	this.c3 = new LinearTimeBasedFloatValueAnimator( labstart[2], labend[2], duration );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:ColourSpaceAnimator.java

示例7: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * 	Main method.
 *	@param args command-line args (unused)
 */
public static void main( final String[] args )
{
	// Create an image to fill
	final MBFImage swatchS1 = new MBFImage( 800, 800, 3 );

	// Loop over the image
	for( int y = 0; y < swatchS1.getHeight(); y++ ) {
		for( int x = 0; x < swatchS1.getWidth(); x++ ) {
			// Set the HSL coordinates
			final float[] hsl = new float[3];
			hsl[0] = x / (float)swatchS1.getWidth();
			hsl[1] = 1f;
			hsl[2] = 1 - (y / (float)swatchS1.getHeight());

			// Convert to RGB
			final float[] rgb = new float[3];
			Transforms.HSL_TO_RGB( hsl, rgb );

			// Set the pixel in the RGB image
			swatchS1.setPixel( x, y, new Float[]{ rgb[0], rgb[1], rgb[2] } );
		}
	}

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

示例8: LabColourAnimator

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public LabColourAnimator(final Float[] start, final Float[] end, final long duration) {
	final MBFImage startImg = new MBFImage(1,1,3);
	startImg.setPixel(0, 0, start);
	final MBFImage endImg = new MBFImage(1,1,3);
	this.buffer = new MBFImage(1,1,3);
	endImg.setPixel(0, 0, end);
	final Float[] labstart = this.space.convertFromRGB(startImg).getPixel(0, 0);
	final Float[] labend = this.space.convertFromRGB(endImg).getPixel(0, 0);
	this.l = new LinearTimeBasedFloatValueAnimator(labstart[0], labend[0], duration);
	this.a = new LinearTimeBasedFloatValueAnimator(labstart[1], labend[1], duration);
	this.b = new LinearTimeBasedFloatValueAnimator(labstart[2], labend[2], duration);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:13,代码来源:WorldVis.java

示例9: RGB_TO_RGB_NORMALISED

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Intensity normalisation
 * 
 * @param in
 *            RGB image
 * @return normalised RGB image
 */
public static MBFImage RGB_TO_RGB_NORMALISED(final MBFImage in) {
	final int r = in.getHeight();
	final int c = in.getWidth();
	final MBFImage out = new MBFImage(c, r, ColourSpace.RGB_INTENSITY_NORMALISED);
	final float max = (float) Math.sqrt(3);

	final float grey = (1.0f / max);
	for (int j = 0; j < r; j++) {
		for (int i = 0; i < c; i++) {
			final Float[] pixin = in.getPixel(i, j);

			if (pixin[0] == pixin[1] && pixin[1] == pixin[2] && pixin[0] == 0.0) {
				out.setPixel(i, j, new Float[] { grey, grey, grey });
			}
			else if (pixin[0] == pixin[1] && pixin[1] == pixin[2] && pixin[0] == 1.0) {
				out.setPixel(i, j, new Float[] { grey, grey, grey });
			}
			else {
				final float length = (float) Math.sqrt(pixin[0] * pixin[0] + pixin[1] * pixin[1] + pixin[2]
						* pixin[2]);
				out.setPixel(i, j, new Float[] { (pixin[0] / length), (pixin[1] / length), (pixin[2] / length) });
			}

		}
	}

	return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:Transforms.java

示例10: extractPixels1d

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Extract a 1xarea image with all the pixels from the region in it. Useful
 * for analysing the colour for example
 * 
 * @param input
 *            input image to extract samples from
 * @return new image with pixels set from samples
 */
public MBFImage extractPixels1d(MBFImage input) {
	final MBFImage out = new MBFImage(pixels.size(), 1, input.numBands());

	int j = 0;
	for (final Pixel p : pixels) {
		for (int i = 0; i < input.numBands(); i++) {
			out.setPixel(j, 0, input.getPixel(p.x, p.y));
		}
		j++;
	}

	return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:PixelSet.java

示例11: processFrame

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public MBFImage processFrame( final MBFImage frame )
{
	this.addToCache( frame );

	if( this.timemapImage == null || this.timemapImage.getWidth() != frame.getWidth() ||
			this.timemapImage.getHeight() != frame.getHeight() )
		this.needToFixTimemap = true;

	if( this.needToFixTimemap )
		this.fixTimemapImage( frame.getWidth(), frame.getHeight() );

	final int height = frame.getHeight();
	final int width = frame.getWidth();

	for( int y = 0; y < height; y++ )
	{
		for( int x = 0; x < width; x++ )
		{
			int index = (int)this.timemapImage.pixels[y][x];
			if( index >= this.cache.size() )
				index = this.cache.size()-1;

			final MBFImage cacheImage = this.cache.get( index );
			frame.setPixel( x, y, cacheImage.getPixel(x,y) );
		}
	}

	for( final FImage f : frame.bands )
	{
		FImageConvolveSeparable.convolveVertical( f, this.blurKern );
	}

	if( this.cache.size() >= this.cacheSize ) this.cache.removeLast();

	return frame;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:38,代码来源:GreyscaleSlitScanProcessor.java


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