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


Java ShortProcessor.set方法代码示例

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


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

示例1: initialize

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private ShortProcessor initialize(ImageProcessor marker)
{
	// size of image
	sizeX = marker.getWidth();
	sizeY = marker.getHeight();
	
	ShortProcessor distMap = new ShortProcessor(sizeX, sizeY);
	distMap.setValue(0);
	distMap.fill();

	// initialize empty image with either 0 (foreground) or Inf (background)
	for (int y = 0; y < sizeY; y++) 
	{
		for (int x = 0; x < sizeX; x++) 
		{
			int val = marker.get(x, y) & 0x00ff;
			distMap.set(x, y, val == 0 ? Short.MAX_VALUE : 0);
		}
	}

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

示例2: initializeResult

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private ShortProcessor initializeResult(ImageProcessor labelImage)
{
	// size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	// create new empty image, and fill it with black
	ShortProcessor distMap = new ShortProcessor(sizeX, sizeY);
	distMap.setValue(0);
	distMap.fill();

	// initialize empty image with either 0 (background) or Inf (foreground)
	for (int y = 0; y < sizeY; y++) 
	{
		for (int x = 0; x < sizeX; x++)
		{
			int label = (int) labelImage.getf(x, y);
			distMap.set(x, y, label == 0 ? 0 : Short.MAX_VALUE);
		}
	}
	
	return distMap;
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:24,代码来源:DistanceTransform5x5Short.java

示例3: makeLabelImageGray

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private ShortProcessor makeLabelImageGray() {
	ShortProcessor sp = new ShortProcessor(width, height);
	for (int v = 0; v < height; v++) {
		for (int u = 0; u < width; u++) {
			int lb = getLabel(u, v);
			sp.set(u, v, (lb >= 0) ? lb : 0);
		}
	}
	sp.resetMinAndMax();
	return sp;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:12,代码来源:RegionLabeling.java

示例4: showLabelling

import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
 * @see sc.fiji.CMP_BIA.segmentation.structures.Labelling#showLabelling()
 */
@Override
public void showLabelling() {
	// create ImageJ ShortProcessor
	ShortProcessor segm = new ShortProcessor(dims[0], dims[1]);
	for (int x=0; x<dims[0]; x++ ) {
		for (int y=0; y<dims[1]; y++ ) {
			segm.set(x, y, data[x][y]);
		}
	}
	
	// create Processor to ImagePlus
	ImagePlus img = new ImagePlus("Segmentation", segm);
	img.show();
}
 
开发者ID:dscho,项目名称:ij-CMP-BIA,代码行数:18,代码来源:Labelling2D.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 (((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

示例6: forwardIteration

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private void forwardIteration(ShortProcessor distMap, ImageProcessor labelImage) 
{
	// Initialize pairs of offset and weights
	int[] dx = new int[]{-1, +1,  -2, -1,  0, +1, +2,  -1};
	int[] dy = new int[]{-2, -2,  -1, -1, -1, -1, -1,   0};
	short[] dw = new short[] { 
			weights[2], weights[2], 
			weights[2], weights[1], weights[0], weights[1], weights[2], 
			weights[0] };
	
	//  size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	// Iterate over pixels
	for (int y = 0; y < sizeY; y++)
	{
		this.fireProgressChanged(this, y, sizeY);
		for (int x = 0; x < sizeX; x++)
		{
			// get current label
			int label = (int) labelImage.getf(x, y);
			
			// do not process background pixels
			if (label == 0)
				continue;
			
			// current distance value
			int currentDist = distMap.get(x, y);
			int newDist = currentDist;
			
			// iterate over neighbors
			for (int i = 0; i < dx.length; i++)
			{
				// compute neighbor coordinates
				int x2 = x + dx[i];
				int y2 = y + dy[i];
				
				// check bounds
				if (x2 < 0 || x2 >= sizeX)
					continue;
				if (y2 < 0 || y2 >= sizeY)
					continue;
				
				if ((int) labelImage.getf(x2, y2) != label)
				{
					// Update with distance to nearest different label
					newDist = dw[i];
				}
				else
				{
					// Increment distance
					newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]);
				}
			}
			
			if (newDist < currentDist) 
			{
				distMap.set(x, y, newDist);
			}
		}
	}
	
	this.fireProgressChanged(this, sizeY, sizeY);
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:66,代码来源:DistanceTransform5x5Short.java

示例7: backwardIteration

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private void backwardIteration(ShortProcessor distMap, ImageProcessor labelImage) 
{
	// Initialize pairs of offset and weights
	int[] dx = new int[]{+1, -1,  +2, +1,  0, -1, -2,  +1};
	int[] dy = new int[]{+2, +2,  +1, +1, +1, +1, +1,   0};
	short[] dw = new short[] { 
			weights[2], weights[2], 
			weights[2], weights[1], weights[0], weights[1], weights[2], 
			weights[0] };
	
	//  size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	// Iterate over pixels
	for (int y = sizeY-1; y >= 0; y--)
	{
		this.fireProgressChanged(this, sizeY-1-y, sizeY);
		for (int x = sizeX-1; x >= 0; x--)
		{
			// get current label
			int label = (int) labelImage.getf(x, y);
			
			// do not process background pixels
			if (label == 0)
				continue;
			
			// current distance value
			int currentDist = distMap.get(x, y);
			int newDist = currentDist;
			
			// iterate over neighbors
			for (int i = 0; i < dx.length; i++)
			{
				// compute neighbor coordinates
				int x2 = x + dx[i];
				int y2 = y + dy[i];
				
				// check bounds
				if (x2 < 0 || x2 >= sizeX)
					continue;
				if (y2 < 0 || y2 >= sizeY)
					continue;
				
				if ((int) labelImage.getf(x2, y2) != label)
				{
					// Update with distance to nearest different label
					newDist = dw[i];
				}
				else
				{
					// Increment distance
					newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]);
				}
			}
			
			if (newDist < currentDist) 
			{
				distMap.set(x, y, newDist);
			}
		}
	}
	
	this.fireProgressChanged(this, sizeY, sizeY);
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:66,代码来源:DistanceTransform5x5Short.java

示例8: 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

示例9: forwardIteration

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private void forwardIteration(ShortProcessor distMap, ImageProcessor labelImage) 
{
	int[] dx = new int[]{-1, 0, +1, -1};
	int[] dy = new int[]{-1, -1, -1, 0};
	int[] dw = new int[]{weights[1], weights[0], weights[1], weights[0]};
	
	// size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	// Iterate over pixels
	for (int y = 0; y < sizeY; y++)
	{
		this.fireProgressChanged(this, y, sizeY);
		for (int x = 0; x < sizeX; x++)
		{
			// get current label
			int label = (int) labelImage.getf(x, y);
			
			// do not process background pixels
			if (label == 0)
				continue;
			
			// current distance value
			int currentDist = distMap.get(x, y);
			int newDist = currentDist;
			
			// iterate over neighbors
			for (int i = 0; i < dx.length; i++)
			{
				// compute neighbor coordinates
				int x2 = x + dx[i];
				int y2 = y + dy[i];
				
				// check bounds
				if (x2 < 0 || x2 >= sizeX)
					continue;
				if (y2 < 0 || y2 >= sizeY)
					continue;
				
				if ((int) labelImage.getf(x2, y2) != label)
				{
					// Update with distance to nearest different label
					newDist = dw[i];
				}
				else
				{
					// Increment distance
					newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]);
				}
			}
			
			if (newDist < currentDist) 
			{
				distMap.set(x, y, newDist);
			}
		}
	}
	
	this.fireProgressChanged(this, sizeY, sizeY);
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:62,代码来源:DistanceTransform3x3Short.java

示例10: backwardIteration

import ij.process.ShortProcessor; //导入方法依赖的package包/类
private void backwardIteration(ShortProcessor distMap, ImageProcessor labelImage) 
{
	int[] dx = new int[]{+1, 0, -1, +1};
	int[] dy = new int[]{+1, +1, +1, 0};
	int[] dw = new int[]{weights[1], weights[0], weights[1], weights[0]};

	// size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	// Iterate over pixels
	for (int y = sizeY-1; y >= 0; y--)
	{
		this.fireProgressChanged(this, sizeY-1-y, sizeY);
		for (int x = sizeX-1; x >= 0; x--)
		{
			// get current label
			int label = (int) labelImage.getf(x, y);
			
			// do not process background pixels
			if (label == 0)
				continue;
			
			// current distance value
			int currentDist = distMap.get(x, y);
			int newDist = currentDist;
			
			// iterate over neighbors
			for (int i = 0; i < dx.length; i++)
			{
				// compute neighbor coordinates
				int x2 = x + dx[i];
				int y2 = y + dy[i];
				
				// check bounds
				if (x2 < 0 || x2 >= sizeX)
					continue;
				if (y2 < 0 || y2 >= sizeY)
					continue;
				
				if ((int) labelImage.getf(x2, y2) != label)
				{
					// Update with distance to nearest different label
					newDist = dw[i];
				}
				else
				{
					// Increment distance
					newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]);
				}
			}
			
			if (newDist < currentDist) 
			{
				distMap.set(x, y, newDist);
			}
		}
	}
	
	this.fireProgressChanged(this, sizeY, sizeY);
}
 
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:62,代码来源:DistanceTransform3x3Short.java

示例11: mapShortAlphaTriangle

import ij.process.ShortProcessor; //导入方法依赖的package包/类
final static protected void mapShortAlphaTriangle(
		final TransformMesh m,
		final AffineModel2D ai,
		final ShortProcessor source,
		final ByteProcessor alpha,
		final ShortProcessor target )
{
	final int w = target.getWidth() - 1;
	final int h = target.getHeight() - 1;
	final ArrayList< PointMatch > pm = m.getAV().get( ai );
	final double[] min = new double[ 2 ];
	final double[] max = new double[ 2 ];
	calculateBoundingBox( pm, min, max );

	final int minX = Math.max( 0, Util.roundPos( min[ 0 ] ) );
	final int minY = Math.max( 0, Util.roundPos( min[ 1 ] ) );
	final int maxX = Math.min( w, Util.roundPos( max[ 0 ] ) );
	final int maxY = Math.min( h, Util.roundPos( max[ 1 ] ) );

	final double[] a = pm.get( 0 ).getP2().getW();
	final double ax = a[ 0 ];
	final double ay = a[ 1 ];
	final double[] b = pm.get( 1 ).getP2().getW();
	final double bx = b[ 0 ];
	final double by = b[ 1 ];
	final double[] c = pm.get( 2 ).getP2().getW();
	final double cx = c[ 0 ];
	final double cy = c[ 1 ];
	final double[] t = new double[ 2 ];
	for ( int y = minY; y <= maxY; ++y )
	{
		for ( int x = minX; x <= maxX; ++x )
		{
			if ( isInTriangle( ax, ay, bx, by, cx, cy, x, y ) )
			{
				t[ 0 ] = x;
				t[ 1 ] = y;
				try
				{
					ai.applyInverseInPlace( t );
				}
				catch ( final Exception e )
				{
					//e.printStackTrace( System.err );
					continue;
				}
				final int is = source.getPixelInterpolated( t[ 0 ], t[ 1 ] );
				final int it = target.get( x, y );
				final double f = alpha.getPixelInterpolated( t[ 0 ], t[ 1 ] ) / 255.0;
				final double v = it + f  * ( is - it );
				target.set( x, y, ( int )Math.max(  0, Math.min( 65535, Math.round( v ) ) ) );
			}
		}
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:56,代码来源:TransformMeshMappingWithMasks.java


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