本文整理汇总了Java中net.imglib2.type.logic.BitType.set方法的典型用法代码示例。如果您正苦于以下问题:Java BitType.set方法的具体用法?Java BitType.set怎么用?Java BitType.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.type.logic.BitType
的用法示例。
在下文中一共展示了BitType.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unaryComputer
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
protected CenterAwareComputerOp<T, BitType> unaryComputer(final T inClass,
final BitType outClass)
{
final LocalThresholdMethod<T> op = new LocalThresholdMethod<T>() {
private UnaryComputerOp<Iterable<T>, DoubleType> meanOp;
@Override
public void compute(final Iterable<T> neighborhood, final T center, final BitType output) {
if (meanOp == null) {
meanOp = Computers.unary(ops(), Ops.Stats.Mean.class, DoubleType.class, neighborhood);
}
final DoubleType m = new DoubleType();
meanOp.compute(neighborhood, m);
output.set(center.getRealDouble() > m.getRealDouble() - c);
}
};
op.setEnvironment(ops());
return op;
}
示例2: compute
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
public void compute(final I center,
final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
final BitType output)
{
final DoubleType sum = new DoubleType();
integralMean.compute(neighborhood, sum);
// Subtract the contrast
sum.sub(new DoubleType(c));
// Set value
final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
final DoubleType centerPixelAsDoubleType = new DoubleType();
conv.convert(center, centerPixelAsDoubleType);
output.set(centerPixelAsDoubleType.compareTo(sum) > 0);
}
示例3: compute
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
public void compute(final I center,
final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
final BitType output)
{
final DoubleType mean = new DoubleType();
integralMean.compute(neighborhood, mean);
final DoubleType variance = new DoubleType();
integralVariance.compute(neighborhood, variance);
final DoubleType stdDev = new DoubleType(Math.sqrt(variance.get()));
final DoubleType threshold = new DoubleType(mean.getRealDouble() * (1.0d +
p * Math.exp(-q * mean.getRealDouble()) + k * ((stdDev.getRealDouble() /
r) - 1.0)));
// Set value
final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
final DoubleType centerPixelAsDoubleType = variance; // NB: Reuse
// DoubleType
conv.convert(center, centerPixelAsDoubleType);
output.set(centerPixelAsDoubleType.compareTo(threshold) > 0);
}
示例4: unaryComputer
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
protected CenterAwareComputerOp<T, BitType> unaryComputer(final T inClass,
final BitType outClass)
{
final LocalThresholdMethod<T> op = new LocalThresholdMethod<T>() {
private UnaryComputerOp<Iterable<T>, DoubleType> median;
@Override
public void compute(final Iterable<T> neighborhood, final T center, final BitType output) {
if (median == null) {
median = Computers
.unary(ops(), Ops.Stats.Median.class, DoubleType.class, neighborhood);
}
final DoubleType m = new DoubleType();
median.compute(neighborhood, m);
output.set(center.getRealDouble() > m.getRealDouble() - c);
}
};
op.setEnvironment(ops());
return op;
}
示例5: compute
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
public void compute(final I center,
final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
final BitType output)
{
final DoubleType mean = new DoubleType();
integralMean.compute(neighborhood, mean);
final DoubleType variance = new DoubleType();
integralVariance.compute(neighborhood, variance);
final DoubleType stdDev = new DoubleType(Math.sqrt(variance.get()));
final DoubleType threshold = new DoubleType(mean.getRealDouble() * (1.0d +
k * ((Math.sqrt(stdDev.getRealDouble()) / r) - 1.0)));
// Set value
final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
final DoubleType centerPixelAsDoubleType = variance; // NB: Reuse
// DoubleType
conv.convert(center, centerPixelAsDoubleType);
output.set(centerPixelAsDoubleType.compareTo(threshold) > 0);
}
示例6: unaryComputer
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
protected CenterAwareComputerOp<T, BitType> unaryComputer(final T inClass,
final BitType outClass)
{
final LocalThresholdMethod<T> op = new LocalThresholdMethod<T>() {
private UnaryComputerOp<Iterable<T>, DoubleType> mean;
private UnaryComputerOp<Iterable<T>, DoubleType> stdDeviation;
@Override
public void compute(final Iterable<T> neighborhood, final T center, final BitType output) {
if (mean == null) {
mean = Computers.unary(ops(), Ops.Stats.Mean.class, new DoubleType(),
neighborhood);
}
if (stdDeviation == null) {
stdDeviation = Computers.unary(ops(), Ops.Stats.StdDev.class,
new DoubleType(), neighborhood);
}
final DoubleType meanValue = new DoubleType();
mean.compute(neighborhood, meanValue);
final DoubleType stdDevValue = new DoubleType();
stdDeviation.compute(neighborhood, stdDevValue);
double threshold = meanValue.get() * (1.0d + p * Math.exp(-q * meanValue
.get()) + k * ((stdDevValue.get() / r) - 1.0));
output.set(center.getRealDouble() >= threshold);
}
};
op.setEnvironment(ops());
return op;
}
示例7: unaryComputer
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
protected CenterAwareComputerOp<T, BitType> unaryComputer(final T inClass,
final BitType outClass)
{
final LocalThresholdMethod<T> op = new LocalThresholdMethod<T>() {
private UnaryComputerOp<Iterable<T>, DoubleType> mean;
private UnaryComputerOp<Iterable<T>, DoubleType> stdDeviation;
@Override
public void compute(final Iterable<T> neighborhood, final T center, final BitType output) {
if (mean == null) {
mean = Computers.unary(ops(), Ops.Stats.Mean.class, new DoubleType(),
neighborhood);
}
if (stdDeviation == null) {
stdDeviation = Computers.unary(ops(), Ops.Stats.StdDev.class,
new DoubleType(), neighborhood);
}
final DoubleType m = new DoubleType();
mean.compute(neighborhood, m);
final DoubleType stdDev = new DoubleType();
stdDeviation.compute(neighborhood, stdDev);
output.set(center.getRealDouble() > m.getRealDouble() + k * stdDev
.getRealDouble() - c);
}
};
op.setEnvironment(ops());
return op;
}
示例8: compute
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
public void compute(final I center,
final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
final BitType output)
{
final DoubleType threshold = new DoubleType(0.0d);
final DoubleType mean = new DoubleType();
integralMean.compute(neighborhood, mean);
threshold.add(mean);
final DoubleType variance = new DoubleType();
integralVariance.compute(neighborhood, variance);
final DoubleType stdDev = new DoubleType(Math.sqrt(variance.get()));
stdDev.mul(k);
threshold.add(stdDev);
// Subtract the contrast
threshold.sub(new DoubleType(c));
// Set value
final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
final DoubleType centerPixelAsDoubleType = variance; // NB: Reuse
// DoubleType
conv.convert(center, centerPixelAsDoubleType);
output.set(centerPixelAsDoubleType.compareTo(threshold) > 0);
}
示例9: createMask
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
/**
* Create a new mask image with a defined size and preset content.
*/
public static RandomAccessibleInterval<BitType> createMask(long[] dim, boolean val) {
RandomAccessibleInterval<BitType> mask = createMask(dim);
for (BitType t : Views.iterable(mask))
t.set(val);
return mask;
}
示例10: compute
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
public void compute(final Iterable<BitType> input, final BitType output) {
for (final BitType e : input)
if (!e.get()) {
output.set(false);
return;
}
output.set(true);
}
示例11: compute
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Override
public void compute(final Iterable<BitType> input, final BitType output) {
for (final BitType e : input)
if (e.get()) {
output.set(true);
return;
}
output.set(false);
}
示例12: initialize
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
@Before
public void initialize() {
in = generateByteArrayTestImg(true, 10, 10);
bitIn = ArrayImgs.bits(10, 10);
final Random rnd = new Random(0x123456789caffee1L);
for (BitType px : bitIn)
px.set(rnd.nextBoolean());
}
示例13: benchmark
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
public static final void benchmark( final String[] args )
{
final int ntrials = 10;
final Shape strel = new DiamondShape( 3 );
final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 200, 200 } );
for ( final FloatType pixel : img )
{
pixel.set( 1f );
}
final ArrayRandomAccess< FloatType > ra = img.randomAccess();
final ArrayImg< BitType, LongArray > bitsImg = ArrayImgs.bits( new long[] { img.dimension( 0 ), img.dimension( 1 ) } );
for ( final BitType pixelB : bitsImg )
{
pixelB.set( true );
}
final ArrayRandomAccess< BitType > raBits = bitsImg.randomAccess(); // LOL
final Random ran = new Random( 1l );
for ( int i = 0; i < 1000; i++ )
{
final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
ra.setPosition( new int[] { x, y } );
ra.get().set( 0f );
raBits.setPosition( ra );
raBits.get().set( false );
}
// Dilate to new image
Img< BitType > imgBits3 = Opening.open( bitsImg, strel, 1 );
long start = System.currentTimeMillis();
for ( int i = 0; i < ntrials; i++ )
{
imgBits3 = Opening.open( bitsImg, strel, 1 );
}
long end = System.currentTimeMillis();
System.out.println( "BitType time: " + ( ( end - start ) / ntrials ) + " ms." );
Img< FloatType > img3 = Opening.open( img, strel, 1 );
start = System.currentTimeMillis();
for ( int i = 0; i < ntrials; i++ )
{
img3 = Opening.open( img, strel, 1 );
}
end = System.currentTimeMillis();
System.out.println( "FloatType time: " + ( ( end - start ) / ntrials ) + " ms." );
ImageJ.main( args );
ImageJFunctions.show( img3, "Float" );
ImageJFunctions.show( imgBits3, "Bit" );
}
示例14: benchmark
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
public static final void benchmark( final String[] args )
{
final int ntrials = 10;
final Shape strel = new DiamondShape( 3 );
final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 200, 200 } );
for ( final FloatType pixel : img )
{
pixel.set( 1f );
}
final ArrayRandomAccess< FloatType > ra = img.randomAccess();
final ArrayImg< BitType, LongArray > bitsImg = ArrayImgs.bits( new long[] { img.dimension( 0 ), img.dimension( 1 ) } );
for ( final BitType pixelB : bitsImg )
{
pixelB.set( true );
}
final ArrayRandomAccess< BitType > raBits = bitsImg.randomAccess(); // LOL
final Random ran = new Random( 1l );
for ( int i = 0; i < 1000; i++ )
{
final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
ra.setPosition( new int[] { x, y } );
ra.get().set( 0f );
raBits.setPosition( ra );
raBits.get().set( false );
}
// Dilate to new image
Img< BitType > imgBits3 = Erosion.erode( bitsImg, strel, 1 );
long start = System.currentTimeMillis();
for ( int i = 0; i < ntrials; i++ )
{
imgBits3 = Erosion.erode( bitsImg, strel, 1 );
}
long end = System.currentTimeMillis();
System.out.println( "BitType time: " + ( ( end - start ) / ntrials ) + " ms." );
Img< FloatType > img3 = Erosion.erode( img, strel, 1 );
start = System.currentTimeMillis();
for ( int i = 0; i < ntrials; i++ )
{
img3 = Erosion.erode( img, strel, 1 );
}
end = System.currentTimeMillis();
System.out.println( "FloatType time: " + ( ( end - start ) / ntrials ) + " ms." );
ImageJ.main( args );
ImageJFunctions.show( img3, "Float" );
ImageJFunctions.show( imgBits3, "Bit" );
}
示例15: benchmark
import net.imglib2.type.logic.BitType; //导入方法依赖的package包/类
public static final void benchmark( final String[] args )
{
final int ntrials = 10;
final Shape strel = new DiamondShape( 3 );
final ArrayImg< UnsignedByteType, ByteArray > img = ArrayImgs.unsignedBytes( new long[] { 200, 200 } );
for ( final UnsignedByteType pixel : img )
{
pixel.set( 1 );
}
final ArrayRandomAccess< UnsignedByteType > ra = img.randomAccess();
final ArrayImg< BitType, LongArray > bitsImg = ArrayImgs.bits( new long[] { img.dimension( 0 ), img.dimension( 1 ) } );
for ( final BitType pixelB : bitsImg )
{
pixelB.set( true );
}
final ArrayRandomAccess< BitType > raBits = bitsImg.randomAccess(); // LOL
final Random ran = new Random( 1l );
for ( int i = 0; i < 1000; i++ )
{
final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
final int y = ran.nextInt( ( int ) img.dimension( 1 ) );
ra.setPosition( new int[] { x, y } );
ra.get().set( 0 );
raBits.setPosition( ra );
raBits.get().set( false );
}
// Dilate to new image
Img< BitType > imgBits3 = Closing.close( bitsImg, strel, 1 );
long start = System.currentTimeMillis();
for ( int i = 0; i < ntrials; i++ )
{
imgBits3 = Closing.close( bitsImg, strel, 1 );
}
long end = System.currentTimeMillis();
System.out.println( "BitType time: " + ( ( end - start ) / ntrials ) + " ms." );
Img< net.imglib2.type.numeric.integer.UnsignedByteType > img3 = Closing.close( img, strel, 1 );
start = System.currentTimeMillis();
for ( int i = 0; i < ntrials; i++ )
{
img3 = Closing.close( img, strel, 1 );
}
end = System.currentTimeMillis();
System.out.println( "UnsignedByteType time: " + ( ( end - start ) / ntrials ) + " ms." );
ImageJ.main( args );
ImageJFunctions.show( img3, "Float" );
ImageJFunctions.show( imgBits3, "Bit" );
}