private OCRImage getImage(int[] data, int width, int height, int threshold, int[] colors, double tolerance, boolean invert) {
		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		image.setRGB(0, 0, width, height, data, 0, width);
		if(invert) {
			BufferedImage in = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
			short[] invertTable = new short[256];
			for (int i = 0; i < 256; i++) {
				invertTable[i] = (short) (255 - i);
			}
			new LookupOp(new ShortLookupTable(0, invertTable), null).filter(image, in);
			image = in;
		}
		int[] temp = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
		for(int i = 0; i < temp.length; i++) {
			if(getBrightness(temp[i], threshold)) {
				temp[i] = 0;
			} else {
				if(inTolerance(temp[i], colors, tolerance)) {
					temp[i] = 0;
				} else {
					temp[i] = 16777215;
				}
			}
		}
		return new OCRImage(temp, width, height);
	}