问题描述
如果 wsplit = 1
我想根据宽度分割,否则根据高度分割。
threshold
将定义是否拆分。
tx,ty
将是四边形的左上角坐标。
sx
= 原图的宽度
它会像
(tx:ty = 0:0 w = 512,h = 512,wsplit = 1) ---> A
分割后
(tx:ty = 0 :0 w = 256,wsplit = 0) ---> B
(tx:ty = 256:0 w = 256,wsplit = 0) ---> C
将在 BST(四叉树)中
所以我做到了
Quad *split(Image *im,Quad *root,int threshold) {
if (root == NULL)
return NULL;
if (similar(im,root,threshold) == 0){ //this will define should split or not
int tx = root->tx;;
int ty = root->ty;
int w = root->w;
int h = root->h;
int wsplit = root->wsplit;
int sx = root->sx;
int tx2,ty2,w1,w2,h1,h2;
if(wsplit==0){
h1 = (int)floor(h/2);
h2 = h-h1;
ty2 = ty+h1;
wsplit = 1;
}
else{
w1 = (int)floor(w/2);
w2 = w-w1;
tx2 = tx+w1;
wsplit = 0;
}
Quad *first = NULL;
Quad *second = NULL;
first = new_Quad(tx,ty,wsplit,sx);
second = new_Quad(tx2,h2,sx);
root = quad_delete(root,tx,ty);
root = insert(root,first);
root = insert(root,second);
}
split(im,root->left,threshold);
split(im,root->right,threshold);
return root;
}
将全部分成两半,但我不知道为什么它不起作用。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)