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 ThresholdUpper implements IOperator< IImageChannel > { private IImageChannel inputChannel; private float value; private float cutValue; public ThresholdUpper(IImageChannel channel, float value) { this.inputChannel = channel; this.value = value; this.cutValue = value; } public ThresholdUpper( IImageChannel channel, float value, float cutValue ) { this.inputChannel = channel; this.value = value; this.cutValue = cutValue; } public IImageChannel apply( ) { IImageChannel outputChannel = new ImageChannel( this.inputChannel.getSize( ) ); for ( int i = 0; i < this.inputChannel.getMaxIndex( ); i++ ) { outputChannel.setValue( i, this.inputChannel.getValue( i ) > this.value ? this.cutValue : this.inputChannel.getValue( i ) ); } return outputChannel; } }