package pl.wroc.pwr.imagechannel.basic; import pl.wroc.pwr.IOperator; import pl.wroc.pwr.imagechannel.IImageChannel; public class CopyChannel implements IOperator< IImageChannel > { private IImageChannel targetChannel; private IImageChannel sourceChannel; public CopyChannel( ) { this( null, null ); } public CopyChannel(IImageChannel sourceChannel) { this.targetChannel = null; this.sourceChannel = sourceChannel; } public CopyChannel( IImageChannel targetChannel, IImageChannel sourceChannel ) { this.targetChannel = targetChannel; this.sourceChannel = sourceChannel; } public IImageChannel apply( ) { IImageChannel outputChannel = null; if ( this.targetChannel == null ) { return null; } outputChannel = this.targetChannel; for ( int i = 0; i < this.targetChannel.getMaxIndex( ); i++ ) { outputChannel.setValue( i, this.sourceChannel.getValue( i ) ); } return outputChannel; } }