status line number display

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

status line number display

Steve Nanchy
Is there any way to make the status line under the tool icons (x/y/height/width/angle/et.al.) show THREE decimals (or more) instead of two?

________________________________

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee you should not disseminate, distribute, retain, or copy this e-mail or any attachments. If you have received this email in error please delete and notify the sender.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: status line number display

Michael Schmid
Hi Nanchy,

sorry, it is hardcoded: In most cases, it's a simple call to IJ.d2s, which defaults to two decimals.

To change it, you would have to change line 711 in IJ.java and build your own version of ImageJ (which is not a big deal: just download the sources; in Linux or MacOS type 'ant' in the source directory).

Maybe an option to change the default decimals might be handy for others, too?
(Sometimes I also have images where the pixel size is much smaller than 1 in 'natural units').

Michael
________________________________________________________________
On Aug 7, 2012, at 19:35, Nanchy III, Stephen wrote:

> Is there any way to make the status line under the tool icons (x/y/height/width/angle/et.al.) show THREE decimals (or more) instead of two?

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: status line number display

dscho
Hi,

On Tue, 7 Aug 2012, Michael Schmid wrote:

> sorry, it is hardcoded: In most cases, it's a simple call to IJ.d2s,
> which defaults to two decimals.
>
> To change it, you would have to change line 711 in IJ.java and build
> your own version of ImageJ (which is not a big deal: just download the
> sources; in Linux or MacOS type 'ant' in the source directory).
>
> Maybe an option to change the default decimals might be handy for
> others, too?  (Sometimes I also have images where the pixel size is much
> smaller than 1 in 'natural units').

Note that you can remove the mouse motion listener similar to what I have
done in the Hue Game:

https://github.com/fiji/fiji/blob/ffmpeg/plugins/Examples/The_Hue_Game.bsh

This is a Beanshell demonstrating how to override a given image's mouse
motion listener. All you would have to do is to implement the mouseMoved()
method and call showStatus() with an appropriate parameter.

You could also make it a new tool, it could even be done using ImageJ 1.x'
PlugInTool (you would not need Fiji's more sophisticated tool framework,
although that would help you prevent massive code duplication when
processing mouse events).

Something like

        import ij.IJ;
        import ij.ImagePlus;

        import ij.gui.GenericDialog;
        import ij.gui.ImageCanvas;

        import ij.plugin.tool.PlugInTool;

        import java.awt.event.MouseEvent;

        public class N_Digits extends PlugInTool {
                protected int digits = 3;

                public void mouseMoved(ImagePlus imp, MouseEvent e) {
                        ImageCanvas ic = imp.getCanvas();
                        int sx = e.getX();
                        int sy = e.getY();
                        int ox = ic.offScreenX(sx);
                        int oy = ic.offScreenY(sy);

                        String message;
                        if (ox < 0 || oy < 0 || ox >= imp.getWidth() || oy >= imp.getHeight())
                                return;
                        message = "x=" + ox + ", y=" + oy + " value=";
                        if (imp.getType() == ImagePlus.COLOR_RGB) {
                                int value = imp.getProcessor().getPixel(ox, oy);
                                message += "" + ((value >> 16) & 0xff) + "," + ((value >> 8) & 0xff) + "," + (value & 0xff);
                        }
                        else
                                message += IJ.d2s(imp.getProcessor().getf(ox, oy), digits);
                        IJ.showStatus(message);

                        // Tell ImageJ 1.x not to bother with the status
                        e.consume();
                }

                public void showOptionsDialog() {
                        GenericDialog gd = new GenericDialog("N Digits Options");
                        gd.addNumericField("Number_of_digits", digits, 0);
                        gd.showDialog();
                        if (!gd.wasCanceled())
                                digits = (int)gd.getNextNumber();
                }
        }

should get you started. Should you use Fiji, just start the Script Editor
using File>New>Script, select Java from the Language menu, paste above
Java code and call Run>Run.

Have fun playing,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html