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


Java FImage.setPixel方法代码示例

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


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

示例1: PowerCepstrumVis

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * 
 *	@param as
 *	@throws Exception
 */
public PowerCepstrumVis( AudioStream as ) throws Exception
   {
	FImage img = new FImage( 1000, 600 );

	PowerCepstrumTransform pct = new PowerCepstrumTransform();
	
	SampleChunk sc = null;
	while( (sc = as.nextSampleChunk()) != null )
	{
		pct.process( sc );
		float[][] c = pct.getLastCepstrum();
		for( int i = 0; i < c[0].length; i++ )
			img.setPixel( img.getWidth()-1, i, c[0][i]/50f );
		img.shiftLeftInplace();
		
		DisplayUtilities.displayName( img, "Power Cepstrum" );
	}
   }
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:PowerCepstrumVis.java

示例2: main

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
	 * Test the distance transform
	 * @param args
	 * @throws IOException
	 */
	public static void main(String args[]) throws IOException{
		FImage i = ImageUtilities.readF(new File("/Users/ss/Desktop/tache.jpg"));
		EuclideanDistanceTransform etrans = new EuclideanDistanceTransform();
//		i.processInplace(new CannyEdgeDetector());
		i.inverse();
		for(int x = 0;x < i.width; x++)
			for(int y = 0; y < i.height; y++) 
				if(i.pixels[y][x] == 1.0f) 
					i.setPixel(x, y, Float.MAX_VALUE);
		DisplayUtilities.display(i);
		i.analyseWith(etrans);
		i = etrans.getDistances();
		i.normalise();
		DisplayUtilities.display(i);
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:EuclideanDistanceTransform.java

示例3: extractEllipsePatch

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * Extract a rectangular image patch centered on the feature
 * with the same primary orientation and a given scale factor. 
 * @param image the image to extract from
 * @param sf the scale factor
 * @return a rectangular image patch
 */
public FImage extractEllipsePatch(FImage image, double sf) {
	double [] data = getEllipseBoundingRectsData(sf);
	double height = data[1], width = data[0], ori = data[2];		
	
	int sx = (int) Math.rint(width);
	int sy = (int) Math.rint(height);

	FImage patch = new FImage(sx, sy);

	//extract pixels
	for (int y=0; y<sy; y++) {
		for (int x=0; x<sx; x++) {
			double xbar = x - sx / 2.0;
			double ybar = y - sy / 2.0;

			double xx = (xbar * Math.cos(ori) - ybar * Math.sin(ori)) + mx;
			double yy = (xbar * Math.sin(ori) + ybar * Math.cos(ori)) + my;

			patch.setPixel(x, y, image.getPixelInterp(xx, yy));
		}
	}

	return patch;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:32,代码来源:MomentFeature.java

示例4: checkFingerWidth

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
   * This method checks whether evaluated average finger width is inside of
   * the given interval.
   * @param res
   * @param finger
   */
  public static void checkFingerWidth(FImage res, Finger finger) {
  	int avgFingerWidth = finger.getAvgWidth();
if (finger.getPlotMap().size() > 0) {
	for (Map.Entry<Pixel, Pixel> entry : finger.getPlotMap().entrySet()) {
	    Pixel key = entry.getKey();
	    Pixel value = entry.getValue();
	    if (avgFingerWidth*AVG_WIDTH_RATE < value.x - key.x) {
	    	res.setPixel(key.x, key.y, 0.0f);			    	
	    	res.setPixel(value.x, value.y, 0.0f);			    	
	    }
	}
}    	
  }
 
开发者ID:ait-ngcms,项目名称:ffma,代码行数:20,代码来源:FingerDetector.java

示例5: checkFingerOnBorder

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
  * This method checks whether finger candidate crosses a scan text border.
  * @param res
  * @param finger
  */
 public static void checkFingerOnBorder(FImage res, Finger finger) {
 	if (!(finger.getxId() < MIN_BORDER_DISTANCE || finger.getLastX() > res.getWidth() - MIN_BORDER_DISTANCE ||
 			finger.getyId() < MIN_BORDER_DISTANCE  || finger.getLastY() > res.getHeight() - MIN_BORDER_DISTANCE)) {
if (finger.getPlotMap().size() > 0) {
	for (Map.Entry<Pixel, Pixel> entry : finger.getPlotMap().entrySet()) {
	    Pixel key = entry.getKey();
	    Pixel value = entry.getValue();
    	res.setPixel(key.x, key.y, 0.0f);			    	
    	res.setPixel(value.x, value.y, 0.0f);			    	
	}
}
 	}
 }
 
开发者ID:ait-ngcms,项目名称:ffma,代码行数:19,代码来源:FingerDetector.java

示例6: drawSpectra

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
	 * Draw the given spectra into the image at the given x coordinate.
	 *
	 * @param freqs The FFT output
	 * @param x The x position to draw it at
	 */
	private void drawSpectra( final FImage img, final float[] f, final int x )
	{
		if( img == null || f == null ) return;

//		final double ps = img.getHeight()/f.length;
		for( int i = 0; i < f.length; i++ )
		{
//			img.drawLine( x, img.getHeight()-i, x, (int)(img.getHeight()-i-ps), mag );
			final int y = img.getHeight() - i -1;
			img.setPixel( x, y, f[i] );
		}
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:AudioSpectrogram.java

示例7: simpleSusan

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * Performs the simple SUSAN edge detection.
 * 
 * @param img
 *            The image to find edges in
 * @param thresh
 *            The threshold
 * @param nmax
 *            The global threshold weighting
 * @return Edge image
 */
public static FImage simpleSusan(FImage img, double thresh, double nmax)
{
	final FImage area = new FImage(img.getWidth(), img.getHeight());

	final double globalThresh = (3.0 * nmax) / 4.0;

	for (int y = 1; y < img.getHeight() - 1; y++)
	{
		for (int x = 1; x < img.getWidth() - 1; x++)
		{
			double a = 0;
			for (int x1 = x - 1; x1 < x + 2; x1++)
			{
				for (int y1 = y - 1; y1 < y + 2; y1++)
				{
					if (Math.abs(img.getPixel(x1, y1) - img.getPixel(x, y)) < thresh)
						a++;
				}
			}

			if (a < globalThresh)
				area.setPixel(x, y, (float) (globalThresh - a));
		}
	}

	return area;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:39,代码来源:SUSANEdgeDetector.java

示例8: smoothSusan

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * Performs the simple SUSAN edge detection.
 * 
 * @param img
 *            The image to find edges in
 * @param thresh
 *            The threshold
 * @param nmax
 *            The global threshold weighting
 * @return Edge image
 */
public static FImage smoothSusan(FImage img, double thresh, double nmax)
{
	final FImage area = new FImage(img.getWidth(), img.getHeight());

	final double globalThresh = (3.0 * nmax) / 4.0;

	for (int y = 1; y < img.getHeight() - 1; y++)
	{
		for (int x = 1; x < img.getWidth() - 1; x++)
		{
			double a = 0;
			for (int x1 = x - 1; x1 < x + 2; x1++)
			{
				for (int y1 = y - 1; y1 < y + 2; y1++)
				{
					a += Math.exp(
							-Math.pow(
									Math.abs(img.getPixel(x1, y1) -
											img.getPixel(x, y))
											/ thresh, 6));
				}
			}

			if (a < globalThresh)
				area.setPixel(x, y, (float) (globalThresh - a));
		}
	}

	return area;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:42,代码来源:SUSANEdgeDetector.java

示例9: smoothCircularSusan

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * Performs the simple SUSAN edge detection.
 * 
 * @param img
 *            The image to find edges in
 * @param thresh
 *            The threshold
 * @param nmax
 *            The global threshold weighting
 * @param radius
 *            The radius of the circle (try 3.4)
 * @return Edge image
 */
public static FImage smoothCircularSusan(FImage img, double thresh, double nmax, double radius)
{
	final FImage area = new FImage(img.getWidth(), img.getHeight());
	final double globalThresh = (3.0 * nmax) / 4.0;

	final int r = (int) Math.ceil(radius);
	for (int y = r; y < img.getHeight() - r; y++)
	{
		for (int x = r; x < img.getWidth() - r; x++)
		{
			final float[] pixelValues = getPixelsInCircle(x, y, radius, img);
			double a = 0;
			for (final float f : pixelValues)
				a += Math.exp(
						-Math.pow(
								Math.abs(f -
										img.getPixel(x, y))
										/ thresh, 6));

			if (a < globalThresh)
				area.setPixel(x, y, (float) (globalThresh - a));
		}
	}

	return area;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:40,代码来源:SUSANEdgeDetector.java

示例10: calculateHorizontalProjection

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * 	Calculates a projection across the given accumulator space. 
 *  Returns an image that has width the same as the input
 * 	and height of 1. Effectively sums across the distances from origin
 * 	in the space such that you end up with a representation that gives you
 * 	the strength of the angles in the image irrespective of where those
 * 	lines occur. 
 *
 * 	@param accum The accumulator space to project
 *	@return A horizontal projection on the accumulator space as an
 *		FImage with same width as input image but only 1 pixel high
 */
public FImage calculateHorizontalProjection( FImage accum )
{
	FImage proj = new FImage( accum.getWidth(), 1 );
	
	for( int x = 0; x < accum.getWidth(); x++ )
	{
		float acc = 0;
		for( int y = 0; y < accum.getHeight(); y++ )
			acc += accum.getPixel(x,y)*accum.getPixel(x,y);
		proj.setPixel(x,0, (float)Math.sqrt(acc) );
	}

	return proj;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:HoughLines.java

示例11: getBestLines

import org.openimaj.image.FImage; //导入方法依赖的package包/类
/**
 * 	Returns the top n lines from the given accumulator space.
 * 	The end points of the lines will have x coordinates at -2000 and 2000.
 * 
 *  @param n The number of lines to return
 *  @param accumulatorSpace The space to look within
 *  @param offset The offset into the accumulator of 0 in this space
 *  @return A list of lines
 */
public List<Line2d> getBestLines( int n, FImage accumulatorSpace, int offset )
{
	FImage accum2 = accumulatorSpace.clone();
	List<Line2d> lines = new ArrayList<Line2d>();
	for( int i = 0; i < n; i++ )
	{
		FValuePixel p = accum2.maxPixel();
		lines.add( getLineFromParams( p.x+offset, p.y, -2000, 2000 ) );
		accum2.setPixel( p.x, p.y, 0f );
	}
	
	return lines;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:HoughLines.java


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