: RE : IMAGEJ Digest - 5 Dec 2005 to 6 Dec 2005 (#2005-326) Saving scales

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

: RE : IMAGEJ Digest - 5 Dec 2005 to 6 Dec 2005 (#2005-326) Saving scales

Goldsmith, Noel
Michael asks about saving scales.

What we do is use some custom plug-ins to accept data from the user about each optical system, objective, inter mag etc.
And then calibrate, and optionally apply a scale bar.

The plug in uses the microscope scale one on the imagej web site as the basis for the bar.
There are two plug-ins which follow here.
The first is common to all of our microscopes, and the second is specific to each one.
Note that the numbers for scales and magnifications etc are specific for the particular microscope, objectives, intermediate magnifications and camera.
To get all of these numbers requires some careful work.
Hope this helps.
Noel
(and Berin)

import ij.*;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import ij.measure.Calibration;

public class Scale_Bar implements PlugInFilter {

/** DESCRIPTION
 * This plugin lets you spatial calibrate images taken on a microscope by calling the MicroCal
 * class to get the calibration and then calling the scale-bar plugin to place the scale bar
 * on the image.
 *
 * Author:  Berin Martini
 * Date:    31-05-2005
 *
 */


        ImagePlus imp;
        private static MicroCal cal = new MicroCal();
               
        public int setup(String arg, ImagePlus imp) {
                this.imp = imp;
                if (imp==null){
                        IJ.noImage();
                        return DONE;
                }
                return DOES_ALL;
        }

        public void run(ImageProcessor ip) {
                if (cal.makeCal()) {
                        Calibration oc = imp.getCalibration().copy();
                        oc.setUnit(cal.getUnit());
                        oc.pixelWidth = cal.getPixelWidth();
                        oc.pixelHeight = oc.pixelWidth;
                        imp.setGlobalCalibration(null);
                        imp.setCalibration(oc);
                        imp.getWindow().repaint();
                        IJ.run("Scale Bar...");
                }
        }
}


import ij.*;
import ij.gui.*;

public class MicroCal {

/** DESCRIPTION
 * This class is called by a plugin in order to calibrate a microscope, the Polyvar microscope in this case.
 * It does this by allowing you to pick between known objectives and values from a drop-down window.
 * After determining the calibration the class will pass the pixel width, units and slice depth back to
 * plugin that called it.
 *
 * Author:  Berin Martini
 * Date:    31-05-2005
 *
 */

        private String[] mags = {"1x","2x","2.5x", "5x", "10x", "20x", "50x","100x", "100x Oil", "125x", "150x", "250x"};
        private static int magsIndex = 3; // index default for selected magnification in drop-down menu
        private static double mag;

        private double pixelWidth;
        private double sliceDepth;
        private String units;

        private String[] auxMag = {"0.8","1","1.25","2.5" };
        private double[] auxMagValue = {0.801D,1D,1.2545D,2.5090D};
        private static int auxMagIndex = 1; // Index default for selected aux mag.

        public boolean makeCal() {
                if (dialog()) {
                        switch (magsIndex) {

                                case 0: sliceDepth = 600D; mag = 1.0121D; units = "?m"; break;
                                case 1: sliceDepth = 100D; mag = 2.0D; units = "?m"; break;
                                case 2: sliceDepth = 95D; mag = 2.5412D; units = "?m"; break;
                                case 3: sliceDepth = 75D; mag = 5.0D; units = "?m"; break;
                                case 4: sliceDepth = 15D; mag = 10.05D; units = "?m"; break;
                                case 5: sliceDepth = 5D; mag = 19.98D; units = "?m"; break;
                                case 6: sliceDepth = 2D; mag = 49.9D; units = "?m"; break;
                                case 7: sliceDepth = 1D; mag = 100.15D; units = "?m"; break;
                                case 8: sliceDepth = 0.7D; mag = 99.94D; units = "?m"; break;
                                case 9: sliceDepth = 0.7D; mag = 94.1D; units = "?m"; break;
                                case 10: sliceDepth = 0.7D; mag = 155.35D; units = "?m"; break;
                                case 11: sliceDepth = 0.7D; mag = 253.6D; units = "?m"; break;
                        }
                        pixelWidth = (1.0D/(0.1282*mag*auxMagValue[auxMagIndex]));
                        return true;
                }
                return false;
        }
               
        public double getSliceDepth() {
                return sliceDepth;
        }
       
        public double getPixelWidth() {
                return pixelWidth;
        }

        public String getUnit() {
                return units;
        }
       
        private boolean dialog() {
                GenericDialog gd = new GenericDialog("Scale Microscope Polyvar Image...");
                gd.addChoice("Intrmediate Mag Used:",auxMag,auxMag[auxMagIndex]);
                gd.addChoice("Objective Lens Used:", mags, mags[magsIndex]);
                gd.showDialog();
                if (gd.wasCanceled()) {return false;}
                auxMagIndex=gd.getNextChoiceIndex();
                magsIndex=gd.getNextChoiceIndex();
                return true;
        }
}



> ----------
> From: ImageJ Interest Group on behalf of IMAGEJ automatic digest system
> Reply To: ImageJ Interest Group
> Sent: Wednesday, December 7, 2005 16:00 PM
> To: [hidden email]
> Subject: IMAGEJ Digest - 5 Dec 2005 to 6 Dec 2005 (#2005-326)
>
> There are 10 messages totalling 343 lines in this issue.
>
> Topics of the day:
>
>  
>   4. Saving scale
>
>
> Date:    Tue, 6 Dec 2005 14:25:09 -0330
> From:    michael shaffer <[hidden email]>
> Subject: Saving scale
>
> Is there a way (or available plugin) for saving the determined scale for a
> number of m'scope objectives?  As is, we have to load the calibrate image
> everytime we work with a different magnification(?)
>
> genuinely  :o)
> michael shaffer
>
> SEM/MLA Laboratory Coordinator
> (709) 737-6799 (ofc)
> (709) 737-6790 (lab)
> (709) 737-6193 (FAX)
>     <http://www.mun.ca/creait/maf/>
>     <http://www.esd.mun.ca/epma/>
>
> Inco Centre
> c/o Memorial University
> 230 Elizabeth Avenue
> P.O. Box 4200
> St. John's, NL A1C 5S7
>
>