class Pattern { private int img[]; private int width; private int height; public Pattern(int img[],int width,int height) { this.img = new int[width*height]; this.width = width ; this.height = height ; for(int i=0;i < width*height;i++) { this.img[i] = img[i]; } } public int index(int x,int y) { if( 0 <= x && x0) {try{ sum = 0; if(index(x,y+1) > 0){sum++;} if(index(x+1,y+1) > 0){sum++;} if(index(x+1,y) > 0){sum++;} if(index(x+1,y-1) > 0){sum++;} if(index(x-1,y-1) > 0){sum++;} if(index(x-1,y) > 0){sum++;} if(index(x-1,y+1) > 0){sum++;} if(index(x,y-1) > 0){sum++;} if(sum <= 1) { edge_sum++; } }catch(Exception e){;}} } return edge_sum; } }