Implements the Image/Stacks/Plot Z-axis Profile command, which plots the selection mean gray value versus slice number.
| 12 | which plots the selection mean gray value versus slice number. |
| 13 | */ |
| 14 | public class ZAxisProfiler implements PlugIn, Measurements, PlotMaker { |
| 15 | private static String[] choices = {"time", "z-axis"}; |
| 16 | private static String choice = choices[0]; |
| 17 | private boolean showingDialog; |
| 18 | private ImagePlus imp; |
| 19 | private boolean isPlotMaker; |
| 20 | private boolean timeProfile; |
| 21 | private boolean firstTime = true; |
| 22 | private String options; |
| 23 | |
| 24 | /** Returns a Plot of the selection mean gray value versus slice number. */ |
| 25 | public static Plot getPlot(ImagePlus imp) { |
| 26 | return getPlot(imp, "time"); |
| 27 | } |
| 28 | |
| 29 | /** Returns a Plot of the selection mean versus slice number for the |
| 30 | specified hyperstack, where 'options' can be "time" or "z-axis". */ |
| 31 | public static Plot getPlot(ImagePlus imp, String options) { |
| 32 | ZAxisProfiler zap = new ZAxisProfiler(); |
| 33 | zap.imp = imp; |
| 34 | zap.options = options; |
| 35 | zap.isPlotMaker = true; |
| 36 | Plot plot = zap.getPlot(); |
| 37 | return plot; |
| 38 | } |
| 39 | |
| 40 | public void run(String arg) { |
| 41 | imp = IJ.getImage(); |
| 42 | if (imp.getStackSize()<2) { |
| 43 | IJ.error("ZAxisProfiler", "This command requires a stack."); |
| 44 | return; |
| 45 | } |
| 46 | isPlotMaker = true; |
| 47 | Plot plot = getPlot(); |
| 48 | if (plot!=null) { |
| 49 | if (isPlotMaker) |
| 50 | plot.setPlotMaker(this); |
| 51 | plot.show(); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | public Plot getPlot() { |
| 56 | Roi roi = imp.getRoi(); |
| 57 | ImageProcessor ip = imp.getProcessor(); |
| 58 | double minThreshold = ip.getMinThreshold(); |
| 59 | double maxThreshold = ip.getMaxThreshold(); |
| 60 | float[] y; |
| 61 | boolean hyperstack = imp.isHyperStack(); |
| 62 | if (hyperstack) |
| 63 | y = getHyperstackProfile(imp, minThreshold, maxThreshold); |
| 64 | else |
| 65 | y = getZAxisProfile(imp, minThreshold, maxThreshold); |
| 66 | if (y==null) |
| 67 | return null; |
| 68 | float[] x = new float[y.length]; |
| 69 | |
| 70 | String xAxisLabel = showingDialog&&choice.equals(choices[0])?"Frame":"Slice"; |
| 71 | Calibration cal = imp.getCalibration(); |
nothing calls this directly
no outgoing calls
no test coverage detected