public int[] getArray(BufferedImage image, int x, int y) {
		int[] n; // store the pixel values of position(x, y) and its neighbors
		int h = image.getHeight();
		int w = image.getWidth();
		int xmin, xmax, ymin, ymax; // the limits of the part of the image on
									// which the filter operate on
		xmin = x - size / 2;
		xmax = x + size / 2;
		ymin = y - size / 2;
		ymax = y + size / 2;

		// special edge cases
		if (xmin < 0)
			xmin = 0;
		if (xmax > (w - 1))
			xmax = w - 1;
		if (ymin < 0)
			ymin = 0;
		if (ymax > (h - 1))
			ymax = h - 1;
		// the actual number of pixels to be considered
		int nsize = (xmax - xmin + 1) * (ymax - ymin + 1);
		n = new int[nsize];
		int k = 0;
		for (int i = xmin; i <= xmax; i++)
			for (int j = ymin; j <= ymax; j++) {
				n[k] = image.getRGB(i, j); // get pixel value
				k++;
			}
		return n;
	}