ij.ImageJ类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(361)

本文整理了Java中ij.ImageJ类的一些代码示例,展示了ImageJ类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageJ类的具体详情如下:
包路径:ij.ImageJ
类名称:ImageJ

ImageJ介绍

[英]This frame is the main ImageJ class.

ImageJ is a work of the United States Government. It is in the public domain and open source. There is no copyright. You are free to do anything you want with this source but I like to get credit for my work and I would like you to offer your changes to me so I can possibly add them to the "official" version.

The following command line options are recognized by ImageJ: 
"file-name" 
Opens a file 
Example 1: blobs.tif 
Example 2: /Users/wayne/images/blobs.tif 
Example 3: e81*.tif 
-macro path [arg] 
Runs a macro or script (JavaScript, BeanShell or Python), passing an 
optional string argument, which the macro or script can be retrieve 
using the getArgument() function. The macro or script is assumed to  
be in the ImageJ/macros folder if 'path' is not a full directory path. 
Example 1: -macro analyze.ijm 
Example 2: -macro script.js /Users/wayne/images/stack1 
Example 2: -macro script.py '1.2 2.4 3.8' 
-batch path [arg] 
Runs a macro or script (JavaScript, BeanShell or Python) in 
batch (no GUI) mode, passing it an optional argument. 
ImageJ exits when the macro finishes. 
-eval "macro code" 
Evaluates macro code 
Example 1: -eval "print('Hello, world');" 
Example 2: -eval "return getVersion();" 
-run command 
Runs an ImageJ menu command 
Example: -run "About ImageJ..." 
-ijpath path 
Specifies the path to the directory containing the plugins directory 
Example: -ijpath /Applications/ImageJ 
-port 
Specifies the port ImageJ uses to determine if another instance is running 
Example 1: -port1 (use default port address + 1) 
Example 2: -port2 (use default port address + 2) 
Example 3: -port0 (don't check for another instance) 
-debug 
Runs ImageJ in debug mode

[中]此框架是主ImageJ类。
ImageJ是美国政府的作品。它是公共领域和开源的。没有版权。你可以自由地做任何事情,你想与这个来源,但我想得到我的工作学分,我希望你提供你的变化给我,所以我可能会添加到“官方”版本。

The following command line options are recognized by ImageJ: 
"file-name" 
Opens a file 
Example 1: blobs.tif 
Example 2: /Users/wayne/images/blobs.tif 
Example 3: e81*.tif 
-macro path [arg] 
Runs a macro or script (JavaScript, BeanShell or Python), passing an 
optional string argument, which the macro or script can be retrieve 
using the getArgument() function. The macro or script is assumed to  
be in the ImageJ/macros folder if 'path' is not a full directory path. 
Example 1: -macro analyze.ijm 
Example 2: -macro script.js /Users/wayne/images/stack1 
Example 2: -macro script.py '1.2 2.4 3.8' 
-batch path [arg] 
Runs a macro or script (JavaScript, BeanShell or Python) in 
batch (no GUI) mode, passing it an optional argument. 
ImageJ exits when the macro finishes. 
-eval "macro code" 
Evaluates macro code 
Example 1: -eval "print('Hello, world');" 
Example 2: -eval "return getVersion();" 
-run command 
Runs an ImageJ menu command 
Example: -run "About ImageJ..." 
-ijpath path 
Specifies the path to the directory containing the plugins directory 
Example: -ijpath /Applications/ImageJ 
-port 
Specifies the port ImageJ uses to determine if another instance is running 
Example 1: -port1 (use default port address + 1) 
Example 2: -port2 (use default port address + 2) 
Example 3: -port0 (don't check for another instance) 
-debug 
Runs ImageJ in debug mode

代码示例

代码示例来源:origin: sc.fiji/VIB_

public static void main(String[] args) {
  new ij.ImageJ();
  ImagePlus img = IJ.openImage("/home/bene/PhD/brains/template.tif");
  img = new ImagePlus("Slice 20", img.getStack().getProcessor(20));
  img.show();
  ij.IJ.runPlugIn("textureByRef.Texture_By_Ref", "");
}

代码示例来源:origin: sc.fiji/fiji-compat

@Override
public void run() {
  if (IJ.getInstance() == null) return;
  if (removeRegisteredListeners()) {
    if (IJ.debugMode)
      IJ.showStatus("Alt Key listener removed.");
    return;
  }
  if (openMenu != null) {
    ImageJ ij = IJ.getInstance();
    ij.addKeyListener(this);
    ij.addFocusListener(this);
    if (IJ.debugMode)
      IJ.showStatus("Alt Key listener installed.");
  }
}

代码示例来源:origin: sc.fiji/TrackMate_

public static void main( final String[] args )
{
  ImageJ.main( args );
  new TrackMatePlugIn_().run( "samples/FakeTracks.tif" );
}

代码示例来源:origin: sc.fiji/fiji-compat

public static boolean removeRegisteredKeyListener() {
  for (KeyListener listener : IJ.getInstance().getKeyListeners())
    if (listener instanceof IJ_Alt_Key_Listener) {
      IJ.getInstance().removeKeyListener(listener);
      return true;
    }
  return false;
}

代码示例来源:origin: net.imagej/ij

/** Starts ImageJ if it's not already running. */
public void init() {
  ImageJ ij = IJ.getInstance();
   if (ij==null || (ij!=null && !ij.isShowing()))
    new ImageJ(this);
  for (int i=1; i<=9; i++) {
    String url = getParameter("url"+i);
    if (url==null) break;
    ImagePlus imp = new ImagePlus(url);
    if (imp!=null) imp.show();
  }
}

代码示例来源:origin: net.imagej/ij

void setIcon() throws Exception {
  URL url = this.getClass().getResource("/microscope.gif");
  if (url==null) return;
  Image img = createImage((ImageProducer)url.getContent());
  if (img!=null) setIconImage(img);
}

代码示例来源:origin: mpicbg/mpicbg

@Override
public void run( String arg )
{
  ij = IJ.getInstance();
  imp = IJ.getImage();
  
  if ( imp.getStackSize() < 2 )
  {
    IJ.error( "This plugin only works on stacks with at least two slices." );
    return;
  }
  window = imp.getWindow();
  canvas = imp.getCanvas();
  
  canvas.addKeyListener( this );
  window.addKeyListener( this );
  canvas.addMouseMotionListener( this );
  canvas.addMouseListener( this );
  ij.addKeyListener( this );
  
  init();
  
  imp.getProcessor().snapshot();
  
  Toolbar.getInstance().setTool( Toolbar.RECTANGLE );
  
  painter = new PaintThread();
  painter.start();
}

代码示例来源:origin: net.imagej/ij

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
  if (!isDataFlavorSupported(flavor))
    throw new UnsupportedFlavorException(flavor);
  ImagePlus imp = WindowManager.getCurrentImage();
  if (imp!=null) {
    imp = flatten(imp);
    ImageProcessor ip;
    if (imp.isComposite()) {
      ip = new ColorProcessor(imp.getImage());
      ip.setRoi(imp.getRoi());
    } else	
      ip = imp.getProcessor();
    ip = ip.crop();
    int w = ip.getWidth();
    int h = ip.getHeight();
    IJ.showStatus(w+"x"+h+ " image copied to system clipboard");
    Image img = IJ.getInstance().createImage(w, h);
    Graphics g = img.getGraphics();
    g.drawImage(ip.createImage(), 0, 0, null);
    g.dispose();
    return img;
  } else {
    //IJ.noImage();
    return null;
  }
}

代码示例来源:origin: net.imagej/ij

text[2] = "National Institutes of Health, USA";
text[3] = IJ.URL;
text[4] = "Java "+System.getProperty("java.version")+(IJ.is64Bit()?" (64-bit)":" (32-bit)");
text[5] = IJ.freeMemory();
text[6] = "ImageJ is in the public domain";
ImageProcessor ip = null;
ImageJ ij = IJ.getInstance();
URL url = ij .getClass() .getResource("/about.jpg");
if (url!=null) {
  Image img = null;
  try {img = ij.createImage((ImageProducer)url.getContent());}
  catch(Exception e) {}
  if (img!=null) {
    ImagePlus imp = new ImagePlus("", img);
    ip = imp.getProcessor();
ImageWindow.centerNextImage();
ImagePlus imp = new ImagePlus("About ImageJ", ip);
String info = text[0] +"\n" + text[4] +"\n" + text[5];
imp.setProperty("Info", info);

代码示例来源:origin: mpicbg/mpicbg

@Override
public void run( final String arg )
{
  ij = IJ.getInstance();
  imp = IJ.getImage();
  window = imp.getWindow();
  canvas = imp.getCanvas();
  
  canvas.addKeyListener( this );
  window.addKeyListener( this );
  canvas.addMouseMotionListener( this );
  canvas.addMouseListener( this );
  ij.addKeyListener( this );
  
  init();
  
  imp.getProcessor().snapshot();
  
  Toolbar.getInstance().setTool( Toolbar.LINE );
  
  painter = new PaintThread();
  painter.start();
}

代码示例来源:origin: net.imagej/ij

running = running2 = false;
if (imp==null) return true;
boolean virtual = imp.getStackSize()>1 && imp.getStack().isVirtual();
if (isRunning) IJ.wait(500);
if (imp==null) return true;
boolean changes = imp.changes;
Roi roi = imp.getRoi();
if (roi!=null && (roi instanceof PointRoi) && ((PointRoi)roi).promptBeforeDeleting())
  changes = true;
if (ij==null || ij.quittingViaMacro() || IJ.getApplet()!=null || Interpreter.isBatchMode() || IJ.macroRunning() || virtual)
  changes = false;
if (changes) {
if (WindowManager.getWindowCount()==0)
  {xloc = 0; yloc = 0;}
if (firstSmallWindow)
  Prefs.saveLocation(LOC_KEY, getLocation());
WindowManager.removeWindow(this);
if (ij!=null && ij.quitting())  // this may help avoid thread deadlocks
  return true;
dispose();
if (imp!=null)
  imp.flush();

代码示例来源:origin: net.preibisch/multiview-reconstruction

public static void main( String[] args )
  {
    new ImageJ();
    
    ImagePlus imp = new Opener().openImage( "/Users/spreibi/Documents/Microscopy/SPIM/HisYFP-SPIM/spim_TL18_Angle0.tif" );
    //ImagePlus imp = new Opener().openImage( "D:/Documents and Settings/Stephan/My Documents/Downloads/1-315--0.08-isotropic-subvolume/1-315--0.08-isotropic-subvolume.tif" );
    imp.show();
    
    imp.setSlice( 27 );		
    imp.setRoi( imp.getWidth()/4, imp.getHeight()/4, imp.getWidth()/2, imp.getHeight()/2 );		
    
    new InteractiveDoG().run( null ); 	
      
  }
}

代码示例来源:origin: mpicbg/mpicbg

if ( imp != null )
  imp.getCanvas().removeMouseListener( this );
  imp.getCanvas().removeMouseMotionListener( this );
  imp.getCanvas().removeKeyListener( this );
  imp.getWindow().removeKeyListener( this );
  IJ.getInstance().removeKeyListener( this );
  imp.setOverlay( null );
  imp.setRoi( ( Roi )null );

代码示例来源:origin: net.imagej/ij

public void windowActivated(WindowEvent e) {
  if (IJ.debugMode) IJ.log("windowActivated: "+imp.getTitle());
  if (IJ.isMacOSX())
    setImageJMenuBar(this);
  if (imp==null)
    return;
  ImageJ ij = IJ.getInstance();
  if (ij!=null && !closed && !ij.quitting() && !Interpreter.isBatchMode())
    WindowManager.setCurrentWindow(this);
  Roi roi = imp.getRoi();
  if (roi!=null && (roi instanceof PointRoi))
    PointToolOptions.update();
  if (imp.isComposite())
    Channels.updateChannels();
  imp.setActivated(); // notify ImagePlus that image has been activated
}

代码示例来源:origin: sc.fiji/TrakEM2_

@SuppressWarnings("unused")
  static public final void main(String[] args) {
    
    final ShortProcessor sp = (ShortProcessor) IJ.openImage("/home/albert/Desktop/t2/bridge-16bit.tif").getProcessor();
    final ShortProcessor filtered = median(sp, 64, 0, 65535, 100);
    new ImageJ();
    new ImagePlus("median", filtered).show();
  }
}

代码示例来源:origin: mpicbg/mpicbg

@Override
public void run( final String arg )
{
  /* cleanup */
  m.clear();
  imp = IJ.getImage();
  target = imp.getProcessor();
  source = target.duplicate();
  source.setInterpolationMethod( ImageProcessor.BILINEAR );
  init();
  createMapping();
  painter = new MappingThread(
      imp,
      source,
      target,
      pleaseRepaint,
      mapping,
      interpolate );
  painter.start();
  Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) );
  imp.getCanvas().addMouseListener( this );
  imp.getCanvas().addMouseMotionListener( this );
  imp.getCanvas().addKeyListener( this );
  imp.getWindow().addKeyListener( this );
  IJ.getInstance().addKeyListener( this );
}

代码示例来源:origin: mpicbg/mpicbg

public void keyPressed( KeyEvent e )
{
  if ( e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_ENTER )
  {
    painter.interrupt();
    
    canvas.removeKeyListener( this );
    window.removeKeyListener( this );
    ij.removeKeyListener( this );
    canvas.removeMouseListener( this );
    canvas.removeMouseMotionListener( this );
    
    if ( imp != null )
    {
      if ( e.getKeyCode() == KeyEvent.VK_ESCAPE )
      {
        imp.getProcessor().reset();
      }
      else if ( e.getKeyCode() == KeyEvent.VK_ENTER )
      {
      }
    }
    imp.updateAndDraw();
  }
  else if ( e.getKeyCode() == KeyEvent.VK_F1 )
  {
    showHelp();
  }
}

代码示例来源:origin: sc.fiji/fiji-lib

public void setActions() {
  ij = IJ.getInstance();
  if (ij == null)
    return;
  Hashtable table = Menus.getCommands();
  if (table.size() == 0) {
    IJ.error("No menu items found!");
    return;
    IJ.error("Cannot install another menu item diverter!");
    return;
    table.put(key, getAction(key));
  cursor = ij.getCursor();
  if (diversionCursor == null) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    diversionCursor = toolkit.createCustomCursor(diversion, hotSpot, "cursor-" + getTitle().replace(' ', '-'));
  ij.setCursor(diversionCursor);
  ij.addKeyListener(this);
  for (Component component : ij.getComponents())
    component.addKeyListener(this);
  ij.addWindowFocusListener(this);
  IJ.showStatus("Click menu entry for " + getTitle() + " (Esc to abort)");

代码示例来源:origin: net.imagej/ij

double scale;
ip = imp.getChannelProcessor();
IndexColorModel cm = (IndexColorModel)ip.getColorModel();
LookUpTable lut = new LookUpTable(cm);
Image img = IJ.getInstance().createImage(imageWidth, imageHeight);
Graphics g = img.getGraphics();
g.setColor(Color.white);
g.dispose();
ImagePlus imp = new ImagePlus("Look-Up Table", img);
new LutWindow(imp, new ImageCanvas(imp), ip);

代码示例来源:origin: net.imagej/ij

public static void setImageJMenuBar(ImageWindow win) {
  ImageJ ij = IJ.getInstance();
  boolean setMenuBar = true;
  ImagePlus imp = win.getImagePlus();
  if (imp!=null)
    setMenuBar = imp.setIJMenuBar();
  MenuBar mb = Menus.getMenuBar();
  if (mb!=null && mb==win.getMenuBar())
    setMenuBar = false;
  setMenuBarTime = 0L;
  if (setMenuBar && ij!=null && !ij.quitting() && !Interpreter.nonBatchMacroRunning()) {
    IJ.wait(10); // may be needed for Java 1.4 on OS X
    long t0 = System.currentTimeMillis();
    win.setMenuBar(mb);
    long time = System.currentTimeMillis()-t0;
    setMenuBarTime = time;
    Menus.setMenuBarCount++;
    if (IJ.debugMode) IJ.log("setMenuBar: "+time+"ms ("+Menus.setMenuBarCount+")");
    if (time>2000L)
      Prefs.setIJMenuBar = false;
  }
  if (imp!=null) imp.setIJMenuBar(true);
}

相关文章