Monday, December 25, 2006

how to find edges?

To find edges in a photo you can use a sobel filter.

float [] data = {-1,-1,-1,-1,8,-1,-1,-1,-1};//Sobel filter
Kernel kernel = new Kernel(3,3,data);
ConvolveOp cop = new ConvolveOp(kernel);
BufferedImage filteredImg = cop.filter(bufImg,dst);

filteredImg is a black-white colored image (edges are white,others are black).To detect an object i will use edge and color informations.

Friday, December 22, 2006

how to read images in java easily?

Java Class javax.imageio.ImageIO has a static read() method so you can read images easily.

try{
File file = new File("C:\photo.jpg');
BufferedImage bufferedImg = ImageIO.read(file);
}
catch(IOException ioe)
{
System.exit(0);
}

You can easily manipulate BufferedImage instances.You can call setRGB(),getRGB() methods to set or get Red Green Blue parts in pixel color.

After read image to bufferedImg i need to get pixels so lets do it:

final int imwidth = bufImg.getWidth(null);
final int imheight = bufImg.getHeight(null);

for(int i=0; i < imheight;i++)
{
for(int j=0; j< imwidth;j++)
{
argb = getARGBs(j,i);
//do sth with Red Green Blue parts of a pixel color.
}
}

//Get Alpha Red Green Blue parts of a pixel color.
public int [] getARGBs(int x,int y)
{
int [] argbs = new int[4];
argbs[0] = (bufImg.getRGB(x,y) >> 24) & 0xff;//alpha
argbs[1] = (bufImg.getRGB(x,y) >> 16) & 0xff;//red
argbs[2]=(bufImg.getRGB(x,y) >> 8) & 0xff;//green
argbs[3] =(bufImg.getRGB(x,y)) & 0xff;//blue
return argbs;
}

first move

The MathWorks Matlab Image Processing Toolbox is really useful for processing images.You can filter images easily with different filters and see results immediately.So i choose this toolbox.

The MathWorks Matlab : http://www.mathworks.com/

After practising in matlab, i will study java image processing.My first target is processing an image in java and detect and recognize significant objects in photo.So lets go:)

graduate thesis

Nowadays i really have to work on my graduate thesis project.So,i hope it will cover my blog topics until i complete it.
key words:
image processing
artificial intelligence
j2me