package pl.wroc.pwr.roi.analysis; import java.util.List; import pl.wroc.pwr.IOperator1P; import pl.wroc.pwr.roi.IROI; public class FindROIBoundingBox implements IOperator1P { public int[] apply(IROI roi) { int minX = Integer.MAX_VALUE; int maxX = Integer.MIN_VALUE; int minY = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; List coords = roi.getROICoordinates(); for (int[] coord : coords) { minX = Math.min(minX, coord[0]); maxX = Math.max(maxX, coord[0]); minY = Math.min(minY, coord[1]); maxY = Math.max(maxY, coord[1]); } return new int[]{minX, minY, maxX, maxY}; } }