SLIC超像素分割算法和目前超像素算法的比较代码实现

2026/1/27 13:51:00

}}

{ }

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++;


SLIC超像素分割算法和目前超像素算法的比较代码实现.doc 将本文的Word文档下载到电脑
搜索更多关于: SLIC超像素分割算法和目前超像素算法的比较代码实现 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219