简体   繁体   English

从其 3 个投影和 2D 阵列重新生成 3D 阵列

[英]regenerate 3D Array from its 3 projection sum 2D arrays

I'm trying to find a programable way to regenerate any size 3D array - consists of 1 and 0 only - by knowing the three 2d arrays that show the sum of the original array on each axis as the pictures show :我试图找到一种可编程的方法来重新生成任何大小的 3D 数组 - 仅由 1 和 0 组成 - 通过了解三个二维数组,这些数组在每个轴上显示原始数组的总和,如图所示:

original 3d array原始 3d 阵列

the projection sum concept投影和概念

example of the sum code :总和代码示例:

int D = 3 ; 
int xsum[D][D] =  {0};
int ysum[D][D] =  {0};
int zsum[D][D] =  {0};

for(int x = 0 ; x<D ;x++){
    for(int y = 0 ; y<D ;y++){
        for(int d = 0 ;d<D;d++){
            zsum[x][y] = zsum[x][y] + array[d][y][x];
        }
    }
}
for(int x = 0 ; x<D ;x++){
    for(int z = 0 ;z<D ;z++){
        for(int d = 0 ;d<D;d++){
            ysum[x][z] = ysum[x][z]+array[z][d][x];
        }
    }
}
for(int z = 0 ;z<D ;z++){
    for(int y = 0 ; y<D ;y++){
        for(int d = 0 ;d<D;d++){
            xsum[z][y] = xsum[z][y]+ array[z][y][d];
        }
    }
}

I tried the easiest algorithm I could think of something like :我尝试了我能想到的最简单的算法:

for(int x = 0 ; x<D ; x++) {
   for(int y = 0 ; y<D ; y++) {
        if(zsum[x][y]> 0 ){
            for(int z = 0 ; z<D ;z++){
                if(xsum[z][y] > 0 && ysum[x][z] > 0){
                    rearray[z][y][x]= 1;
                    zsum[x][y]-- ;
                    xsum[z][y]-- ;
                    ysum[x][z]-- ;
                }
            }
        }
    }
}

it produces somthing very similar to the original array the bold numbers are different:它产生与原始数组非常相似的东西,粗体数字不同:

1,1,0 1,1,0
0,1,0 0,1,0
0,0,0 0,0,0

1 ,1, 0 1 ,1, 0
1,1,1 1,1,1
0 ,1, 1 0 ,1, 1

1,0,1 0,0,1 1,0,1 0,0,1
0,0,1 0,0,1

however when I make D = 4 or 5 more errors occur can anyone explain or suggest a correct algorithm to solve this problem ?但是,当我使 D = 4 或 5 出现更多错误时,有人可以解释或建议解决此问题的正确算法吗?

While there may happend to be solutions for particular values with sizes>3, there is no guaranteed solution because information is being lost in the summing - as it happens for size 3, there are 27 elements in the 3-D array, and also 27 elements in the projection, so it may be possible for there to always be a solution.虽然可能碰巧有大小> 3 的特定值的解决方案,但没有保证的解决方案,因为信息在求和过程中丢失 - 就像大小 3 一样,3-D 数组中有 27 个元素,还有 27投影中的元素,因此可能总是有一个解决方案。 However for larger sizes, for example 5, there are 125 elements in the 3-D array and only 75 in the projected 2-D arrays.然而,对于较大的尺寸,例如 5,3-D 阵列中有 125 个元素,而投影的 2-D 阵列中只有 75 个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM