public static BufferedImage gaussFilter(BufferedImage image, int filter[][] ) {
		BufferedImage ret = makeEmptyGrayImageFromImage(image);
		

		int w = image.getWidth();
		int h = image.getHeight();
		int windowSize = filter.length;
		int norm = 0;
		for (int i = 0; i < windowSize; ++i) {
			for (int j = 0; j < windowSize; ++j) {
				norm += filter[i][j];
			}
		}
		if ( norm == 0)
			norm = 1;

		//dla unikniecia efektu pozostawianej czarnej ramki 
		for (int x = 0; x < w ; ++x) {
			for (int y = 0; y < h ; ++y) {
				ret.setRGB(x, y, levelToGrayscale( rgbToLuminance( image.getRGB(x, y) ) )); 
			}
		}
		for (int x = 0; x < w - windowSize; ++x) {
			for (int y = 0; y < h - windowSize; ++y) {
				int level = 0;
				
				
				for (int i = 0; i < windowSize; ++i) {
					for (int j = 0; j < windowSize; ++j) {
						level += filter[i][j] * rgbToLuminance( image.getRGB(x + i, y + j) );
						
					}
				}
				level = level/norm;
				level = levelToGrayscale(level);

				ret.setRGB(x + windowSize / 2, y + windowSize / 2, level );
				
			}
		}
		
		return ret;
	}