Never been to DZone Snippets before?

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

Java - Dilate3 (See related posts)

// pixel before the filter
// |--|--|--|
// | | | |
// |--|--|--|
// | | *| |
// |--|--|--|
// | | | |
// |--|--|--|

// pixel after the filter
// |--|--|--|
// | *| *| *|
// |--|--|--|
// | *| *| *|
// |--|--|--|
// | *| *| *|
// |--|--|--|

   1  
   2  public BufferedImage dilate3(BufferedImage bi)
   3  	{
   4  		BufferedImage buff = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());
   5  		
   6  		Kernel kernel = new Kernel(3, 3, new float[] {
   7  														1f, 1f, 1f, 
   8  														1f, 1f, 1f, 
   9  														1f, 1f, 1f
  10  													 });
  11  		
  12  		ConvolveOp op = new ConvolveOp(kernel);
  13  		op.filter(bi, buff);
  14  		
  15  		return buff;
  16  	}

You need to create an account or log in to post comments to this site.


Click here to browse all 5556 code snippets

Related Posts