SLIC超像素分割 源代码中 获取图像初始种子点的函数 下面这一句啥意思

来苏苏 2019-04-08 01:11:07
SLIC超像素分割 源代码中 获取图像初始种子点的函数 下面这一句的意思:

const bool hexgrid = false;
......
if(hexgrid){ seedx = x*STEP+(xoff<<(y&0x1))+xe; if(seedx >= width)seedx = width-1; }//for hex grid sampling (这句不懂)

疑惑:1.hexgrid 不是被const修饰了吗?为什么还要 if(hexgrid)?
2.(xoff<<(y&0x1))是啥意思呢

跪求大佬解惑一下~

----------------------------------------------------------------------------------------------------------------------------
函数如下:
void getLABXYSeeds(int STEP, int width, int height, int* seedIndices, int* numseeds)
const bool hexgrid = false;
int n;
int xstrips, ystrips;
double xerrperstrip,yerrperstrip;
int xoff,yoff;
int x,y;
int xe,ye;
int seedx,seedy;
int i;

xstrips = (0.5+(double)(width)/(double)(STEP));
ystrips = (0.5+(double)(height)/(double)(STEP));

xerr = width - STEP*xstrips;if(xerr < 0){xstrips--;xerr = width - STEP*xstrips;}
yerr = height - STEP*ystrips;if(yerr < 0){ystrips--;yerr = height- STEP*ystrips;}

xerrperstrip = (double)(xerr)/(double)(xstrips);
yerrperstrip = (double)(yerr)/(double)(ystrips);

xoff = STEP/2;
yoff = STEP/2;

n = 0;
for( y = 0; y < ystrips; y++ )
{
ye = y*yerrperstrip;
for( x = 0; x < xstrips; x++ )
{
xe = x*xerrperstrip;
seedx = (x*STEP+xoff+xe);

if(hexgrid){ seedx = x*STEP+(xoff<<(y&0x1))+xe; if(seedx >= width)seedx = width-1; }//for hex grid sampling

seedy = (y*STEP+yoff+ye);
i = seedy*width + seedx;
seedIndices[n] = i;
n++;
}
}
*numseeds = n;
}
...全文
101 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧