

/**
 *
 * @author  jwr
 */
public class Quantization {
    
    /** Creates a new instance of Quantization */
    public Quantization() {
    }
    
    public double [][] quantizy(double[][] data, int step){
        int h=data.length;
        int w=data[0].length;
        int v;
        // quantization step
        int d=step;
        double [][] iData = new double[h][w];
        //v=sign(y)(Math.abs(y)/d)

        for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    iData[i][j]=Math.signum(data[i][j])*(Math.abs(Math.ceil((data[i][j])/d)));
                    //System.out.print(";"+iData[i][j]);
                }
        }

        return iData;
}//end of quantizy()


public double [][] quantizyBP(double [][] iData, int nBits){

    int w=iData.length;
    int h=iData[0].length;
    //ile bitow przesun��
    nBits=8-nBits;
    //double [][] qData = new int[w][h];

    for(int i=0;i<w;i++){
            for(int j=0;j<h;j++){
                iData[i][j]=(double)((((int)iData[i][j])>>nBits)<<nBits);
                //iData[i][j]=((int)iData[i][j])<<nBits;
            }
    }
    return iData;

}//end of quantizyBP()

}
