All pastes #363753 Raw Edit

Mine

public text v1 · immutable
#363753 ·published 2007-02-19 17:28 UTC
rendered paste body
public class VisualModel {
	public double[][] llh;
	boolean [][]llm;
	boolean flag;
	double xmean;
	double xwholemean;
	int height;
	int width;
	
	public void computexWholeMean()
	{
		int row=llh.length;
		int col=llh[1].length;
		int cnt=0;
		xwholemean=0.0;
		System.out.println("inside compute whole mean");
		for(int i=0;i<row;i++)
			for(int j=0;j<col;j++)
			{
				if(llm[i][j]==false)
				{
					cnt++;
					xwholemean+=llh[i][j];
				}
				
			}
		xwholemean/=cnt;
		
	}
	public VisualModel(double[][]llh,boolean[][]llm)
	{
		//testing
		System.out.println("inside visual model");
		this.llh=llh;
		this.llm=llm;
		 height=llh.length;
		 width=llh[1].length;

		computexWholeMean();
	}
	
	public double checkSurrounding8(int i,int j)
	{
		
		System.out.println("\ninside check surrounding");
		int row=i-1;
		int col=j-1;

		xmean=0.0;
		flag=false;
		for(int c=row;c<=row+2;c++)
		for(int d=col;d<=col+2;d++)
		{
		if(c<0||d<0)
		continue;
		if(c>height||d>width)
			continue;
		if(llm[i][j]==false)
		flag=true;
		xmean+=llh[c][d];
		}
		if(flag==true)
			return xmean/8.0;
		else return xwholemean;
	}
	public double[][] getVM()
	{
		System.out.println("\ninside getVM");
		int row=llh.length;
		int col=llh[1].length;
		double [][] xdash= new double[row][col];
		System.out.println("inside getvm" + row+"\t"+col);
		for(int i=0;i<row;i++)
			for(int j=0;j<col;j++)
			{
				if(llm[i][j]==false)
				{	
					System.out.println("inside if in getVM");
					xdash[i][j]=llh[i][j];
				}
				else{
					xdash[i][j]=checkSurrounding8(i,j);
					System.out.println("after check surrounding in getVM");
				}
				
			}
		return xdash;
		
	}

}