sx=256; sy=256; sz=256; nb=100; max_rad=16; min_rad=5; view3d=false; Dialog.create("Smarties 3D"); Dialog.addNumber("Number:", nb); Dialog.addNumber("SizeX:", sx); Dialog.addNumber("SizeY:", sy); Dialog.addNumber("SizeZ:", sz); Dialog.addNumber("Min_Radius:", min_rad); Dialog.addNumber("Max_Radius:", max_rad); Dialog.addCheckbox("3D Viewer", view3d); Dialog.show(); nb = Dialog.getNumber(); sx = Dialog.getNumber(); sy = Dialog.getNumber(); sz = Dialog.getNumber(); min_rad = Dialog.getNumber(); max_rad = Dialog.getNumber(); view3d = Dialog.getCheckbox(); t3d=""; if(view3d) t3d="3d_viewer"; newImage("Smarties", "16-bit Black", sx, sy, sz); for(i=1;i<=nb;i++) { cx=random*sx; cy=random*sy; cz=random*sz; rx=min_rad+random*(max_rad-min_rad); ry=min_rad+random*(max_rad-min_rad); rz=min_rad+random*(max_rad-min_rad); vx=random; vy=random; vz=random; wx=-vy; wy=vx; wz=0; val=i; run("3D Draw Shape", "size="+sx+","+sy+","+sz+" center="+cx+","+cy+","+cz+" radius="+rx+","+ry+","+rz+" vector1="+vx+","+vy+","+vz+" vector2="+wx+","+wy+","+wz+" res_xy=1.000 res_z=1.000 unit=pix value=&val display=Overwrite "+t3d); if(view3d) { call("ij3d.ImageJ3DViewer.select", "ellipsoid"+i); call("ij3d.ImageJ3DViewer.setColor", d2s(random*255,0), d2s(random*255,0), d2s(random*255,0)); } } selectWindow("Smarties"); setSlice(nSlices/2); run("Enhance Contrast", "saturated=0"); run("3-3-2 RGB");