package pl.wroc.pwr.imagechannel.basic; import pl.wroc.pwr.IOperator; import pl.wroc.pwr.imagechannel.IImageChannel; import pl.wroc.pwr.imagechannel.factory.ImageChannelFactory; public class CloneChannel implements IOperator { private IImageChannel sourceChannel; public CloneChannel(IImageChannel sourceChannel) { this.sourceChannel = sourceChannel; } public IImageChannel apply( ) { IImageChannel outputChannel = new ImageChannelFactory(this.sourceChannel).apply(); final int maxIndex = this.sourceChannel.getMaxIndex( ); for ( int i = 0; i < maxIndex; i++ ) { outputChannel.setValue( i, this.sourceChannel.getValue( i ) ); } return outputChannel; } }