DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Java - Erode

11.05.2006
| 7816 views |
  • submit to reddit
        // JAI Filter erode

public RenderedImage erode(BufferedImage img)
	{
		KernelJAI kernel = new KernelJAI(7, 7, new float[]{
															0, 0, 0, 0, 0, 0, 0,
															0, 1, 1, 1, 1, 1, 0,
															0, 1, 1, 1, 1, 1, 0,
															0, 1, 1, 1, 1, 1, 0,
															0, 1, 1, 1, 1, 1, 0,
															0, 1, 1, 1, 1, 1, 0,
															0, 0, 0, 0, 0, 0, 0
															});
		ParameterBlock pb = new ParameterBlock();
		pb.addSource(img);
		pb.add(kernel);
		
		return JAI.create("erode", pb);
	}