本文整理汇总了Java中ij.process.ShortProcessor.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ShortProcessor.getWidth方法的具体用法?Java ShortProcessor.getWidth怎么用?Java ShortProcessor.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.ShortProcessor
的用法示例。
在下文中一共展示了ShortProcessor.getWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: targetToShortImage
import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
* Converts the processor to a short (16-bit) image.
*
* @param renderedImageProcessorWithMasks processor to convert.
*
* @return the converted image.
*/
public static BufferedImage targetToShortImage(final ImageProcessorWithMasks renderedImageProcessorWithMasks) {
// convert to 16-bit gray-scale
final ShortProcessor sp = renderedImageProcessorWithMasks.ip.convertToShortProcessor();
final BufferedImage image = new BufferedImage(sp.getWidth(), sp.getHeight(), BufferedImage.TYPE_USHORT_GRAY);
final WritableRaster raster = image.getRaster();
raster.setDataElements(0, 0, sp.getWidth(), sp.getHeight(), sp.getPixels());
return image;
}
示例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;
}
示例3: 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 );
}
}
示例4: testShortAlphaByteMappingIndependently
import ij.process.ShortProcessor; //导入方法依赖的package包/类
/**
* Test downsampling the pyramid of a short image + byte alpha channel
* including the byte mapping of the short all in separate loops.
*
* @param ba
*/
final private static void testShortAlphaByteMappingIndependently( ShortProcessor sp, ByteProcessor alpha )
{
ByteProcessor bp;
while( sp.getWidth() > 32 )
{
sp = Downsampler.downsampleShortProcessor( sp );
bp = ( ByteProcessor )sp.convertToByte( true );
alpha = Downsampler.downsampleByteProcessor( alpha );
// new ImagePlus( "pixels " + ba.a.getWidth(), ba.a ).show();
// new ImagePlus( "pixels to byte " + ba.a.getWidth(), new ByteProcessor( ba.a.getWidth(), ba.a.getHeight(), ba.b[ 0 ], null ) ).show();
// new ImagePlus( "alpha " + ba.a.getWidth(), new ByteProcessor( ba.a.getWidth(), ba.a.getHeight(), ba.b[ 1 ], null ) ).show();
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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 ) ) ) );
}
}
}
}
示例8: 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 );
}