MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / run

Method run

ij/src/main/java/ij/plugin/Histogram.java:44–94  ·  view source on GitHub ↗
(String arg)

Source from the content-addressed store, hash-verified

42 private String defaultMin, defaultMax;
43
44 public void run(String arg) {
45 ImagePlus imp = IJ.getImage();
46 int bitDepth = imp.getBitDepth();
47 if (bitDepth==32 || IJ.altKeyDown() || (IJ.isMacro()&&Macro.getOptions()!=null)) {
48 IJ.setKeyUp(KeyEvent.VK_ALT);
49 if (!showDialog(imp))
50 return;
51 } else {
52 int stackSize = imp.getStackSize();
53 boolean noDialog = stackSize==1;
54 if (stackSize==3) {
55 ImageStack stack = imp.getStack();
56 String label1 = stack.getSliceLabel(1);
57 if ("Hue".equals(label1))
58 noDialog = true;
59 }
60 int flags = noDialog?0:setupDialog(imp, 0);
61 if (flags==PlugInFilter.DONE) return;
62 stackHistogram = flags==PlugInFilter.DOES_STACKS;
63 Calibration cal = imp.getCalibration();
64 if (bitDepth==16 && ImagePlus.getDefault16bitRange()!=0) {
65 xMin = 0.0;
66 xMax = Math.pow(2,ImagePlus.getDefault16bitRange())-1;
67 useImageMinAndMax = false;
68 } else if (stackHistogram && ((bitDepth==8&&!cal.calibrated())||imp.isRGB())) {
69 xMin = 0.0;
70 xMax = 256.0;
71 useImageMinAndMax = false;
72 } else
73 useImageMinAndMax = true;
74 yMax = "Auto";
75 }
76 ImageStatistics stats = null;
77 if (useImageMinAndMax) {
78 xMin = 0.0;
79 xMax = 0.0;
80 }
81 int iyMax = (int)Tools.parseDouble(yMax, 0.0);
82 boolean customHistogram = (bitDepth==8||imp.isRGB()) && (!(xMin==0.0&&xMax==0.0)||nBins!=256||iyMax>0);
83 HistogramPlot plot = new HistogramPlot();
84 if (stackHistogram || customHistogram) {
85 ImagePlus imp2 = imp;
86 if (customHistogram && !stackHistogram && imp.getStackSize()>1)
87 imp2 = new ImagePlus("Temp", imp.getProcessor());
88 stats = new StackStatistics(imp2, nBins, xMin, xMax);
89 stats.histYMax = iyMax;
90 plot.draw(imp, stats);
91 } else
92 plot.draw(imp, nBins, xMin, xMax, iyMax);
93 plot.show();
94 }
95
96 boolean showDialog(ImagePlus imp) {
97 if (!IJ.isMacro()) {

Callers

nothing calls this directly

Calls 15

getImageMethod · 0.95
getBitDepthMethod · 0.95
altKeyDownMethod · 0.95
isMacroMethod · 0.95
getOptionsMethod · 0.95
setKeyUpMethod · 0.95
showDialogMethod · 0.95
getStackSizeMethod · 0.95
getStackMethod · 0.95
getSliceLabelMethod · 0.95
setupDialogMethod · 0.95
getCalibrationMethod · 0.95

Tested by

no test coverage detected