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 MaximumChannel implements IOperator< IImageChannel > { /** * */ private static final long serialVersionUID = 7588947990022361402L; private IImageChannel channel1; private IImageChannel channel2; private boolean inPlace; public MaximumChannel( IImageChannel channel1, IImageChannel channel2, boolean inPlace ) { this.channel1 = channel1; this.channel2 = channel2; this.inPlace = inPlace; } public IImageChannel apply( ) { IImageChannel result = this.inPlace ? this.channel1 : new ImageChannel( this.channel1.getSize( ) ); for ( int i = 0; i < this.channel1.getMaxIndex( ); i++ ) { result.setValue( i, Math.max( this.channel1.getValue( i ), this.channel2.getValue( i ) ) ); } return result; } }