Java Code Examples for mpicbg.spim.data.sequence.VoxelDimensions#dimension()
The following examples show how to use
mpicbg.spim.data.sequence.VoxelDimensions#dimension() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Apply_Transformation.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
public static void setModelToCalibration( final SpimData spimData, final ViewId viewId, final double minResolution ) { setModelToIdentity( spimData, viewId ); final ViewRegistrations viewRegistrations = spimData.getViewRegistrations(); final ViewRegistration r = viewRegistrations.getViewRegistration( viewId ); final ViewDescription viewDescription = spimData.getSequenceDescription().getViewDescription( viewId.getTimePointId(), viewId.getViewSetupId() ); VoxelDimensions voxelSize = ViewSetupUtils.getVoxelSizeOrLoad( viewDescription.getViewSetup(), viewDescription.getTimePoint(), spimData.getSequenceDescription().getImgLoader() ); final double calX = voxelSize.dimension( 0 ) / minResolution; final double calY = voxelSize.dimension( 1 ) / minResolution; final double calZ = voxelSize.dimension( 2 ) / minResolution; final AffineTransform3D m = new AffineTransform3D(); m.set( calX, 0.0f, 0.0f, 0.0f, 0.0f, calY, 0.0f, 0.0f, 0.0f, 0.0f, calZ, 0.0f ); final ViewTransform vt = new ViewTransformAffine( "calibration", m ); r.preconcatenateTransform( vt ); }
Example 2
Source File: ProcessFusion.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
protected Blending getBlending( final Interval interval, final ViewDescription desc, final ImgLoader imgLoader ) { final float[] blending = ProcessFusion.defaultBlendingRange.clone(); final float[] border = ProcessFusion.defaultBlendingBorder.clone(); final float minRes = (float)getMinRes( desc, imgLoader ); final VoxelDimensions voxelSize = ViewSetupUtils.getVoxelSizeOrLoad( desc.getViewSetup(), desc.getTimePoint(), imgLoader ); if ( ProcessFusion.defaultAdjustBlendingForAnisotropy ) { for ( int d = 0; d < 2; ++d ) { blending[ d ] /= ( float ) voxelSize.dimension( d ) / minRes; border[ d ] /= ( float ) voxelSize.dimension( d ) / minRes; } } return new Blending( interval, border, blending ); }
Example 3
Source File: ProcessFusion.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
protected < T extends RealType< T > > ContentBased< T > getContentBased( final RandomAccessibleInterval< T > img, final ViewDescription desc, final ImgLoader imgLoader ) { final double[] sigma1 = ProcessFusion.defaultContentBasedSigma1.clone(); final double[] sigma2 = ProcessFusion.defaultContentBasedSigma2.clone(); final double minRes = getMinRes( desc, imgLoader ); final VoxelDimensions voxelSize = ViewSetupUtils.getVoxelSizeOrLoad( desc.getViewSetup(), desc.getTimePoint(), imgLoader ); if ( ProcessFusion.defaultAdjustContentBasedSigmaForAnisotropy ) { for ( int d = 0; d < 2; ++d ) { sigma1[ d ] /= voxelSize.dimension( d ) / minRes; sigma2[ d ] /= voxelSize.dimension( d ) / minRes; } } return new ContentBased<T>( img, bb.getImgFactory( new ComplexFloatType() ), sigma1, sigma2); }
Example 4
Source File: TileConfigurationHelpers.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
public static Map<ViewId, Translation3D> getTransformsForData(Map<ViewId, Translation3D> locations, boolean pixelUnits, AbstractSpimData< ? > data ) { final Map<ViewId, Translation3D> res = new HashMap<>(); final Set< ViewId > vidsWithTransformations = locations.keySet(); final Collection< BasicViewDescription< ? > > vds = (Collection< BasicViewDescription< ? > >) data.getSequenceDescription().getViewDescriptions().values(); for ( BasicViewDescription< ? > vd : vds ) { ViewId key; if (vidsWithTransformations.contains( vd )) key = vd; else if (vidsWithTransformations.contains( new ViewId(-1, vd.getViewSetupId()) )) key = new ViewId(-1, vd.getViewSetupId()); else continue; final ViewRegistration vr = data.getViewRegistrations().getViewRegistration( vd ); final AffineTransform3D calib = new AffineTransform3D(); calib.set( vr.getTransformList().get( vr.getTransformList().size() - 1 ).asAffine3D().getRowPackedCopy() ); final VoxelDimensions voxelDims = vd.getViewSetup().getVoxelSize(); final Translation3D translation3d = locations.get( key ); final double[] translationVec = translation3d.getTranslationCopy(); if (!pixelUnits) for (int d = 0; d<voxelDims.numDimensions(); d++) translationVec[d] /= voxelDims.dimension( d ); for (int d = 0; d<calib.numDimensions(); d++) translationVec[d] *= calib.get( d, d ); res.put( new ViewId(vd.getTimePointId(), vd.getViewSetupId()), new Translation3D( translationVec ) ); } return res; }
Example 5
Source File: DifferenceOf.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public int downsampleFactor( final int downsampleXY, final int downsampleZ, final VoxelDimensions v ) { final double calXY = Math.min( v.dimension( 0 ), v.dimension( 1 ) ); final double calZ = v.dimension( 2 ) * downsampleZ; final double log2ratio = Math.log( calZ / calXY ) / Math.log( 2 ); final double exp2; if ( downsampleXY == 0 ) exp2 = Math.pow( 2, Math.floor( log2ratio ) ); else exp2 = Math.pow( 2, Math.ceil( log2ratio ) ); return (int)Math.round( exp2 ); }
Example 6
Source File: StackList.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
/** * Assembles the {@link ViewRegistration} object consisting of a list of {@link ViewRegistration}s for all {@link ViewDescription}s that are present * * @param viewDescriptionList * @param minResolution - the smallest resolution in any dimension (distance between two pixels in the output image will be that wide) * @return */ protected static ViewRegistrations createViewRegistrations( final Map< ViewId, ViewDescription > viewDescriptionList, final double minResolution ) { final HashMap< ViewId, ViewRegistration > viewRegistrationList = new HashMap< ViewId, ViewRegistration >(); for ( final ViewDescription viewDescription : viewDescriptionList.values() ) if ( viewDescription.isPresent() ) { final ViewRegistration viewRegistration = new ViewRegistration( viewDescription.getTimePointId(), viewDescription.getViewSetupId() ); final VoxelDimensions voxelSize = viewDescription.getViewSetup().getVoxelSize(); final double calX = voxelSize.dimension( 0 ) / minResolution; final double calY = voxelSize.dimension( 1 ) / minResolution; final double calZ = voxelSize.dimension( 2 ) / minResolution; final AffineTransform3D m = new AffineTransform3D(); m.set( calX, 0.0f, 0.0f, 0.0f, 0.0f, calY, 0.0f, 0.0f, 0.0f, 0.0f, calZ, 0.0f ); final ViewTransform vt = new ViewTransformAffine( "calibration", m ); viewRegistration.preconcatenateTransform( vt ); viewRegistrationList.put( viewRegistration, viewRegistration ); } return new ViewRegistrations( viewRegistrationList ); }
Example 7
Source File: Specify_Calibration.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
public static ArrayList< Cal > findCalibrations( final AbstractSpimData< ? extends AbstractSequenceDescription< ?, ?, ? > > spimData, final List< ViewId > viewIds ) { // this is the same for all timepoints, we are just interested in the ViewSetup final TimePoint t = spimData.getSequenceDescription().getTimePoints().getTimePointsOrdered().get( 0 ); final ArrayList< Cal > calibrations = new ArrayList< Cal >(); for ( final ViewId viewId : viewIds ) { if ( viewId.getTimePointId() != t.getId() ) continue; final BasicViewDescription< ? > vd = spimData.getSequenceDescription().getViewDescriptions().get( viewId ); final BasicViewSetup vs = vd.getViewSetup(); final String name; if ( ViewSetup.class.isInstance( vs ) ) { name = "angle: " + ((ViewSetup)vs).getAngle().getName() + " channel: " + ((ViewSetup)vs).getChannel().getName() + " illum: " + ((ViewSetup)vs).getIllumination().getName() + ", present at timepoint: " + t.getName() + ": " + vd.isPresent(); } else { name = "viewsetup: " + vs.getId() + ", present at timepoint: " + t.getName() + ": " + vd.isPresent(); } // only consider voxelsizes as defined in the XML VoxelDimensions voxelSize = ViewSetupUtils.getVoxelSize( vs ); if ( voxelSize == null ) voxelSize = new FinalVoxelDimensions( "", new double[]{ 1, 1, 1 } ); final double x = voxelSize.dimension( 0 ); final double y = voxelSize.dimension( 1 ); final double z = voxelSize.dimension( 2 ); String unit = voxelSize.unit(); if ( unit == null ) unit = ""; IOFunctions.println( "cal: [" + x + ", " + y + ", " + z + "] " + unit + " -- " + name ); final Cal calTmp = new Cal( new double[]{ x, y, z }, unit ); boolean foundMatch = false; for ( int j = 0; j < calibrations.size() && !foundMatch; ++j ) { final Cal cal = calibrations.get( j ); if ( cal.equals( calTmp ) ) { cal.increaseCount(); foundMatch = true; } } if ( !foundMatch ) calibrations.add( calTmp ); } return calibrations; }
Example 8
Source File: SlideBook6.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
public static void applyAxis(final SpimData data, final double minResolution) { ViewRegistrations viewRegistrations = data.getViewRegistrations(); for (final ViewDescription vd : data.getSequenceDescription().getViewDescriptions().values()) { if (vd.isPresent()) { final Angle a = vd.getViewSetup().getAngle(); if (a.hasRotation()) { final ViewRegistration vr = viewRegistrations.getViewRegistration(vd); final Dimensions dim = vd.getViewSetup().getSize(); VoxelDimensions voxelSize = ViewSetupUtils.getVoxelSizeOrLoad(vd.getViewSetup(), vd.getTimePoint(), data.getSequenceDescription().getImgLoader()); final double calX = voxelSize.dimension(0) / minResolution; final double calY = voxelSize.dimension(1) / minResolution; final double calZ = voxelSize.dimension(2) / minResolution; AffineTransform3D calModel = new AffineTransform3D(); calModel.set( 1, 0, 0, -dim.dimension(0) / 2 * calX, 0, 1, 0, -dim.dimension(1) / 2 * calY, 0, 0, 1, -dim.dimension(2) / 2 * calZ); ViewTransform vt = new ViewTransformAffine("Center view", calModel); vr.preconcatenateTransform(vt); final double[] tmp = new double[16]; final double[] axis = a.getRotationAxis(); final double degrees = a.getRotationAngleDegrees(); final AffineTransform3D rotModel = new AffineTransform3D(); final String d; if (axis[0] == 1 && axis[1] == 0 && axis[2] == 0) { rotModel.rotate(0, Math.toRadians(degrees)); d = "Rotation around x-axis by " + degrees + " degrees"; } else if (axis[0] == 0 && axis[1] == 1 && axis[2] == 0) { rotModel.rotate(1, Math.toRadians(degrees)); d = "Rotation around y-axis by " + degrees + " degrees"; } else if (axis[0] == 0 && axis[0] == 0 && axis[2] == 1) { rotModel.rotate(2, Math.toRadians(degrees)); d = "Rotation around z-axis by " + degrees + " degrees"; } else { IOFunctions.println("Arbitrary rotation axis not supported yet."); continue; } vt = new ViewTransformAffine(d, rotModel); vr.preconcatenateTransform(vt); vr.updateModel(); } } } }