Read the labeling from a file
| 47 | } |
| 48 | // Read the labeling from a file |
| 49 | VectorXs getLabeling( const unsigned char * im, int N, int M ){ |
| 50 | VectorXs res(N); |
| 51 | //printf("%d %d %d \n",im[0],im[1],im[2]); |
| 52 | for( int k=0; k<N; k++ ){ |
| 53 | // Map the color to a label |
| 54 | int c = getColor( im + 3*k ); |
| 55 | int i; |
| 56 | for( i=0;i<nColors && c!=colors[i]; i++ ); |
| 57 | if (c && i==nColors){ |
| 58 | if (i<M) |
| 59 | colors[nColors++] = c; |
| 60 | else |
| 61 | c=0; |
| 62 | } |
| 63 | res[k] = c?i:-1; |
| 64 | } |
| 65 | return res; |
| 66 | } |