@SuppressWarnings({ "unchecked", "rawtypes" }) public static < T extends RealType< T > > RandomAccessibleInterval< T > getImage( final T type, ImgLoader imgLoader, final ViewId view, final boolean normalize ) { if ( (RealType)type instanceof FloatType ) return (RandomAccessibleInterval)imgLoader.getSetupImgLoader( view.getViewSetupId() ).getFloatImage( view.getTimePointId(), normalize, LOAD_COMPLETELY ); else if ( (RealType)type instanceof UnsignedShortType ) return (RandomAccessibleInterval)imgLoader.getSetupImgLoader( view.getViewSetupId() ).getImage( view.getTimePointId(), LOAD_COMPLETELY ); else return null; }
public FusionResult( final String filepath, final String filepattern, final TimePoints timepoints, final int numSlices, final double sliceValueMin, final double sliceValueMax, final Map< Integer, AffineTransform3D > perTimePointFusionTransforms ) { final HashMap< Integer, Integer > setupIdToChannelId = new HashMap<>(); setupIdToChannelId.put( 0, 0 ); final ImgLoader fusionLoader = new FusionImageLoader<>( filepath +"/" + filepattern, setupIdToChannelId, numSlices, new FusionImageLoader.Gray32ImagePlusLoader(), sliceValueMin, sliceValueMax ); final int setupId = 0; final String name = "fused"; final int timepointId = timepoints.getTimePointsOrdered().get( 0 ).getId(); final Dimensions size = fusionLoader.getSetupImgLoader( setupId ).getImageSize( timepointId ); final VoxelDimensions voxelSize = fusionLoader.getSetupImgLoader( setupId ).getVoxelSize( timepointId ); final BasicViewSetup setup = new BasicViewSetup( setupId, name, size, voxelSize ); desc = new SequenceDescriptionMinimal( timepoints, Entity.idMap( Arrays.asList( setup ) ), fusionLoader, null ); final ArrayList< ViewRegistration > registrations = new ArrayList<>(); for ( final TimePoint timepoint : timepoints.getTimePointsOrdered() ) registrations.add( new ViewRegistration( timepoint.getId(), 0, perTimePointFusionTransforms.get( timepoint.getId() ) ) ); regs = new ViewRegistrations( registrations ); }
@Override public T getImageType() { @SuppressWarnings("unchecked") final T res = (T) wrappedImgLoader.getSetupImgLoader( setupId ).getImageType(); return res; }
public static void main(String[] args) { SpimData sd2 = createSpimDataFromUserInput(); RandomAccessibleInterval< UnsignedShortType > img2 = (RandomAccessibleInterval< UnsignedShortType >) sd2.getSequenceDescription().getImgLoader().getSetupImgLoader( 0 ).getImage( 0, null ); ImageJFunctions.show( img2 ); if (true) return; List<double[]> channelShifts = new ArrayList<>(); channelShifts.add( new double[3] ); List<double[]> illumShifts = new ArrayList<>(); illumShifts.add( new double[3] ); List<double[]> timeShifts = new ArrayList<>(); timeShifts.add( new double[3] ); timeShifts.add( new double[3] ); List<double[]> tileShifts = new ArrayList<>(); tileShifts.add( new double[3] ); SpimData sd = createSpimData( 1000, new double[] {1, 1, 3 }, Intervals.createMinMax( 0,0,0,256,256,100 ), Intervals.createMinMax( 0,0,0,256,256,100 ), 1, new double[] {0, 90}, channelShifts, illumShifts, timeShifts, tileShifts , 0.9, true); RandomAccessibleInterval< UnsignedShortType > img = (RandomAccessibleInterval< UnsignedShortType >) sd.getSequenceDescription().getImgLoader().getSetupImgLoader( 0 ).getImage( 1, null ); ImageJFunctions.show( img ); }
@Override public Dimensions getImageSize(int timepointId) { return wrappedImgLoader.getSetupImgLoader( setupId ).getImageSize( timepointId ); }
@Override public VoxelDimensions getVoxelSize(int timepointId) { return wrappedImgLoader.getSetupImgLoader( setupId ).getVoxelSize( timepointId ); } }
public static RandomAccessibleInterval< FloatType > openAtLowestLevelFloat( final ImgLoader imgLoader, final ViewId view, final AffineTransform3D t ) { final RandomAccessibleInterval< FloatType > input; if ( MultiResolutionImgLoader.class.isInstance( imgLoader ) ) { final MultiResolutionImgLoader mrImgLoader = ( MultiResolutionImgLoader ) imgLoader; final double[][] mipmapResolutions = mrImgLoader.getSetupImgLoader( view.getViewSetupId() ).getMipmapResolutions(); final int bestLevel = findLowestResolutionLevel( mrImgLoader, view ); IOFunctions.println( "(" + new Date(System.currentTimeMillis()) + "): Loading level " + Util.printCoordinates( mipmapResolutions[ bestLevel ] ) ); input = mrImgLoader.getSetupImgLoader( view.getViewSetupId() ).getFloatImage( view.getTimePointId(), bestLevel, false ); if ( t != null ) t.set( mrImgLoader.getSetupImgLoader( view.getViewSetupId() ).getMipmapTransforms()[ bestLevel ] ); } else { IOFunctions.println( "(" + new Date(System.currentTimeMillis()) + "): Loading full-resolution images :( " ); input = imgLoader.getSetupImgLoader( view.getViewSetupId() ).getFloatImage( view.getTimePointId(), false ); if ( t != null ) t.identity(); } return input; }
@SuppressWarnings({ "unchecked", "rawtypes" }) public PSFExtraction( final SpimData2 data, final ViewId viewId, final String label, final boolean useCorresponding, final T type, final long[] size, final boolean multithreaded ) { this( (RandomAccessibleInterval)data.getSequenceDescription().getImgLoader().getSetupImgLoader( viewId.getViewSetupId() ).getImage( viewId.getTimePointId() ), getPoints( data, viewId, label, useCorresponding ), type, size, multithreaded ); }
/** * @param setup - the {@link BasicViewSetup} for which to get the image size * @param t - the {@link TimePoint} from which to load the image size * @param loader - the {@link ImgLoader} * @return - the image size of this {@link ViewSetup} */ public static Dimensions getSizeOrLoad( final BasicViewSetup setup, final TimePoint t, final ImgLoader loader ) { if ( setup.hasSize() ) return setup.getSize(); else return loader.getSetupImgLoader( setup.getId() ).getImageSize( t.getId() ); } }
/** * @param setup - the {@link BasicViewSetup} for which to get the Voxelsize * @param t - the {@link TimePoint} from which to load the Voxelsize * @param loader - the {@link ImgLoader} * @return - the Voxelsize for this {@link ViewSetup} */ public static VoxelDimensions getVoxelSizeOrLoad( final BasicViewSetup setup, final TimePoint t, final ImgLoader loader ) { if ( setup.hasVoxelSize() ) return setup.getVoxelSize(); else return loader.getSetupImgLoader( setup.getId() ).getVoxelSize( t.getId() ); }
RandomAccessibleInterval< FloatType > img = spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( vd.getViewSetupId() ).getFloatImage( vd.getTimePointId(), false );
final Dimensions size = fusionLoader.getSetupImgLoader( setupId ).getImageSize( timepointId ); final VoxelDimensions voxelSize = fusionLoader.getSetupImgLoader( setupId ).getVoxelSize( timepointId ); final BasicViewSetup setup = new BasicViewSetup( setupId, name, size, voxelSize ); setup.setAttribute( new Channel( channels.get( setupId ) ) );
final RandomAccessibleInterval input = imgLoader.getSetupImgLoader( viewId.getViewSetupId() ).getImage( viewId.getTimePointId() );
export.exportImage( ((ImgLoader)spimData.getSequenceDescription().getImgLoader()).getSetupImgLoader( viewId.getViewSetupId() ).getFloatImage( viewId.getTimePointId(), false ), name ); else ( RandomAccessibleInterval< UnsignedShortType > ) ((ImgLoader)spimData.getSequenceDescription().getImgLoader()).getSetupImgLoader( viewId.getViewSetupId() ).getImage( viewId.getTimePointId() ); export.exportImage( img, name );
for (ViewSetup setup : setups) Dimensions siz = imgLoader.getSetupImgLoader( setup.getId() ).getImageSize( tp.getId() ); setup.setSize( siz );
VoxelDimensions voxelSize = sequenceDescription.getImgLoader().getSetupImgLoader( viewId.getViewSetupId() ).getVoxelSize( viewId.getTimePointId() ); if ( voxelSize == null )
input = imgLoader.getSetupImgLoader( vd.getViewSetupId() ).getFloatImage( vd.getTimePointId(), false, LOAD_COMPLETELY ); else input = imgLoader.getSetupImgLoader( vd.getViewSetupId() ).getFloatImage( vd.getTimePointId(), false );
public static int inputBytePerPixel( final ViewId viewId, final SpimData2 spimData ) { SetupImgLoader< ? > loader = spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( viewId.getViewSetupId() ); Object type = loader.getImageType(); if ( UnsignedByteType.class.isInstance( type ) ) return 1; else if ( UnsignedShortType.class.isInstance( type ) ) return 2; else return 4; } }
public static RandomAccessibleInterval openAtLowestLevel( final ImgLoader imgLoader, final ViewId view, final AffineTransform3D t ) { final RandomAccessibleInterval input; if ( MultiResolutionImgLoader.class.isInstance( imgLoader ) ) { final MultiResolutionImgLoader mrImgLoader = ( MultiResolutionImgLoader ) imgLoader; final double[][] mipmapResolutions = mrImgLoader.getSetupImgLoader( view.getViewSetupId() ).getMipmapResolutions(); final int bestLevel = findLowestResolutionLevel( mrImgLoader, view ); IOFunctions.println( "(" + new Date(System.currentTimeMillis()) + "): Loading level " + Util.printCoordinates( mipmapResolutions[ bestLevel ] ) ); input = mrImgLoader.getSetupImgLoader( view.getViewSetupId() ).getImage( view.getTimePointId(), bestLevel ); if ( t != null ) t.set( mrImgLoader.getSetupImgLoader( view.getViewSetupId() ).getMipmapTransforms()[ bestLevel ] ); } else { IOFunctions.println( "(" + new Date(System.currentTimeMillis()) + "): Loading full-resolution images :( " ); input = imgLoader.getSetupImgLoader( view.getViewSetupId() ).getImage( view.getTimePointId() ); if ( t != null ) t.identity(); } return input; }
return (RandomAccessibleInterval< FloatType >) wrappedImgLoader.getSetupImgLoader( setupId ).getFloatImage( timepointId, false, hints ); (RandomAccessibleInterval< T >) wrappedImgLoader.getSetupImgLoader( setupId ).getImage( timepointId, hints ), getBrightImg( new ViewId( timepointId, setupId ) ),