void getUniverse() { if (universe != null) return; universe = new Image3DUniverse(); universe.show(); }
/** * Add a new image as a content, displaying it as orthoslices. Default * parameters are used for its attributes: * <ul> * <li>color: null * <li>name: title of the image * <li>threshold: the default threshold, as returned by * Content.getDefaultTreshold() * <li>channels: all color channels r, g, b * </ul> * * @param image the image to display * @return the Content which was added, null if any error occurred. */ public Content addOrthoslice(final ImagePlus image, final int res) { return addContent(image, ContentConstants.ORTHO, res); }
public Collection<Future<Content>> addContentLater(final String file) { final Map<String, CustomMesh> meshes = MeshLoader.load(file); if (meshes == null) return null; final List<Content> contents = new ArrayList<Content>(); for (final Map.Entry<String, CustomMesh> entry : meshes.entrySet()) { String name = entry.getKey(); name = getSafeContentName(name); final CustomMesh mesh = entry.getValue(); final Content content = createContent(mesh, name); contents.add(content); } return addContentLater(contents); }
/** * Display next timepoint. */ public void next() { if (univ.getContents().size() == 0) return; final int curr = univ.getCurrentTimepoint(); if (curr == univ.getEndTime()) return; univ.showTimepoint(curr + 1); }
/** * Display previous timepoint. */ public void previous() { if (univ.getContents().size() == 0) return; final int curr = univ.getCurrentTimepoint(); if (curr == univ.getStartTime()) return; univ.showTimepoint(curr - 1); }
@Override public void run(final String ignore) { final ImageStack stack = new ImageStack(3, 3); for (int i = 0; i < 3; ++i) { final byte[] pixels = new byte[9]; if (i == 1) pixels[4] = (byte) 255; final ByteProcessor bp = new ByteProcessor(3, 3); bp.setPixels(pixels); stack.addSlice("", bp); } final ImagePlus i = new ImagePlus("test", stack); i.show(); final Image3DUniverse univ = new Image3DUniverse(512, 512); univ.show(); GUI.center(univ.getWindow()); final boolean[] channels = { true, true, true }; final Content c = univ.addContent(i, new Color3f(Color.white), "Volume Rendering of a Single Voxel at (1,1,1)", 10, // threshold channels, 1, // resampling factor ContentConstants.VOLUME); final List<Point3f> linePoints = new ArrayList<Point3f>(); linePoints.add(new Point3f(1, 1, 1)); linePoints.add(new Point3f(2, 2, 2)); univ.addLineMesh(linePoints, new Color3f(Color.red), "Line from (1,1,1) to (2,2,2)", false); univ.resetView(); } }
@Override public void run(ImageProcessor ip) { if(imp.getStackSize() > 1 || !isPow2(imp.getWidth()) || !isPow2(imp.getHeight())) { IJ.error("Only one slice allowed, whose dimensions must" + " be a power of 2"); return; } bImage = createImage(); univ = new Image3DUniverse(); BranchGroup bg = new BranchGroup(); bg.addChild(createShape()); bg.compile(); univ.getScene().addChild(bg); univ.show(); univ.getCanvas().addMouseListener(this); univ.getCanvas().addMouseMotionListener(this); updater = new ImageUpdater(); ImagePlus.addImageListener(this); imp.show(); }
universe = new Image3DUniverse(); universe.show(); content.setUserData(vasculature); content.display(contentNode); universe.addContent(content); universe.setInteractiveBehavior( new CustomVolumeBehavior2(universe, content, volumes, volumesPanel, imagePlus, originalImage)); universe.setShowBoundingBoxUponSelection(false); universe.getWindow().add(volumesPanel,BorderLayout.SOUTH); universe.getWindow().pack();
@Override public void run(final String arg) { final ImagePlus image = WindowManager.getCurrentImage(); try { final Image3DUniverse univ = new Image3DUniverse(); univ.show(); GUI.center(univ.getWindow()); if (arg != null && !arg.equals("")) importContent(arg); // only when there is an image and we are not called // from a macro else if (image != null && !IJ.isMacro()) univ.getExecuter().addContent( image, null); } catch (final Exception e) { final StringBuffer buf = new StringBuffer(); final StackTraceElement[] st = e.getStackTrace(); buf.append("An unexpected exception occurred. \n" + "Please mail me the following lines if you \n" + "need help.\n" + "bene.schmid@gmail.com\n \n"); buf.append(e.getClass().getName() + ":" + e.getMessage() + "\n"); for (int i = 0; i < st.length; i++) { buf.append(" at " + st[i].getClassName() + "." + st[i].getMethodName() + "(" + st[i].getFileName() + ":" + st[i].getLineNumber() + ")\n"); } new ij.text.TextWindow("Error", buf.toString(), 500, 400); } }
@Override public TrackMateModelView create( final Model model, final Settings settings, final SelectionModel selectionModel ) final Image3DUniverse universe = new Image3DUniverse(); final ImageWindow3D win = new ImageWindow3D( "TrackMate 3D Viewer", universe ); win.setIconImage( TrackMateWizard.TRACKMATE_ICON.getImage() ); universe.init( win ); win.pack(); win.setVisible( true ); universe.addContentLater( cimp ); universe.addContentLater( cimp );
for (int i = 0; i < choices.length - 1; ++i) { final String contentsString = Image3DUniverse.universes.get(i).allContentsString(); String shortContentsString; if (contentsString.length() == 0) shortContentsString = "[Empty]"; univ = new Image3DUniverse(512, 512); univ.show(); GUI.center(univ.getWindow());
public static void main(final String[] args) { final ij3d.Image3DUniverse u = new ij3d.Image3DUniverse(); u.show(); final List<Point3f> pts = new ArrayList<Point3f>(); pts.add(new Point3f(0, 0, 0)); pts.add(new Point3f(1, 0, 0)); pts.add(new Point3f(1, 1, 0)); final CustomTransparentTriangleMesh m = new CustomTransparentTriangleMesh(pts); final List<Color4f> cols = new ArrayList<Color4f>(); cols.add(new Color4f(0, 1, 1, 0)); cols.add(new Color4f(1, 0, 1, 0.5f)); cols.add(new Color4f(1, 1, 0, 1)); m.setTransparentColor(cols); u.addCustomMesh(m, "lkjl"); } }
@Override public void run(ImageProcessor arg0) { Image3DUniverse univ = new Image3DUniverse(512, 512); Content c = univ.addVoltex(image, null, image.getTitle(), 0, new boolean[] {true, true, true}, 1); volume = ((VoltexGroup)c.getContent()).getRenderer().getVolume(); univ.show(); }
/** * @param args */ public static void main(String[] args) { System.out.println(ImageJ_3D_Viewer.getJava3DVersion()); File file = new File(AppUtils.getBaseDirectory(TrackMate.class), "samples/FakeTracks.xml"); ij.ImageJ.main(args); TmXmlReader reader = new TmXmlReader(file); Model model = reader.getModel(); Image3DUniverse universe = new Image3DUniverse(); universe.show(); SpotDisplayer3D displayer = new SpotDisplayer3D(model, new SelectionModel(model), universe); displayer.render(); displayer.setDisplaySettings(TrackMateModelView.KEY_TRACK_DISPLAY_MODE, TrackMateModelView.TRACK_DISPLAY_MODE_LOCAL); displayer.refresh(); System.out.println(universe.getContents()); }
final Image3DUniverse universe = new Image3DUniverse(); universe.show(); universe.addContentLater( c );
private void setModel( final Model model ) { if ( model.getSpots() != null ) { makeSpotContent(); } if ( model.getTrackModel().nTracks( true ) > 0 ) { trackContent = makeTrackContent(); universe.removeContent( TRACK_CONTENT_NAME ); universe.addContentLater( trackContent ); } }
@Override public void run(final String arg) { final Image3DUniverse univ = new Image3DUniverse(512, 512); univ.show(); univ.addMesh(createSphere(x1, y1, z1, r1, 12, 12), color1, "Sphere 1", 1); final Content sph2 = univ.addMesh(createSphere(x2, y2, z2, r2, 12, 12), color2, "Sphere 2", 1); final Content tube1 = univ.addMesh(createTube(px, py, pz, pr, 12, false), colort, "Tube", 1); final Content tube2 = univ.addMesh(createTube(px2, py2, pz2, pr2, 12, false), color_t2, "Tube spiral", 1); final Content disc1 = univ.addMesh(createDisc(100, 100, 50, 3, 3, 3, 50, 12), new Color3f( Color.blue), "Disc 1", 1);
final Image3DUniverse universe = new Image3DUniverse(); final ImageWindow3D win = new ImageWindow3D( "TrackMate 3D Viewer", universe ); universe.init( win ); win.pack(); win.setVisible( true );
@Override public Content call() { try { // 1 - Create content final Callable<Content> c = createMesh(pt, displ, resample); if (null == c) return null; final Content content = c.call(); if (null == content) return null; final String title = content.getName(); // 2 - Remove from universe any content of the same title if (universe.contains(title)) { universe.removeContent(title); } // 3 - Add to universe, and wait universe.addContentLater(content).get(); return content; } catch (final Exception e) { IJError.print(e); return null; } } });
public void displayCase(Image3DUniverse univ, int caseNo) { System.out.println("Case no " + caseNo); int threshold = 120; BranchGroup scene = univ.getScene(); for(int i = scene.numChildren()-1; i >= 1 ; i--) { if (scene.getChild(i) instanceof BranchGroup) if (scene.getChild(i).getCapability(BranchGroup.ALLOW_DETACH)) scene.removeChild(i); } System.out.println("Nr. of contents:" + univ.getContents().size()); univ.removeAllContents(); createCase(caseNo); Volume volume = new Volume(image); List l = MCCube.getTriangles(volume, threshold); univ.addTriangleMesh(l, RED, "case" + caseNo); for(int z = 0; z < data.length; z++) { for(int y = 0; y < 2; y++) { for(int x = 0; x < 2; x++) { if(((int)data[z][y*2+x]&0xff)>=threshold) { addVertex(univ, RED, x, y, z); } else { addVertex(univ, GREY, x, y, z); } } } } }