Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Impala::Core::Array::extractRegions ( pixgroup *  rg,
int  nrClusters,
const VectorDouble &  clusterMap,
const MatrixDouble &  m 
)

Definition at line 235 of file ColorSegmentation.h.

References Impala::Core::Array::pixgroup::cov, Impala::Core::Matrix::MatrixTem< C >::covariance(), Impala::Core::Array::pixgroup::dim, Impala::Core::Matrix::MatrixTem< C >::getRow(), Impala::Core::Array::pixgroup::idx, Impala::Core::Array::pixgroup::m, Impala::Core::Matrix::MatrixTem< C >::nCol(), Impala::Core::Matrix::MatrixTem< C >::nRow(), Impala::Core::Array::pixgroup::nrPixInGroup, and Impala::Core::Matrix::MatrixTem< C >::setRow().

Referenced by ColorSegmentation().

00235                                                                                                     {
00236 
00237     int nrPixInImage = m.nRow() ;
00238     int i;
00239 
00240     // init
00241     for (i=0; i<nrClusters; i++) {
00242 
00243         rg[i].size = nrPixInImage ;
00244 
00245             // number of pixels in the group
00246         rg[i].nrPixInGroup = 0; 
00247 
00248             // for each pixel in the group, 
00249             // keep a reference to its place in the original image
00250         rg[i].idx = VectorDouble(nrPixInImage); 
00251 
00252         rg[i].dim = m.nCol();
00253 
00254     }
00255 
00256         // get regions for each pixel in the image
00257     for (i=0; i<nrPixInImage; i++) {
00258             // get the cluster number for pixel i
00259         int l = clusterMap[i];
00260             // add a reference to the pixel i
00261         int n = rg[l].nrPixInGroup ;
00262         rg[l].idx[n] = i; //add pixel's index
00263             // added pixel i to group l
00264         rg[l].nrPixInGroup++;
00265     }
00266 
00267         // set covariance and mean values for each region
00268     for (i=0; i<nrClusters; i++) {
00269         rg[i].label = i;
00270 
00271         MatrixDouble rgPixMatrix(rg[i].nrPixInGroup, m.nCol(), 0.0) ;
00272             // create a new matrix of the pixels in group i
00273         for(int j=0;j<rg[i].nrPixInGroup;j++) 
00274             rgPixMatrix.setRow(j, m.getRow(rg[i].idx[j]) ) ;
00275 
00276             // set covariance matrix, and mean vector
00277         VectorDouble means ;
00278         rg[i].cov = rgPixMatrix.covariance(means) ;
00279 
00280         rg[i].m = means ;
00281     }
00282 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:56:19 2010 for ImpalaSrc by  doxygen 1.5.1