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


Java ShortProcessor.setMinAndMax方法代码示例

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


在下文中一共展示了ShortProcessor.setMinAndMax方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testShort

import ij.process.ShortProcessor; //导入方法依赖的package包/类
final private static void testShort( ShortProcessor ipShort )
{
	final double min = ipShort.getMin();
	final double max = ipShort.getMax();
	
	while( ipShort.getWidth() > 32 )
	{
		ipShort = Downsampler.downsampleShortProcessor( ipShort );
		ipShort.setMinAndMax( min, max );
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:12,代码来源:DownsamplerTest.java

示例3: mapIntensities

import ij.process.ShortProcessor; //导入方法依赖的package包/类
final static protected ShortProcessor mapIntensities( final PatchIntensityRange pir, final double min, final double max )
{
	final double a = 65535.0 / ( max - min );
	final ImageProcessor source = pir.patch.getImageProcessor();
	final short[] targetPixels = new short[ source.getWidth() * source.getHeight() ];
	for ( int i = 0; i < targetPixels.length; ++i )
	{
		targetPixels[ i ] = ( short )Math.max( 0, Math.min( 65535, Math.round( ( ( source.getf( i ) - pir.patch.getMin() ) / pir.a - min ) * a ) ) );
	}
	final ShortProcessor target = new ShortProcessor( source.getWidth(), source.getHeight(), targetPixels, null );
	target.setMinAndMax( -min * a, ( 1.0 - min ) * a );
	return target;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:14,代码来源:ExportUnsignedShort.java

示例4: distanceMap

import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
 * Computes the distance map of the distance to the nearest pixel with a
 * different value. The function returns a new short processor the same size
 * as the input, with values greater or equal to zero.
 * 
 * @param labelImage
 *            a label image with black pixels (0) as foreground
 * @return a new instance of ShortProcessor containing:
 *         <ul>
 *         <li>0 for each background pixel</li>
 *         <li>the (strictly positive) distance to the nearest background
 *         pixel otherwise</li>
 *         </ul>
 */
public ShortProcessor distanceMap(ImageProcessor labelImage) 
{
	// size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	this.fireStatusChanged(new AlgoEvent(this, "Initialization"));
	ShortProcessor distMap = initializeResult(labelImage);
	
	// Two iterations are enough to compute distance map to boundary
	this.fireStatusChanged(new AlgoEvent(this, "Forward Scan"));
	forwardIteration(distMap, labelImage);
	this.fireStatusChanged(new AlgoEvent(this, "Backward Scan"));
	backwardIteration(distMap, labelImage);

	// Normalize values by the first weight
	if (this.normalizeMap)
	{
		this.fireStatusChanged(new AlgoEvent(this, "Normalization"));
		for (int y = 0; y < sizeY; y++)
		{
			for (int x = 0; x < sizeX; x++)
			{
				if (((int) labelImage.getf(x, y)) > 0)
				{
					distMap.set(x, y, distMap.get(x, y) / weights[0]);
				}
			}
		}
	}

	this.fireStatusChanged(new AlgoEvent(this, ""));

	// Compute max value within the mask for setting min/max of ImageProcessor
	double maxVal = LabelValues.maxValueWithinLabels(distMap, labelImage);
	distMap.setMinAndMax(0, maxVal);

	// Forces the display to non-inverted LUT
	if (distMap.isInvertedLut())
		distMap.invertLut();

	return distMap;
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:58,代码来源:DistanceTransform5x5Short.java

示例5: distanceMap

import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
 * Computes the distance map of the distance to the nearest pixel with a different value.
 * The function returns a new short processor the same size as the input,
 * with values greater or equal to zero.
 * 
 * @param labelImage a label image with black pixels (0) as foreground
 * @return a new instance of ShortProcessor containing: <ul>
 * <li> 0 for each background pixel </li>
 * <li> the (strictly positive) distance to the nearest background pixel otherwise</li>
 * </ul>
 */
public ShortProcessor distanceMap(ImageProcessor labelImage) 
{
	// size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	this.fireStatusChanged(new AlgoEvent(this, "Initialization"));
	ShortProcessor distMap = initializeResult(labelImage);
	
	// Two iterations are enough to compute distance map to boundary
	this.fireStatusChanged(new AlgoEvent(this, "Forward Scan"));
	forwardIteration(distMap, labelImage);
	this.fireStatusChanged(new AlgoEvent(this, "Backward Scan"));
	backwardIteration(distMap, labelImage);

	// Normalize values by the first weight
	if (this.normalizeMap)
	{
		this.fireStatusChanged(new AlgoEvent(this, "Normalization"));
		for (int y = 0; y < sizeY; y++)
		{
			for (int x = 0; x < sizeX; x++)
			{
				if (labelImage.getPixel(x, y) != 0)
				{
					distMap.set(x, y, distMap.get(x, y) / weights[0]);
				}
			}
		}
	}

	this.fireStatusChanged(new AlgoEvent(this, ""));

	// Compute max value within the mask for setting min/max of ImageProcessor
	double maxVal = LabelValues.maxValueWithinLabels(distMap, labelImage);
	distMap.setMinAndMax(0, maxVal);

	// Forces the display to non-inverted LUT
	if (distMap.isInvertedLut())
		distMap.invertLut();

	return distMap;
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:55,代码来源:DistanceTransform3x3Short.java

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