}}
{ }
int nindex = y*width + x;
if(nlabels[nindex] >= 0) adjlabel = nlabels[nindex];
int count(1);
for( int c = 0; c < count; c++ ) { }
//------------------------------------------------------- // If segment size is less then a limit, assign an
// adjacent label found before, and decrement label count. //------------------------------------------------------- if(count <= SUPSZ >> 2) {
for( int c = 0; c < count; c++ ) { } label--;
int ind = yvec[c]*width+xvec[c]; nlabels[ind] = adjlabel; for( int n = 0; n < 4; n++ ) { }
int x = xvec[c] + dx4[n]; int y = yvec[c] + dy4[n];
if( (x >= 0 && x < width) && (y >= 0 && y < height) ) { }
int nindex = y*width + x;
if( 0 > nlabels[nindex] && labels[oindex] == labels[nindex] ) { }
xvec[count] = x; yvec[count] = y;
nlabels[nindex] = label; count++;
}
}
}
}
} label++;
oindex++;
numlabels = label; if(xvec) delete [] xvec; if(yvec) delete [] yvec;
//=========================================================================== /// RelabelStraySupervoxels
//=========================================================================== void SLIC::EnforceSupervoxelLabelConnectivity( {
int adjlabel(0);//adjacent label
int* xvec = new int[SUPSZ*10];//a large enough size int* yvec = new int[SUPSZ*10];//a large enough size int* zvec = new int[SUPSZ*10];//a large enough size
//------------------ // memory allocation //------------------
int** nlabels = new int*[depth]; {for( int d = 0; d < depth; d++ ) {
int sz = width*height;
const int SUPSZ = STEP*STEP*STEP;
const int dx10[10] = {-1, 0, 1, 0, -1, 1, 1, -1, 0, 0}; const int dy10[10] = { 0, -1, 0, 1, -1, -1, 1, 1, 0, 0}; const int dz10[10] = { 0, 0, 0, 0, 0, 0, 0, 0, -1, 1}; int**& const int& const int& const int& int&
const int&
labels,//input - previous labels, output - new labels width, height, depth, STEP)
numlabels,
}}
nlabels[d] = new int[sz];
for( int i = 0; i < sz; i++ ) nlabels[d][i] = -1;
//------------------ // labeling
//------------------ int lab(0);
{for( int d = 0; d < depth; d++ ) {
int i(0);
for( int h = 0; h < height; h++ ) {
for( int w = 0; w < width; w++ ) {
if(nlabels[d][i] < 0) {
nlabels[d][i] = lab;
//------------------------------------------------------- // Quickly find an adjacent label for use later if needed //------------------------------------------------------- {for( int n = 0; n < 10; n++ ) { }}
xvec[0] = w; yvec[0] = h; zvec[0] = d; int count(1);
for( int c = 0; c < count; c++ ) {
for( int n = 0; n < 10; n++ ) int x = w + dx10[n]; int y = h + dy10[n]; int z = d + dz10[n];
if( (x >= 0 && x < width) && (y >= 0 && y < height) && (z >= 0 && { }
int nindex = y*width + x; if(nlabels[z][nindex] >= 0) { }
adjlabel = nlabels[z][nindex];
z < depth) )
}
}
{ }
int x = xvec[c] + dx10[n]; int y = yvec[c] + dy10[n]; int z = zvec[c] + dz10[n];
if( (x >= 0 && x < width) && (y >= 0 && y < height) && (z >= 0 { }
int nindex = y*width + x;
if( 0 > nlabels[z][nindex] && labels[d][i] == { }
xvec[count] = x; yvec[count] = y; zvec[count] = z;
nlabels[z][nindex] = lab; count++;
&& z < depth))
labels[z][nindex] )
//------------------------------------------------------- // If segment size is less then a limit, assign an
// adjacent label found before, and decrement label count. //-------------------------------------------------------
if(count <= (SUPSZ >> 2))//this threshold can be changed according to { }
//-------------------------------------------------------- lab++;
for( int c = 0; c < count; c++ ) { } lab--;
int ind = yvec[c]*width+xvec[c]; nlabels[zvec[c]][ind] = adjlabel;
needs
i++;

