本文整理汇总了Java中net.imglib2.exception.IncompatibleTypeException类的典型用法代码示例。如果您正苦于以下问题:Java IncompatibleTypeException类的具体用法?Java IncompatibleTypeException怎么用?Java IncompatibleTypeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IncompatibleTypeException类属于net.imglib2.exception包,在下文中一共展示了IncompatibleTypeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HWatershedLabeling
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
public HWatershedLabeling(Img<T> input, float threshold, Connectivity connectivity)
{
int nDims = input.numDimensions();
long[] dims = new long[nDims];
input.dimensions(dims);
ImgFactory<IntType> imgFactoryIntType=null;
try {
imgFactoryIntType = input.factory().imgFactory( new IntType() );
} catch (IncompatibleTypeException e) {
e.printStackTrace();
}
if ( imgFactoryIntType != null )
{
this.labelMapMaxTree = imgFactoryIntType.create(dims, new IntType(0));
Cursor<IntType> c_label = labelMapMaxTree.cursor();
Cursor<T> c_input = input.cursor();
while( c_input.hasNext() )
{
c_label.next().setInteger( (int) c_input.next().getRealFloat() );
}
}
this.threshold = threshold;
this.connectivity = connectivity;
}
示例2: RealARGBConverterBenchmark
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
public RealARGBConverterBenchmark( final String filename ) throws ImgIOException, IncompatibleTypeException
{
// open with ImgOpener using an ArrayImgFactory
final ArrayImgFactory< UnsignedByteType > factory = new ArrayImgFactory< UnsignedByteType >();
img = new ImgOpener().openImg( filename, factory, new UnsignedByteType() );
argbImg = new ArrayImgFactory< ARGBType >().create( img, new ARGBType() );
BenchmarkHelper.benchmarkAndPrint( 15, true, new Runnable()
{
@Override
public void run()
{
for ( int i = 0; i < 10; ++i )
convert( img, argbImg );
}
} );
ImageJFunctions.show( argbImg );
}
示例3: main
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
public static <T extends RealType<T> & NativeType< T >> void main(final String[] args) throws ImgIOException, IncompatibleTypeException {
// File file = new File( "E:/Users/JeanYves/Desktop/Data/Y.tif");
final File file = new File( "/home/tobias/Desktop/Y.tif");
final int niter = 1000;
// Open file in imglib2
final ImgFactory< ? > imgFactory = new ArrayImgFactory< T >();
final Img< T > image = (Img< T >) new ImgOpener().openImg( file.getAbsolutePath(), imgFactory );
// Display it via ImgLib using ImageJ
new ImageJ();
ImageJFunctions.show( image );
benchmark( IterationMethod.TRANSLATE_VIEW, "With translated views:", niter, image );
benchmark( IterationMethod.TRANSLATE_VIEW_CURSOR, "With translated views (Cursors only):", niter, image );
benchmark( IterationMethod.TRANSLATE_VIEW_SPLIT, "With translated views (split into center and borders):", niter, image );
benchmark( IterationMethod.RANDOM_ACCESS, "With random access:", niter, image );
benchmark( IterationMethod.RANDOM_ACCESS_SPLIT, "With random access (split into center and borders):", niter, image );
benchmark( IterationMethod.RANDOM_ACCESS_NO_EXTEND, "With random access, no out of bounds access:", niter, image );
}
示例4: main
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
public static void main( final String[] args ) throws ImgIOException
{
final String fn = "/home/tobias/workspace/data/DrosophilaWing.tif";
final Img< FloatType > img = new ImgOpener().openImg( fn, new ArrayImgFactory< FloatType >(), new FloatType() );
final long[] dims = new long[ img.numDimensions() ];
img.dimensions( dims );
final Img< FloatType > convolved = ArrayImgs.floats( dims );
try
{
Gauss3.gauss( 3, Views.extendMirrorSingle( img ), convolved );
// Gauss3.gauss( 5, img, Views.interval( convolved, Intervals.createMinSize( 200, 100, 200, 150 ) ) );
}
catch ( final IncompatibleTypeException e )
{
e.printStackTrace();
}
ImageJFunctions.show( convolved );
}
示例5: compute
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> input,
final RandomAccessibleInterval<T> output)
{
if (outOfBounds == null) {
outOfBounds = new OutOfBoundsMirrorFactory<>(Boundary.SINGLE);
}
final RandomAccessible<FloatType> eIn = //
(RandomAccessible) Views.extend(input, outOfBounds);
try {
SeparableSymmetricConvolution.convolve(Gauss3.halfkernels(sigmas), eIn,
output, threads.getExecutorService());
}
catch (final IncompatibleTypeException e) {
throw new RuntimeException(e);
}
}
示例6: testLocalMeanResultsConsistency
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* @see LocalMeanThresholdIntegral
* @see LocalMeanThreshold
*/
@Test
public void testLocalMeanResultsConsistency() {
Img<BitType> out2 = null;
Img<BitType> out3 = null;
try {
out2 = in.factory().imgFactory(new BitType()).create(in, new BitType());
out3 = in.factory().imgFactory(new BitType()).create(in, new BitType());
}
catch (IncompatibleTypeException exc) {
exc.printStackTrace();
}
// Default implementation
ops.run(LocalMeanThreshold.class, out2, in, new RectangleShape(2, false),
new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE),
0.0);
// Integral image-based implementation
ops.run(LocalMeanThresholdIntegral.class, out3, in, new RectangleShape(2,
false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(
Boundary.SINGLE), 0.0);
testIterableIntervalSimilarity(out2, out3);
}
示例7: testLocalNiblackResultsConsistency
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* @see LocalNiblackThresholdIntegral
* @see LocalNiblackThreshold
*/
@Test
public void testLocalNiblackResultsConsistency() {
Img<BitType> out2 = null;
Img<BitType> out3 = null;
try {
out2 = in.factory().imgFactory(new BitType()).create(in, new BitType());
out3 = in.factory().imgFactory(new BitType()).create(in, new BitType());
}
catch (IncompatibleTypeException exc) {
exc.printStackTrace();
}
// Default implementation
ops.run(LocalNiblackThreshold.class, out2, normalizedIn, new RectangleShape(
2, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(
Boundary.SINGLE), 0.2, 1.0);
// Integral image-based implementation
ops.run(LocalNiblackThresholdIntegral.class, out3, normalizedIn,
new RectangleShape(2, false),
new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE),
0.2, 1.0);
testIterableIntervalSimilarity(out2, out3);
}
示例8: testLocalSauvolaResultsConsistency
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* @see LocalSauvolaThresholdIntegral
* @see LocalSauvolaThreshold
*/
@Test
public void testLocalSauvolaResultsConsistency() {
Img<BitType> out2 = null;
Img<BitType> out3 = null;
try {
out2 = in.factory().imgFactory(new BitType()).create(in, new BitType());
out3 = in.factory().imgFactory(new BitType()).create(in, new BitType());
}
catch (IncompatibleTypeException exc) {
exc.printStackTrace();
}
// Default implementation
ops.run(LocalSauvolaThreshold.class, out2, normalizedIn, new RectangleShape(
2, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(
Boundary.SINGLE), 0.5, 0.5);
// Integral image-based implementation
ops.run(LocalSauvolaThresholdIntegral.class, out3, normalizedIn,
new RectangleShape(2, false),
new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE),
0.5, 0.5);
testIterableIntervalSimilarity(out2, out3);
}
示例9: preSmooth
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
protected < T extends RealType< T > > void preSmooth( final RandomAccessibleInterval< T > img )
{
if ( additionalSigmaX > 0.0 || additionalSigmaY > 0.0 || additionalSigmaZ > 0.0 )
{
IOFunctions.println( "presmoothing image with sigma=[" + additionalSigmaX + "," + additionalSigmaY + "," + additionalSigmaZ + "]" );
try
{
Gauss3.gauss( new double[]{ additionalSigmaX, additionalSigmaY, additionalSigmaZ }, Views.extendMirrorSingle( img ), img );
}
catch (IncompatibleTypeException e)
{
IOFunctions.println( "presmoothing failed: " + e );
e.printStackTrace();
}
}
}
示例10: openImgs
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* @param reader - An initialized {@link Reader} to use for reading image
* data.
* @param config - {@link SCIFIOConfig} to use when opening this dataset
* @return - the {@link ImgPlus} or null
* @throws ImgIOException if there is a problem reading the image data.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<SCIFIOImgPlus<?>> openImgs(final Reader reader,
SCIFIOConfig config) throws ImgIOException
{
final RealType t = getType(reader);
if (config == null) {
config = new SCIFIOConfig().imgOpenerSetComputeMinMax(true);
}
final ImgFactoryHeuristic heuristic = getHeuristic(config);
ImgFactory imgFactory;
try {
if (NativeType.class.isAssignableFrom(t.getClass())) {
imgFactory =
heuristic.createFactory(reader.getMetadata(), config
.imgOpenerGetImgModes(), (NativeType) t);
}
else return null;
}
catch (final IncompatibleTypeException e) {
throw new ImgIOException(e);
}
return openImgs(reader, t, imgFactory, config);
}
示例11: SCIFIOConfig
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* @param reader - An initialized {@link Reader} to use for reading image
* data.
* @param type - The {@link Type} T of the output {@link ImgPlus}, which must
* match the typing of the {@link ImgFactory}.
* @param config - {@link SCIFIOConfig} to use when opening this dataset
* @return - the {@link ImgPlus} or null
* @throws ImgIOException if there is a problem reading the image data.
*/
public <T extends RealType<T> & NativeType<T>> List<SCIFIOImgPlus<T>>
openImgs(final Reader reader, final T type, SCIFIOConfig config)
throws ImgIOException
{
if (config == null) {
config = new SCIFIOConfig().imgOpenerSetComputeMinMax(true);
}
final ImgFactoryHeuristic heuristic = getHeuristic(config);
ImgFactory<T> imgFactory;
try {
imgFactory =
heuristic.createFactory(reader.getMetadata(), config
.imgOpenerGetImgModes(), type);
}
catch (final IncompatibleTypeException e) {
throw new ImgIOException(e);
}
return openImgs(reader, type, imgFactory, config);
}
示例12: writeImg
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* Terminal {@link #writeImg} method. Performs actual pixel output.
*/
private Metadata writeImg(final Writer w, final SCIFIOImgPlus<?> imgPlus,
final int imageIndex, final int sliceCount) throws ImgIOException,
IncompatibleTypeException
{
if (imgPlus.numDimensions() > 0) {
final long startTime = System.currentTimeMillis();
// write pixels
writePlanes(w, imageIndex, imgPlus);
// Print time statistics
final long endTime = System.currentTimeMillis();
final float time = (endTime - startTime) / 1000f;
statusService.showStatus(sliceCount, sliceCount, w.getMetadata()
.getDatasetName() +
": wrote " + sliceCount + " planes in " + time + " s");
}
return w.getMetadata();
}
示例13: testImgPlusIntegrity
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
/**
* Write an image to memory using the {@link ImgSaver} and verify that the
* given {@link ImgPlus} is not corrupted during the process.
*/
@Test
public void testImgPlusIntegrity() throws ImgIOException,
IncompatibleTypeException
{
final ImgOpener o = new ImgOpener(ctx);
final ImgSaver s = new ImgSaver(ctx);
final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes(
ImgMode.PLANAR);
final ByteArrayHandle bah = new ByteArrayHandle();
locationService.mapFile(out, bah);
final SCIFIOImgPlus<?> openImg = o.openImgs(id, config).get(0);
final String source = openImg.getSource();
s.saveImg(out, openImg);
assertEquals(source, openImg.getSource());
}
示例14: testPlaneSavingForConfig
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
private void testPlaneSavingForConfig(final SCIFIOConfig config)
throws ImgIOException, IncompatibleTypeException
{
final ImgOpener o = new ImgOpener(ctx);
final ImgSaver s = new ImgSaver(ctx);
// write the image
final SCIFIOImgPlus<UnsignedByteType> before = o.openImgs(id,
new UnsignedByteType(), config).get(0);
s.saveImg(out, before);
// re-read the written image and check for consistency
final SCIFIOImgPlus<UnsignedByteType> after = o.openImgs(out,
new UnsignedByteType()).get(0);
assertImagesEqual(before, after);
}
示例15: doTestGenerics
import net.imglib2.exception.IncompatibleTypeException; //导入依赖的package包/类
private <T extends RealType<T> & NativeType<T>> void doTestGenerics(
final T type) throws IncompatibleTypeException, ImgIOException
{
ImgPlus<T> imgPlus = null;
final ImgFactory<T> factory = new ArrayImgFactory<T>().imgFactory(type);
// Try each rawtype openImg method
imgPlus = imgOpener.openImgs(id, type).get(0);
assertNotNull(imgPlus);
imgPlus = null;
imgPlus = imgOpener.openImgs(id, type, new SCIFIOConfig()).get(0);
assertNotNull(imgPlus);
imgPlus = null;
imgPlus = imgOpener.openImgs(id, factory, type).get(0);
assertNotNull(imgPlus);
imgPlus = null;
}