import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; public class CCLabeling { List intList = null; public int tabv []= null; // relabel the root public int label=0; // original component image/array private int[][] image; private int width,height; // graph of nodes private int[] roots = null; private final int NOROOT=-1; public CCLabeling (int[][] im, int width, int height) { this.image = im; this.width = width; this.height = height; this.roots = new int[width*height]; } // find the root of the node at position pos private int find(int pos) { while(roots[pos]!=pos) pos=roots[pos]; return pos; } // union of the 2 path formed by the 2 roots private int union(int root0, int root1) { if (root0==root1) return root0; if (root0==NOROOT) return root1; if (root1==NOROOT) return root0; if (root00) && (image[x-1][y]==image[x][y]) ) root = union( find(pos-1) , root); if ( (x>0 && y>0) && (image[x-1][y-1]==image[x][y]) ) root = union( find(pos-1-width) , root); if ( (y>0) && (image[x][y-1]==image[x][y]) ) root = union( find(pos-width) , root); if ( (x<(width-1) && y>0) && (image[x+1][y-1]==image[x][y]) ) root = union( find(pos+1-width) , root); add( pos, root ); }} return buildLabelArray(); } public int [][] elimin_surface(int [][] mat , int etq,int l ,int h){ int ss = l*h; int surf [] = getsurfaces(mat,etq, l ,h); intList = new ArrayList(); for(int k = 1 ; k< surf.length; k++){ if((surf[k] <(ss/21.2))||(surf[k]>(ss/0.9) )){//////<(ss/21.2)> (ss/0.9) for(int i=0 ;i