package pl.wroc.pwr.imagechannel.basic; import pl.wroc.pwr.IOperator; import pl.wroc.pwr.imagechannel.IImageChannel; import pl.wroc.pwr.imagechannel.model.ImageChannel; public class TransposeByValue implements IOperator< IImageChannel > { private IImageChannel inputChannel; private float value; private boolean inPlace; public TransposeByValue( IImageChannel channel, float value, boolean inPlace ) { this.inputChannel = channel; this.value = value; this.inPlace = inPlace; } public void setInPlace( boolean inPlace ) { this.inPlace = inPlace; } public void setValue( float value ) { this.value = value; } public IImageChannel apply() { if ( this.inputChannel == null ) { return null; } IImageChannel outputChannel = this.inPlace ? this.inputChannel : new ImageChannel( this.inputChannel.getSize( ) ); for ( int i = 0; i < this.inputChannel.getMaxIndex( ); i++ ) { outputChannel.setValue( i, (this.inputChannel.getValue( i ) + this.value) % 1.0f ); } return outputChannel; } }