(ImagePlus img, String arg)
| 140 | } |
| 141 | |
| 142 | public void run2(ImagePlus img, String arg) { |
| 143 | imp = img; |
| 144 | |
| 145 | // Make sure input image is a stack. |
| 146 | if(imp.getStackSize()==1) { |
| 147 | IJ.error("Z Project", "Stack required"); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | // Check for inverting LUT. |
| 152 | if (imp.getProcessor().isInvertedLut()) { |
| 153 | if (!IJ.showMessageWithCancel("ZProjection", lutMessage)) |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | setDefaultBounds(); |
| 158 | |
| 159 | // Build control dialog |
| 160 | GenericDialog gd = buildControlDialog(startSlice,stopSlice); |
| 161 | gd.showDialog(); |
| 162 | if (gd.wasCanceled()) return; |
| 163 | |
| 164 | if (!imp.lock()) return; // exit if in use |
| 165 | long tstart = System.currentTimeMillis(); |
| 166 | gd.setSmartRecording(true); |
| 167 | int startSlice2 = startSlice; |
| 168 | int stopSlice2 = stopSlice; |
| 169 | setStartSlice((int)gd.getNextNumber()); |
| 170 | setStopSlice((int)gd.getNextNumber()); |
| 171 | boolean rangeChanged = startSlice!=startSlice2 || stopSlice!=stopSlice2; |
| 172 | startSlice2 = startSlice; |
| 173 | stopSlice2 = stopSlice; |
| 174 | gd.setSmartRecording(false); |
| 175 | method = gd.getNextChoiceIndex(); |
| 176 | Prefs.set(METHOD_KEY, method); |
| 177 | if (isHyperstack) |
| 178 | allTimeFrames = imp.getNFrames()>1&&imp.getNSlices()>1?gd.getNextBoolean():false; |
| 179 | doProjection(true); |
| 180 | |
| 181 | if (arg.equals("") && projImage!=null) { |
| 182 | long tstop = System.currentTimeMillis(); |
| 183 | if (simpleComposite && imp.getBitDepth()!=24) |
| 184 | IJ.run(projImage, "Grays", ""); |
| 185 | projImage.show("ZProjector: " +IJ.d2s((tstop-tstart)/1000.0,2)+" seconds"); |
| 186 | } |
| 187 | |
| 188 | imp.unlock(); |
| 189 | IJ.register(ZProjector.class); |
| 190 | if (Recorder.scriptMode()) { |
| 191 | String m = getMethodAsString(); |
| 192 | if (isHyperstack && allTimeFrames) |
| 193 | m = m + " all"; |
| 194 | String range = ""; |
| 195 | if (rangeChanged) |
| 196 | range = ","+startSlice2+","+stopSlice2; |
| 197 | Recorder.recordCall("imp = ZProjector.run(imp,\""+m+"\""+range+");"); |
| 198 | } |
| 199 |
no test coverage detected