package pl.wroc.pwr.imagechannel.basic; import pl.wroc.pwr.IOperator2P; import pl.wroc.pwr.imagechannel.IImageChannel; import pl.wroc.pwr.imagechannel.model.ImageChannel; public class SubImageChannel implements IOperator2P { private static final long serialVersionUID = 1289816752314168282L; public IImageChannel apply(IImageChannel inputChannel, int[] box) { if (inputChannel == null) { return null; } IImageChannel outputChannel = new ImageChannel(box[2] - box[0], box[3] - box[1]); for (int x = 0; x < outputChannel.getXSize(); x++) { for (int y = 0; y < outputChannel.getYSize(); y++) { int sX = x + box[0]; int sY = y + box[1]; outputChannel.setValue(x, y, inputChannel.getValue(sX, sY)); } } return outputChannel; } }