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


Java ShortProcessor.getPixels方法代码示例

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


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

示例1: labelImage

import ij.process.ShortProcessor; //导入方法依赖的package包/类
public static ShortProcessor labelImage(ImageProcessor ip, float threshold, boolean conn8) {
	int w = ip.getWidth();
	int h = ip.getHeight();
	short shortMax = (short)65535;
	ShortProcessor sp = new ShortProcessor(w, h);
	short[] pxShort = (short[])sp.getPixels();
	for (int i = 0; i < w*h; i++) {
		if (ip.getf(i) > threshold)
			pxShort[i] = shortMax;
	}
	// Loop through and flood fill
	FloodFiller ff = new FloodFiller(sp);
	double label = 0;
	for (int i = 0; i < pxShort.length; i++) {
		if (pxShort[i] == shortMax) {
			label++;
			sp.setValue(label);
			if (conn8)
				ff.fill8(i % w, i / w);
			else
				ff.fill(i % w, i / w);
		}
	}
	sp.setMinAndMax(0, label);
	return sp;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:27,代码来源:ROILabeling.java

示例2: labelRegions

import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
 * Convert the binary mask to labelled regions, each with a unique number.
 */
private void labelRegions(ShortProcessor ip)
{
	maxx = ip.getWidth();
	maxy = ip.getHeight();

	xlimit = maxx - 1;
	ylimit = maxy - 1;

	// Create the offset table (for single array 2D neighbour comparisons)
	offset = new int[DIR_X_OFFSET.length];
	for (int d = offset.length; d-- > 0;)
	{
		offset[d] = maxx * DIR_Y_OFFSET[d] + DIR_X_OFFSET[d];
	}

	short[] mask = (short[]) ip.getPixels();
	int[] pList = new int[mask.length];

	// Store all the non-zero positions
	boolean[] binaryMask = new boolean[mask.length];
	for (int i = 0; i < binaryMask.length; i++)
		binaryMask[i] = (mask[i] != 0);

	// Find particles 
	for (int i = 0; i < binaryMask.length; i++)
	{
		if (binaryMask[i])
		{
			expandParticle(binaryMask, mask, pList, i, (short) regionCounter);
			regionCounter++;
		}
	}

	// Free memory
	offset = null;
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:40,代码来源:SpotDistance.java

示例3: downsampleShortProcessor

import ij.process.ShortProcessor; //导入方法依赖的package包/类
final static public ShortProcessor downsampleShortProcessor( final ShortProcessor a )
{
	final int wa = a.getWidth();
	final int ha = a.getHeight();
	final int wa2 = wa + wa;
	
	final int wb = wa / 2;
	final int hb = ha / 2;
	final int nb = hb * wb;
	
	final ShortProcessor b = new ShortProcessor( wb, hb );
	
	final short[] aPixels = ( short[] )a.getPixels();
	final short[] bPixels = ( short[] )b.getPixels();
	
	for ( int ya = 0, yb = 0; yb < nb; ya += wa2, yb += wb )
	{
		final int ya1 = ya + wa;
		for ( int xa = 0, xb = 0; xb < wb; xa += 2, ++xb )
		{
			final int xa1 = xa + 1;
			final int s = averageShort(
					ya + xa,
					ya + xa1,
					ya1 + xa,
					ya1 + xa1,
					aPixels );
			bPixels[ yb + xb ] = ( short )s;
		}
	}
	
	return b;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:34,代码来源:Downsampler.java

示例4: fastConvertToFloat

import ij.process.ShortProcessor; //导入方法依赖的package包/类
/** A method that circumvents the findMinAndMax when creating a float processor from an existing processor.  Ignores color calibrations and does no scaling at all. */
static public final FloatProcessor fastConvertToFloat(final ShortProcessor ip) {
	final short[] pix = (short[])ip.getPixels();
	final float[] data = new float[pix.length];
	for (int i=0; i<pix.length; i++) data[i] = pix[i]&0xffff;
	final FloatProcessor fp = new FloatProcessorT2(ip.getWidth(), ip.getHeight(), data, ip.getColorModel(), ip.getMin(), ip.getMax());
	return fp;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:9,代码来源:Utils.java

示例5: downsampleShort

import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
 * Create a downsampled version of a {@link ShortProcessor} and the
 * mapping of its [min,max] range into an unsigned byte array.
 * 
 * @param a
 * @return
 * 	Pair.a downsampled {@link ShortProcessor}
 *  Pair.b mapped into unsigned byte
 */
final static public Pair< ShortProcessor, byte[] > downsampleShort( final ShortProcessor a )
{
	final int wa = a.getWidth();
	final int ha = a.getHeight();
	final int wa2 = wa + wa;
	
	final double min = a.getMin();
	final double max = a.getMax();
	final double scale = 255.0 / ( max - min );
	
	
	final int wb = wa / 2;
	final int hb = ha / 2;
	final int nb = hb * wb;
	
	final ShortProcessor b = new ShortProcessor( wb, hb );
	b.setMinAndMax( min, max );
	
	final short[] aPixels = ( short[] )a.getPixels();
	final short[] bPixels = ( short[] )b.getPixels();
	final byte[] bBytes = new byte[ bPixels.length ];
	
	for ( int ya = 0, yb = 0; yb < nb; ya += wa2, yb += wb )
	{
		final int ya1 = ya + wa;
		for ( int xa = 0, xb = 0; xb < wb; xa += 2, ++xb )
		{
			final int xa1 = xa + 1;
			final int yaxa = ya + xa;
			final int yaxa1 = ya + xa1;
			final int ya1xa = ya1 + xa;
			final int ya1xa1 = ya1 + xa1;
			final int ybxb = yb + xb;
			
			final int s = averageShort( yaxa, yaxa1, ya1xa, ya1xa1, aPixels );
			bPixels[ ybxb ] = ( short )s;
			final int sb = ( int )( ( s - min ) * scale + 0.5 );
			bBytes[ ybxb ] = ( byte )( sb < 0 ? 0 : sb > 255 ? 255 : sb );
		}
	}
	return new Pair< ShortProcessor, byte[] >( b, bBytes );
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:52,代码来源:Downsampler.java


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