I want to "transform" a image according to this:

http://homepages.inf.ed.ac.uk/rbf/HIPR2/dilate.htm

How can i do that? THNX!

I tried that but it doesn't work:

public static BufferedImage dilatation(BufferedImage aImage)
{
// i use a black&white picture
BufferedImage tmpBufImage = aImage;
int rgb;
rgb = 0x00000000; //black ; i consider the background white
//and the object that i want to dilate black

for (int i = 0; i < aImage.getHeight(); i++)
{
for (int j = 0; j < aImage.getWidth(); j++)
{
if ((i - 1) % 3 == 0 && i > 0 && (j - 1) % 3 == 0 && j > 0)
// with this condition i don't want to go out of the "matrix"; i don't think is good
{
try
{
Color c = new Color(aImage.getRGB(i, j));

if(c.getBlue()==0) //if the pixel is black,the blue is 0
{

//here i try to make all the pixel around the black pixel, black
tmpBufImage.setRGB(i, j, rgb);
tmpBufImage.setRGB(i - 1, j, rgb);
tmpBufImage.setRGB(i, j - 1, rgb);
tmpBufImage.setRGB(i, j + 1, rgb);
tmpBufImage.setRGB(i + 1, j, rgb);
tmpBufImage.setRGB(i - 1, j - 1, rgb);
tmpBufImage.setRGB(i + 1, j - 1, rgb);
tmpBufImage.setRGB(i - 1, j + 1, rgb);
tmpBufImage.setRGB(i + 1, j + 1, rgb);
}
}
catch (Exception ex)
{
ex.printStackTrace(System.out);
}
}
}
}
return tmpBufImage;
}