bdv.viewer.Source Java Examples
The following examples show how to use
bdv.viewer.Source.
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: RenderUnit.java From paintera with GNU General Public License v2.0 | 6 votes |
public RenderUnit( final ThreadGroup threadGroup, final Supplier<ViewerState> viewerState, final Function<Source<?>, Interpolation> interpolation, final AccumulateProjectorFactory<ARGBType> accumulateProjectorFactory, final CacheControl cacheControl, final long targetRenderNanos, final int numRenderingThreads, final ExecutorService renderingExecutorService) { this.threadGroup = threadGroup; this.viewerState = viewerState; this.interpolation = interpolation; this.accumulateProjectorFactory = accumulateProjectorFactory; this.cacheControl = cacheControl; this.targetRenderNanos = targetRenderNanos; this.numRenderingThreads = numRenderingThreads; this.renderingExecutorService = renderingExecutorService; update(); }
Example #2
Source File: SourceInfo.java From paintera with GNU General Public License v2.0 | 6 votes |
public synchronized <D, T> void addState( final Source<T> source, final SourceState<D, T> state) { this.states.put(source, state); // composites needs to hold a valid (!=null) value for source whenever // viewer is updated this.composites.put(source, state.compositeProperty().getValue()); this.sources.add(source); state.isVisibleProperty().addListener((obs, oldv, newv) -> updateVisibleSources()); if (this.currentSource.get() == null) { this.currentSource.set(source); } state.compositeProperty().addListener((obs, oldv, newv) -> this.composites.put(source, newv)); }
Example #3
Source File: ValueDisplayListener.java From paintera with GNU General Public License v2.0 | 6 votes |
private <D> void getInfo() { final Optional<Source<?>> optionalSource = Optional.ofNullable(currentSource.getValue()); if (optionalSource.isPresent() && optionalSource.get() instanceof DataSource<?, ?>) { @SuppressWarnings("unchecked") final DataSource<D, ?> source = (DataSource<D, ?>) optionalSource.get(); final ViewerState state = viewer.getState(); final Interpolation interpolation = this.interpolation.apply(source); final AffineTransform3D screenScaleTransform = new AffineTransform3D(); viewer.getRenderUnit().getScreenScaleTransform(0, screenScaleTransform); final int level = state.getBestMipMapLevel(screenScaleTransform, source); final AffineTransform3D affine = new AffineTransform3D(); source.getSourceTransform(0, level, affine); final RealRandomAccess<D> access = RealViews.transformReal( source.getInterpolatedDataSource( 0, level, interpolation ), affine ).realRandomAccess(); final D val = getVal(x, y, access, viewer); submitValue.accept(stringConverterFromSource(source).apply(val)); } }
Example #4
Source File: DataSource.java From paintera with GNU General Public License v2.0 | 6 votes |
/** * Returns transforms for all scale levels in the given {@link Source} into the world coordinates * without the half-pixel offset. This is useful for converting between coordinate spaces * when pixel coordinates represent the top-left corner of the pixel instead of its center. * @param source * @param t * @return */ static AffineTransform3D[] getUnshiftedWorldTransforms(final Source<?> source, final int t) { // get mipmap transforms without the half-pixel shift final AffineTransform3D[] unshiftedWorldTransforms = new AffineTransform3D[source.getNumMipmapLevels()]; final AffineTransform3D fullResToWorldTransform = new AffineTransform3D(); source.getSourceTransform(0, 0, fullResToWorldTransform); for (int i = 0; i < unshiftedWorldTransforms.length; ++i) { final double[] scales = DataSource.getRelativeScales(source, 0, 0, i); final Scale3D toFullResTransform = new Scale3D(scales); unshiftedWorldTransforms[i] = new AffineTransform3D(); unshiftedWorldTransforms[i].preConcatenate(toFullResTransform).preConcatenate(fullResToWorldTransform); } return unshiftedWorldTransforms; }
Example #5
Source File: OrthogonalViews.java From paintera with GNU General Public License v2.0 | 6 votes |
private static ViewerAndTransforms create( final GlobalTransformManager manager, final CacheControl cacheControl, final ViewerOptions optional, final ViewerAxis axis, final Function<Source<?>, Interpolation> interpolation) { final AffineTransform3D globalToViewer = ViewerAxis.globalToViewer(axis); LOG.debug("Generating viewer, axis={}, globalToViewer={}", axis, globalToViewer); final ViewerPanelFX viewer = new ViewerPanelFX( 1, cacheControl, optional, interpolation ); final AffineTransformWithListeners displayTransform = new AffineTransformWithListeners(); final AffineTransformWithListeners globalToViewerTransform = new AffineTransformWithListeners(globalToViewer); return new ViewerAndTransforms(viewer, manager, displayTransform, globalToViewerTransform); }
Example #6
Source File: FitToInterval.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public void onChanged(final Change<? extends Source<?>> change) { while (change.next()) if (change.wasAdded() && change.getList().size() == 1) { final Source<?> addedSource = change.getAddedSubList().get(0); final double[] min = Arrays.stream(Intervals.minAsLongArray(addedSource.getSource( 0, 0 ))).asDoubleStream().toArray(); final double[] max = Arrays.stream(Intervals.maxAsLongArray(addedSource.getSource( 0, 0 ))).asDoubleStream().toArray(); final AffineTransform3D tf = new AffineTransform3D(); addedSource.getSourceTransform(0, 0, tf); tf.apply(min, min); tf.apply(max, max); fitToInterval.fit(Intervals.smallestContainingInterval(new FinalRealInterval(min, max))); } }
Example #7
Source File: CompositeProjectorPreMultiply.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public VolatileProjector createAccumulateProjector( final ArrayList<VolatileProjector> sourceProjectors, final ArrayList<Source<?>> sources, final ArrayList<? extends RandomAccessible<? extends ARGBType>> sourceScreenImages, final RandomAccessibleInterval<ARGBType> targetScreenImage, final int numThreads, final ExecutorService executorService) { final CompositeProjectorPreMultiply projector = new CompositeProjectorPreMultiply( sourceProjectors, sourceScreenImages, targetScreenImage, numThreads, executorService ); final ArrayList<Composite<ARGBType, ARGBType>> activeComposites = new ArrayList<>(); for (final Source<?> activeSource : sources) activeComposites.add(composites.get(activeSource)); projector.setComposites(activeComposites); return projector; }
Example #8
Source File: CompositeProjector.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public VolatileProjector createAccumulateProjector( final ArrayList<VolatileProjector> sourceProjectors, final ArrayList<Source<?>> sources, final ArrayList<? extends RandomAccessible<? extends A>> sourceScreenImages, final RandomAccessibleInterval<A> targetScreenImage, final int numThreads, final ExecutorService executorService) { final CompositeProjector<A> projector = new CompositeProjector<>( sourceProjectors, sourceScreenImages, targetScreenImage, numThreads, executorService ); final ArrayList<Composite<A, A>> activeComposites = new ArrayList<>(); for (final Source<?> activeSource : sources) activeComposites.add(composites.get(activeSource)); projector.setComposites(activeComposites); return projector; }
Example #9
Source File: ClearingCompositeProjector.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public VolatileProjector createAccumulateProjector( final ArrayList<VolatileProjector> sourceProjectors, final ArrayList<Source<?>> sources, final ArrayList<? extends RandomAccessible<? extends A>> sourceScreenImages, final RandomAccessibleInterval<A> targetScreenImage, final int numThreads, final ExecutorService executorService) { final ClearingCompositeProjector<A> projector = new ClearingCompositeProjector<>( sourceProjectors, sourceScreenImages, targetScreenImage, clearValue, numThreads, executorService ); final ArrayList<Composite<A, A>> activeComposites = new ArrayList<>(); for (final Source<?> activeSource : sources) activeComposites.add(composites.get(activeSource)); projector.setComposites(activeComposites); return projector; }
Example #10
Source File: LabelBlockLookupAllBlocks.java From paintera with GNU General Public License v2.0 | 6 votes |
public static LabelBlockLookupAllBlocks fromSource(final Source<?> source, final int... fallbackBlockSize) { if (fallbackBlockSize.length < 3) return fromSource(source); final long[][] dims = new long[source.getNumMipmapLevels()][3]; final int[][] blockSizes = new int[dims.length][3]; for (int level = 0; level < dims.length; ++level) { final RandomAccessibleInterval<?> rai = source.getSource(0, level); Arrays.setAll(dims[level], rai::dimension); if (rai instanceof AbstractCellImg<?, ?, ?, ?>) ((AbstractCellImg<?, ?, ?, ?>) rai).getCellGrid().cellDimensions(blockSizes[level]); else Arrays.setAll(blockSizes[level], d -> fallbackBlockSize[d]); } return new LabelBlockLookupAllBlocks(dims, blockSizes); }
Example #11
Source File: TranslateGroupManuallyPanel.java From BigStitcher with GNU General Public License v2.0 | 6 votes |
/** * try to unwrap source to get the view setup id of wrapped and transformed SpimData view * @param source - BigDataViewer source * @return - view setup id if we can unwrap, null else */ public static Integer getViewSetupIdFromBDVSource(Source<?> source) { if (TransformedSource.class.isInstance( source )) { Source< ? > wrappedSource = ((TransformedSource< ? >) source).getWrappedSource(); if (SpimSource.class.isInstance( wrappedSource )) { return ( (SpimSource<?> ) wrappedSource).getSetupId(); } else return null; } else return null; }
Example #12
Source File: ViewerState.java From paintera with GNU General Public License v2.0 | 5 votes |
public synchronized int getBestMipMapLevel(final AffineTransform3D screenScaleTransform, final Source<?> source, final int timepoint) { final AffineTransform3D screenTransform = new AffineTransform3D(); getViewerTransform(screenTransform); screenTransform.preConcatenate(screenScaleTransform); return MipmapTransforms.getBestMipMapLevel(screenTransform, source, timepoint); }
Example #13
Source File: OrthogonalViews.java From paintera with GNU General Public License v2.0 | 5 votes |
/** * * @param manager manages the transform from world coordinates to shared viewer space and is shared by all {@link ViewerPanelFX viewers}. * @param cacheControl shared between all {@link ViewerPanelFX viewers} * @param optional Options for {@link ViewerPanelFX} * @param bottomRight bottom right child * @param interpolation {@link Interpolation interpolation} lookup for every {@link Source} */ public OrthogonalViews( final GlobalTransformManager manager, final CacheControl cacheControl, final ViewerOptions optional, final BR bottomRight, final Function<Source<?>, Interpolation> interpolation) { this.manager = manager; this.topLeft = create(this.manager, cacheControl, optional, ViewerAxis.Z, interpolation); this.topRight = create(this.manager, cacheControl, optional, ViewerAxis.X, interpolation); this.bottomLeft = create(this.manager, cacheControl, optional, ViewerAxis.Y, interpolation); this.grid = new ResizableGridPane2x2<>(topLeft.viewer, topRight.viewer, bottomLeft.viewer, bottomRight); this.queue = cacheControl; }
Example #14
Source File: SourceInfoSerializer.java From paintera with GNU General Public License v2.0 | 5 votes |
@Override public JsonElement serialize(final SourceInfo src, final Type typeOfSrc, final JsonSerializationContext context) { final Map<String, Object> elements = new HashMap<>(); final List<Source<?>> sources = new ArrayList<>(src.trackSources()); LOG.debug("Serializing sources: {}", sources); final List<JsonElement> serializedSources = src .trackSources() .stream() .map(src::getState) .map(s -> { final JsonObject typeAndData = new JsonObject(); typeAndData.addProperty(STATE_TYPE_KEY, s.getClass().getName()); typeAndData.add(STATE_KEY, context.serialize(s, s.getClass())); return typeAndData; }) .collect(Collectors.toList()); LOG.debug("Serialized sources: {}", serializedSources); final int currentSourceIndex = src.currentSourceIndexProperty().get(); elements.put(NUM_SOURCES_KEY, sources.size()); elements.put(CURRENT_SOURCE_INDEX_KEY, currentSourceIndex); elements.put(SOURCES_KEY, serializedSources); return context.serialize(elements); }
Example #15
Source File: DataSource.java From paintera with GNU General Public License v2.0 | 5 votes |
/** * Convenience method to extract the relative scale of two levels of a {@link Source} at time {@code t}. * @param source Extract relative scale from this source * @param t Extract relative scale at this time points * @param level source level * @param targetLevel target level * @return ratio of diagonals of transforms at levels {@code targetLevel} and {@code level} for {@code source} at time {@code t}: * scale[targetLevel] / scale[level] */ static double[] getRelativeScales( final Source<?> source, final int t, final int level, final int targetLevel) { final double[] scale = getScale(source, t, level); final double[] targetScale = getScale(source, t, targetLevel); Arrays.setAll(targetScale, d -> targetScale[d] / scale[d]); return targetScale; }
Example #16
Source File: ValueDisplayListener.java From paintera with GNU General Public License v2.0 | 5 votes |
public ValueDisplayListener( final ViewerPanelFX viewer, final ObservableValue<Source<?>> currentSource, final Function<Source<?>, Interpolation> interpolation, final Consumer<String> submitValue) { super(); this.viewer = viewer; this.currentSource = currentSource; this.interpolation = interpolation; this.submitValue = submitValue; }
Example #17
Source File: SegmentMaskGenerators.java From paintera with GNU General Public License v2.0 | 5 votes |
LabelMultisetTypeMaskGenerator(final Source<?> source, final int level) { final double[] scales = DataSource.getRelativeScales(source, 0, 0, level); // check that all scales are integers assert Arrays.stream(scales).allMatch(scale -> Util.isApproxEqual(scale, Math.round(scale), 1e-7)); numFullResPixels = Arrays.stream(scales).mapToLong(Math::round).reduce(1, Math::multiplyExact); }
Example #18
Source File: MultiResolutionRendererGeneric.java From paintera with GNU General Public License v2.0 | 5 votes |
private static <T> RandomAccessible<T> getTransformedSource( final Source<T> source, final int timepoint, final AffineTransform3D viewerTransform, final AffineTransform3D screenScaleTransform, final int mipmapIndex, final CacheHints cacheHints, final Interpolation interpolation) { final RandomAccessibleInterval<T> img = source.getSource(timepoint, mipmapIndex); if (VolatileCachedCellImg.class.isInstance(img)) ((VolatileCachedCellImg<?, ?>) img).setCacheHints(cacheHints); final RealRandomAccessible<T> ipimg = source.getInterpolatedSource(timepoint, mipmapIndex, interpolation); final AffineTransform3D sourceToScreen = viewerTransform.copy(); final AffineTransform3D sourceTransform = new AffineTransform3D(); source.getSourceTransform(timepoint, mipmapIndex, sourceTransform); sourceToScreen.concatenate(sourceTransform); sourceToScreen.preConcatenate(screenScaleTransform); LOG.debug( "Getting transformed source {} (name={}) for t={} level={} transform={} screen-scale={} hints={} " + "interpolation={}", source, source.getName(), timepoint, mipmapIndex, sourceToScreen, screenScaleTransform, cacheHints, interpolation ); return RealViews.affine(ipimg, sourceToScreen); }
Example #19
Source File: OrthogonalViewsValueDisplayListener.java From paintera with GNU General Public License v2.0 | 5 votes |
public OrthogonalViewsValueDisplayListener( final Consumer<String> submitValue, final ObservableValue<Source<?>> currentSource, final Function<Source<?>, Interpolation> interpolation) { super(); this.submitValue = submitValue; this.currentSource = currentSource; this.interpolation = interpolation; }
Example #20
Source File: SourceInfo.java From paintera with GNU General Public License v2.0 | 5 votes |
public void moveSourceTo(final Source<?> source, final int index) { if (index >= 0 && index < sources.size() && sources.contains(source) && sources.indexOf(source) != index) { final ArrayList<Source<?>> copy = new ArrayList<>(this.sources); copy.remove(source); copy.add(index, source); final Source<?> currentSource = this.currentSource.get(); final int currentSourceIndex = copy.indexOf(currentSource); this.sources.clear(); this.sources.setAll(copy); this.currentSource.set(currentSource); this.currentSourceIndex.set(currentSourceIndex); } }
Example #21
Source File: SourceInfo.java From paintera with GNU General Public License v2.0 | 5 votes |
public ObservableBooleanValue isCurrentSource(final Source<?> source) { return Bindings.createBooleanBinding( () -> Optional.ofNullable(currentSource.get()).map(source::equals).orElse(false), currentSource ); }
Example #22
Source File: SourceInfo.java From paintera with GNU General Public License v2.0 | 5 votes |
private void updateVisibleSources() { final List<Source<?>> visibleSources = this.sources .stream() .filter(s -> states.get(s).isVisibleProperty().get()) .collect(Collectors.toList()); this.visibleSources.setAll(visibleSources); }
Example #23
Source File: SourceInfo.java From paintera with GNU General Public License v2.0 | 5 votes |
public List<SourceState<?, ?>> getDependents(final Source<?> source) { return Optional .ofNullable(this.states.get(source)) .map(this::getDependents) .orElseGet(ArrayList::new); }
Example #24
Source File: CreateDataset.java From paintera with GNU General Public License v2.0 | 5 votes |
public CreateDataset( Source<?> currentSource, Collection<SourceState<?, ?>> allSources) { this.currentSource = currentSource; this.allSources = new ArrayList<>(allSources); this.allSources.forEach(s -> { final MenuItem mi = new MenuItem(s.nameProperty().get()); mi.setOnAction(e -> this.populateFrom(s.getDataSource())); mi.setMnemonicParsing(false); this.populateFromSource.getItems().add(mi); }); this.populateFromSource.setVisible(this.allSources.size() > 0); Optional.ofNullable(currentSource).ifPresent(this::populateFrom); }
Example #25
Source File: CreateDataset.java From paintera with GNU General Public License v2.0 | 5 votes |
private void populateFrom(Source<?> source) { if (source == null) return; if (source instanceof N5DataSource<?, ?>) { N5DataSource<?, ?> n5s = (N5DataSource<?, ?>) source; if (n5s.meta() instanceof N5FSMeta) { n5Container.directoryProperty().setValue(new File(((N5FSMeta) n5s.meta()).basePath())); } } final RandomAccessibleInterval<?> data = source.getSource(0, 0); this.dimensions.getX().valueProperty().set(data.dimension(0)); this.dimensions.getY().valueProperty().set(data.dimension(1)); this.dimensions.getZ().valueProperty().set(data.dimension(2)); if (data instanceof AbstractCellImg<?, ?, ?, ?>) { final CellGrid grid = ((AbstractCellImg<?, ?, ?, ?>) data).getCellGrid(); this.blockSize.getX().valueProperty().set(grid.cellDimension(0)); this.blockSize.getY().valueProperty().set(grid.cellDimension(1)); this.blockSize.getZ().valueProperty().set(grid.cellDimension(2)); } AffineTransform3D transform = new AffineTransform3D(); source.getSourceTransform(0, 0, transform); this.resolution.getX().valueProperty().set(transform.get(0, 0)); this.resolution.getY().valueProperty().set(transform.get(1, 1)); this.resolution.getZ().valueProperty().set(transform.get(2, 2)); this.offset.getX().valueProperty().set(transform.get(0, 3)); this.offset.getY().valueProperty().set(transform.get(1, 3)); this.offset.getZ().valueProperty().set(transform.get(2, 3)); }
Example #26
Source File: CreateDatasetHandler.java From paintera with GNU General Public License v2.0 | 5 votes |
private static void createAndAddNewLabelDataset( final PainteraBaseView paintera, final Supplier<String> projectDirectory, final Consumer<Exception> exceptionHandler) { createAndAddNewLabelDataset( paintera, projectDirectory, exceptionHandler, paintera.sourceInfo().currentSourceProperty().get(), paintera.sourceInfo().trackSources().stream().toArray(Source[]::new)); }
Example #27
Source File: CreateDatasetHandler.java From paintera with GNU General Public License v2.0 | 5 votes |
public static void createAndAddNewLabelDataset( final PainteraBaseView pbv, final Supplier<String> projecDirectory, final Consumer<Exception> exceptionHandler, final Source<?> currentSource, final Source<?>... allSources ) { try { createAndAddNewLabelDataset(pbv, projecDirectory, currentSource, allSources); } catch (final Exception e) { exceptionHandler.accept(e); } }
Example #28
Source File: CreateDatasetHandler.java From paintera with GNU General Public License v2.0 | 5 votes |
private static void createAndAddNewLabelDataset( final PainteraBaseView pbv, final Supplier<String> projectDirectory, final Source<?> currentSource, final Source<?>... allSources) throws IOException { final CreateDataset cd = new CreateDataset(currentSource, Arrays.stream(allSources).map(pbv.sourceInfo()::getState).toArray(SourceState[]::new)); final Optional<Pair<N5FSMeta, String>> metaAndName = cd.showDialog(); if (metaAndName.isPresent()) { final N5FSMeta meta = metaAndName.get().getKey(); final N5Backend backend = N5Backend.createFrom( meta.getWriter(), meta.getDataset(), projectDirectory, pbv.getPropagationQueue()); pbv.addState(new ConnectomicsLabelState( backend, pbv.viewer3D().meshesGroup(), pbv.viewer3D().viewFrustumProperty(), pbv.viewer3D().eyeToWorldTransformProperty(), pbv.getMeshManagerExecutorService(), pbv.getMeshWorkerExecutorService(), pbv.getQueue(), 0, metaAndName.get().getValue(), N5Helpers.getResolution(meta.getWriter(), String.format("%s/data", meta.getDataset())), N5Helpers.getOffset(meta.getWriter(), String.format("%s/data", meta.getDataset())), null)); } }
Example #29
Source File: MaximumProjectorARGB.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
@Override public VolatileProjector createAccumulateProjector( ArrayList< VolatileProjector > sourceProjectors, ArrayList< Source< ? > > sources, ArrayList< ? extends RandomAccessible< ? extends ARGBType > > sourceScreenImages, RandomAccessibleInterval< ARGBType > targetScreenImage, int numThreads, ExecutorService executorService) { return new MaximumProjectorARGB( sourceProjectors, sourceScreenImages, targetScreenImage, numThreads, executorService ); }
Example #30
Source File: AveragingProjectorARGB.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
@Override public VolatileProjector createAccumulateProjector(ArrayList< VolatileProjector > sourceProjectors, ArrayList< Source< ? > > sources, ArrayList< ? extends RandomAccessible< ? extends ARGBType > > sourceScreenImages, RandomAccessibleInterval< ARGBType > targetScreenImage, int numThreads, ExecutorService executorService) { return new AveragingProjectorARGB( sourceProjectors, sourceScreenImages, targetScreenImage, numThreads, executorService ); }