diff --git a/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java b/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java index 31330e0d4947427dde46235f072f4e67024726ec..e9b08f493c49a092726d824f984b7fb413425a7c 100644 --- a/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java +++ b/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java @@ -24,19 +24,23 @@ public class CallIJPlugin extends Plugin implements IJBlock { try { - IJ.run(varIp.getValue(true), pluginName.getValue(true), pluginParams.getValue(true)); + ImagePlus imgPlus = varIp.getValue(false); + String params = pluginParams.getValue(false); + + if (imgPlus != null) + IJ.run(imgPlus, pluginName.getValue(true), params); + else + IJ.run(pluginName.getValue(true), params); + // Set the output image (if available) with the following priority - ImagePlus output = WindowManager.getCurrentImage(); + ImagePlus output = IJ.getImage(); + // Default to the current "temporary" image (if any) if (output == null) - { - // Default to the current "temporary" image (if any) output = WindowManager.getTempCurrentImage(); - } + // Default to the input image (may have been modified "in-place" if (output == null) - { - // Default to the input image (may have been modified "in-place" output = varIp.getValue(); - } + varActiveIP.setValue(output); } catch (RuntimeException e)