Commit f60b919e authored by Daniel Felipe  GONZALEZ OBANDO's avatar Daniel Felipe GONZALEZ OBANDO
Browse files

Added copy option for logical operations

parent 2ece8676
......@@ -11,6 +11,7 @@ import icy.roi.ROI;
import icy.type.collection.CollectionUtil;
import plugins.adufour.blocks.tools.roi.ROIBlock;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.lang.VarBoolean;
import plugins.adufour.vars.lang.VarEnum;
import plugins.adufour.vars.lang.VarROIArray;
import plugins.stef.roi.bloc.RoiBlocks;
......@@ -34,13 +35,14 @@ public class LogicalOperationROI extends Plugin implements ROIBlock, PluginLibra
protected VarROIArray roiSetA = new VarROIArray("ROI(s) group A", null);
protected VarROIArray roiSetB = new VarROIArray("ROI(s) group B", null);
protected VarEnum<LogicOperator> op = new VarEnum<LogicOperator>("Keep", LogicOperator.A_CONTAINED_IN_B);
protected VarBoolean copyRois = new VarBoolean("Copy ROIs", true);
protected VarROIArray output = new VarROIArray("Result");
@Override
public void run()
{
final List<ROI> result = doLogicalOperation(CollectionUtil.asList(roiSetA.getValue()),
CollectionUtil.asList(roiSetB.getValue()), op.getValue());
CollectionUtil.asList(roiSetB.getValue()), op.getValue(), copyRois.getValue());
output.setValue(result.toArray(new ROI[result.size()]));
}
......@@ -51,6 +53,7 @@ public class LogicalOperationROI extends Plugin implements ROIBlock, PluginLibra
inputMap.add("roiA", roiSetA);
inputMap.add("roiB", roiSetB);
inputMap.add("op", op);
inputMap.add("generate copies", copyRois);
}
@Override
......@@ -74,9 +77,11 @@ public class LogicalOperationROI extends Plugin implements ROIBlock, PluginLibra
* second set of ROI
* @param logicOp
* logical operation to apply between the 2 sets of ROI
* @param generateCopies
* @return result ROIs from the given logical operation between the 2 sets of ROI
*/
public static List<ROI> doLogicalOperation(Collection<ROI> roiSetA, Collection<ROI> roiSetB, LogicOperator logicOp)
public static List<ROI> doLogicalOperation(Collection<ROI> roiSetA, Collection<ROI> roiSetB, LogicOperator logicOp,
boolean copyRois)
{
final List<ROI> result = new ArrayList<ROI>();
......@@ -129,7 +134,7 @@ public class LogicalOperationROI extends Plugin implements ROIBlock, PluginLibra
// condition verified ?
if (cond)
result.add(roiA.getCopy());
result.add((copyRois ? roiA.getCopy() : roiA));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment