package pl.wroc.pwr.imagechannel.moment; import pl.wroc.pwr.basic.IDoubleOperator; import pl.wroc.pwr.imagechannel.IImageChannel; public class Moment implements IDoubleOperator { /** * */ private static final long serialVersionUID = -495682429859523914L; private IImageChannel imageChannel; private int p; private int q; public Moment( IImageChannel imageChannel, int p, int q ) { this.imageChannel = imageChannel; this.p = p; this.q = q; } public float applyDouble( ) { float value = 0; for ( int x = 0; x < this.imageChannel.getXSize( ); x++ ) { for ( int y = 0; y < this.imageChannel.getYSize( ); y++ ) { value += Math.pow( x, this.p ) * Math.pow( y, this.q ) * this.imageChannel.getValue( x, y ); } } return value; } public Float apply( ) { return new Float( this.applyDouble( ) ); } }