【发布时间】:2019-05-14 15:14:31
【问题描述】:
我想实现一个代码,对大小为 (bs x bs x bs) 的立方体内的信息进行洗牌,这样立方体 (x,y,z) 内的每个元素都唯一地映射到 (x_new, y_new,z )。但是代码不能正常工作。
所附图像是我尝试离散化和实现的代码的实际数学定义。原始数学方程适用于单位立方体,而我有一个维度为 bs 的立方体。有人可以看看我的代码并提示假定的错误吗?
n=bs;
NEWI=zeros(bs,bs,bs);
for row= 1:bs
for col=1:bs
for height=1:bs
if ( 1<=row && row<=(n/2) && 1<=col && col<=(n/2) )
x_new= 2*(row-1) + 1;
y_new= 2*(col-1) + 1;
z=floor(0.25*(height-mod(height-1,2)))+1;
end
for
for
for
Now this is just the first line implementation of the equation given in the figure. But as we see the coorepondence of points
(1,1,1) goes to (1,1,1)
(1,1,2) goes to (1,1,1)
(1,1,3) goes to (1,1,1)
(1,1,4) goes to (1,1,1)
which clearly is not a unique mapping, whereas the function claims of giving unique images for every (x,y,z). So my question is clearly there has to be some adjustments to discretize this map. Can somebody suggest
【问题讨论】:
-
为什么你认为它错了?想解释一下你的方程和你分享的方程之间的区别吗?愿意提供minimal reproducible example 吗?
-
我发现了一个问题,那就是您将 n/2 乘以 2:
y_new= 2*(col-1-n/2)。这与说y_new = 2*col - 2 - n相同,总是否定的。我想你的意思是y_new= 2*(col-1)-n/2。x_new也重复此错误。我也不确定您为什么在每个操作中都涉及height值的奇偶校验。 -
为什么会是负数?我已经包含了条件:col>n/2, already
-
方程在 x 和 y 方向上将信息传播了 2 倍,并沿 z 方向将其压缩了 4 倍。显然,这在离散世界中是行不通的。
z/4在 4 种情况下有 3 种会导致亚像素位置。这就是为什么您有 4 个值映射到同一位置的原因。 -
但是我正在阅读的文章说它映射点是唯一的。