(String args)
| 24 | int bitDepth; |
| 25 | |
| 26 | public void run(String args) { |
| 27 | ImagePlus imp = WindowManager.getCurrentImage(); |
| 28 | if (imp==null) { |
| 29 | IJ.showMessage("LUT Editor", "No images are open"); |
| 30 | return; |
| 31 | } |
| 32 | bitDepth = imp.getBitDepth(); |
| 33 | if (bitDepth==24) { |
| 34 | IJ.showMessage("LUT Editor", "RGB images do not use LUTs"); |
| 35 | return; |
| 36 | } |
| 37 | if (bitDepth!=8) { |
| 38 | imp.getProcessor().resetMinAndMax(); |
| 39 | imp.updateAndDraw(); |
| 40 | } |
| 41 | |
| 42 | colorPanel = new ColorPanel(imp); |
| 43 | if (colorPanel.getMapSize()!=256) { |
| 44 | IJ.showMessage("LUT Editor", "LUT must have 256 entries"); |
| 45 | return; |
| 46 | } |
| 47 | Recorder.suspendRecording(); |
| 48 | int red=0, green=0, blue=0; |
| 49 | GenericDialog gd = new GenericDialog("LUT Editor"); |
| 50 | Panel buttonPanel = new Panel(new GridLayout(4, 1, 0, 5)); |
| 51 | openButton = new Button("Open..."); |
| 52 | openButton.addActionListener(this); |
| 53 | buttonPanel.add(openButton); |
| 54 | saveButton = new Button("Save..."); |
| 55 | saveButton.addActionListener(this); |
| 56 | buttonPanel.add(saveButton); |
| 57 | resizeButton = new Button("Set..."); |
| 58 | resizeButton.addActionListener(this); |
| 59 | buttonPanel.add(resizeButton); |
| 60 | invertButton = new Button("Invert..."); |
| 61 | invertButton.addActionListener(this); |
| 62 | buttonPanel.add(invertButton); |
| 63 | Panel panel = new Panel(); |
| 64 | panel.add(colorPanel); |
| 65 | panel.add(buttonPanel); |
| 66 | gd.addPanel(panel, GridBagConstraints.CENTER, new Insets(10, 0, 0, 0)); |
| 67 | gd.showDialog(); |
| 68 | Recorder.resumeRecording(); |
| 69 | if (gd.wasCanceled()){ |
| 70 | colorPanel.cancelLUT(); |
| 71 | return; |
| 72 | } else { |
| 73 | colorPanel.applyLUT(); |
| 74 | String lutName = imp.getProp(LUT.nameKey); |
| 75 | if (lutName!=null && !lutName.endsWith(" (edited)")) |
| 76 | imp.setProp(LUT.nameKey, lutName+" (edited)"); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | void save() { |
| 81 | try {IJ.run("LUT...");} // File>Save As>Lut... |
nothing calls this directly
no test coverage detected