@Override
	public void doMedianBlur() {
		if (imageManager.getBufferedImage() == null) return;
		WritableRaster raster = imageManager.getBufferedImage().getRaster();
		double[][] newPixels = new double[raster.getWidth()][raster.getHeight()];
		for (int x = 1; x < raster.getWidth() - 1; x++) {
			for (int y = 1; y < raster.getHeight() - 1; y++) {
				List<Double> mr_rogers = new ArrayList<Double>();
				mr_rogers.add(raster.getPixel(x+1, y+1, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x+1, y-1, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x, y+1, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x, y-1, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x-1, y+1, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x-1, y-1, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x, y, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x+1, y, new double[3])[0]);
				mr_rogers.add(raster.getPixel(x-1, y, new double[3])[0]);
				Collections.sort(mr_rogers);
				double[] pixel = new double[3];
				pixel[0] = mr_rogers.get(mr_rogers.size()/2);
				if (pixel[0] > 255)
					pixel[0] = 255;
				else if (pixel[0] < 0)
					pixel[0] = 0;
				newPixels[x][y] = pixel[0];
			}
		}
		for (int x = 1; x < raster.getWidth() - 1; x++) {
			for (int y = 1; y < raster.getHeight() - 1; y++) {
				double[] pixel = new double[3];
				pixel[0] = pixel[1] = pixel[2] = newPixels[x][y];
				raster.setPixel(x, y, pixel);
			}
		}
		GUIFunctions.refresh();
	}