I have an assignment to do average and uniform sharpening filter on 3x3 png image.
My code was
public static void AverageFilter(BufferedImage img) throws IOException{
Kernel kernel = new Kernel(3, 3, new float[] { 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f,
1f/9f, 1f/9f });
BufferedImageOp op = new ConvolveOp(kernel);
img = op.filter(img, null);
DisplayImage(img);
}
public static void Sharpening(BufferedImage img) throws IOException{
Kernel kernel = new Kernel(3, 3, new float[] { -1, -1, -1, -1, 9, -1, -1,
-1, -1 });
BufferedImageOp op = new ConvolveOp(kernel);
img = op.filter(img, null);
DisplayImage(img);
}
How to implement this code using a predefined method such as loops and if conditions to handle all cases for zero padding ?
Aucun commentaire:
Enregistrer un commentaire