static private ImageAccess merge(ImageAccess in, int type1, int type2, int length) {
		int nx = in.getWidth();
		int ny = in.getHeight();
		ImageAccess out = new ImageAccess(nx, ny);
		ComplexWaveFilter wf = new ComplexWaveFilter(length);
		
		if (nx >= 1 ) {
			double rowin[]  = new double[nx];
			double rowout[] = new double[nx];
			for (int y=0; y<ny; y++) {
				in.getRow(y, rowin);
				
				if (type1 == 0)
					merge_1D(rowin, rowout, wf.h, wf.g);
				if (type1 == 1)	{
					merge_1D(rowin, rowout, wf.hi, wf.gi);
				}
				out.putRow(y,rowout);
			}
		}
		else {
			out = in.duplicate();
		}
		
		if (ny > 1 ) {
			double colin[] = new double[ny];
			double colout[] = new double[ny];
			for (int x=0; x<nx; x++) {
				out.getColumn(x, colin);
				
				if (type2 == 0)
					merge_1D(colin, colout, wf.h, wf.g);
				if (type2 == 1) {
					merge_1D(colin, colout, wf.hi, wf.gi);
				}
				out.putColumn(x,colout);
			}
		}
		return out;	
	}