public static QuadTree compressImage (int[][] image) {
		if (image == null) {
			throw new IllegalArgumentException();
		} else if (image.length != image[0].length) {
			throw new IllegalArgumentException();
		} else if (!((image.length & (image.length - 1)) == 0)) { //checks if power of 2
			throw new IllegalArgumentException();
		}
		//case where image is 1x1
		if (image.length == 1) {
			return new QuadTree(new QuadNode(image[0][0], 1));
		} else if (image.length == 2) {
			QuadNode root = getQuadNode(image, 0, 0, 2);			
			return new QuadTree(root);
		} else {
			QuadNode root = new QuadNode(image.length);
			root.setQuadrant(QuadName.UpperLeft, getQuadNode(image, 0, 0, 
					image.length / 2));
			root.setQuadrant(QuadName.UpperRight, getQuadNode(image, 0, 
					image.length/2, image.length / 2));
			root.setQuadrant(QuadName.LowerRight, getQuadNode(image, 
					image.length/2, image.length/2, image.length / 2));
			root.setQuadrant(QuadName.LowerLeft, getQuadNode(image, 
					image.length/2, 0, image.length / 2));
			if (checkIfAll4ChildrenAreLeaves(root)) {
				int color = root.getQuadrant(QuadName.UpperLeft).getRegionColor();
				if ((color != root.getQuadrant(QuadName.UpperRight).getRegionColor()) ||
					(color != root.getQuadrant(QuadName.LowerRight).getRegionColor()) ||
					(color != root.getQuadrant(QuadName.LowerLeft).getRegionColor())) {
					return new QuadTree(root);
				}
				else {
					return new QuadTree(new QuadNode(color, image.length));
				}
			} else {
				return new QuadTree(root);
			}
		}
	}