FAQ: How do I get the information from the cursor in the status bar?

When dragging the mouse over an image, ImageJ shows some information about the pixel under the mouse cursor. This can however vary across different plugins.

The information comes from the “mouseMoved” method, from a ImagePlus inherited class.

public void mouseMoved(int x, int y) {
  if (ij!=null)
    ij.showStatus(getLocationAsString(x,y) + getValueAsString(x,y));
    savex=x; savey=y;
}

“Directionality” plugin example (Fiji) :

public void mouseMoved(MouseEvent e) {
  Point coord = canvas.getCursorLoc();
  int x = coord.x;
  int y = coord.y;
  try {
    final ColorProcessor cp = (ColorProcessor) canvas.getImage().getProcessor();
    final int c = cp.getPixel(x, y);
    final int r = (c&0xff0000) >>16;
    final int g = (c&0xff00)>>8;
    final int b = c&0xff;
    final float[] hsb = Color.RGBtoHSB(r, g, b, null);
    final float angle = hsb[0] * 180 - 90;
    final float amount = hsb[1];
    IJ.showStatus( String.format("Orientation: %5.1f º - Amont: %5.1f %%", angle, 100*amount));
  } 
  catch (ClassCastException cce) {
    return;
  }
}

To understand the status bar information, please see manual, and/or the source code…

faq/technical/how_can_i_understand_status_bar_mouse_informations.txt · Last modified: 2012/07/07 06:28 by tferreira
Back to top
CC Attribution-Noncommercial-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0