I am not sure if this help; I went through your code quickly and I realized based on your question below
i m getting problem using getSubimage(), the task that i have to performed is to find the first pixel from 4 sides i.e top, bottom,left,right
So you have the new BufferedImage from the method getSubimage(). So what make a problem if the getRBG(x,y) if x and y are the coordinate point on the image so the top left corner has a point (0,0) and the top right corner has (subImage.getWidth(),0) etc..
I am not sure if this is correct answer but it may help
I have looked at the API doc for hte getRBG(x,y) method which return the pixel at specific point
Have you looked at the method public int getRGB(int startX, int startY, int w, int h,
int rgbArray, int offset, int scansize) in the BufferedImage
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com