public Color getPixel(int x, int y) { int height = getHeight(); int width = getWidth(); if (x >= 0 && x <= width && y >= 0 && y <= height) { int pixel = getRGB(x, y); return new Color(pixel); } else { return null; } } public void blur() { int height = getHeight(); int width = getWidth(); OFImage original = null; try { original = (OFImage) this.clone(); } catch (Exception e) {} int ox = 0; int oy = 0; Color oPixel = new Color(0, 0, 0); int oRed = 0; int oGreen = 0; int oBlue = 0; int avgRed = 0; int avgGreen = 0; int avgBlue = 0; for(int y = 0; y < height; y++) { for(int x = 0; x < width; x++) { for(int h = -1; h <= 1; h++) { for(int v = -1; v <= 1; v++) { ox = x + h; oy = y + v; oPixel = original.getPixel(ox, oy); if (oPixel != null) { oRed = oPixel.getRed(); oGreen = oPixel.getGreen(); oBlue = oPixel.getBlue(); avgRed = (avgRed + oRed)/2; avgGreen = (avgGreen + oGreen)/2; avgBlue = (avgBlue + oBlue)/2; } } } setPixel(x, y, new Color(200, 200, 200)); } } } ======= Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at OFImage.blur(OFImage.java:177) at ImageViewer.blur(ImageViewer.java:148) at ImageViewer.access$700(ImageViewer.java:17)