IDL - 将 2D 数组重塑为 3D 数组
IDL - Reshape 2D-Array to 3D-Array
在 IDL 中,我有一个数据立方体,其中包含不同时间的(灰度)图像:数据立方体 [w, h, frames]。现在我想使用 IDLFFVideoWrite 将该数据立方体转换成动画,但问题是,Put-Method 只吃排序帧 [3, w, h] 的帧。
如何将我的数据立方体的单个框架转换为适合 IDLffVideoWrite::Put 的框架?
您有灰度图像,因此我们需要制作所有三个波段(R、G 和 B)只是一个波段的副本。 REBIN
和 REFORM
是 "juggling dimensions" 的工具,例如:
frame = rebin(reform(datacube[*, *, i], 1, w, h), 3, w, h)
只要datacube
是字节数据,frame
就适合IDLffVideoWrite::put
。
更新:编辑答案,因为我在评论中的格式选项有限。
所以你实际上有一个 datacube
这种形式然后:
datacube[w, h, 3 * n_frames]
所以你应该对datacube
这样做,这样更容易对付:
datacube = transpose(reform(datacube, w, h, 3, n_frames), [2, 0, 1, 3])
然后,要获取第 i
帧,您可以这样做:
frame = reform(datacube[*, *, *, i])
在 IDL 中,我有一个数据立方体,其中包含不同时间的(灰度)图像:数据立方体 [w, h, frames]。现在我想使用 IDLFFVideoWrite 将该数据立方体转换成动画,但问题是,Put-Method 只吃排序帧 [3, w, h] 的帧。
如何将我的数据立方体的单个框架转换为适合 IDLffVideoWrite::Put 的框架?
您有灰度图像,因此我们需要制作所有三个波段(R、G 和 B)只是一个波段的副本。 REBIN
和 REFORM
是 "juggling dimensions" 的工具,例如:
frame = rebin(reform(datacube[*, *, i], 1, w, h), 3, w, h)
只要datacube
是字节数据,frame
就适合IDLffVideoWrite::put
。
更新:编辑答案,因为我在评论中的格式选项有限。
所以你实际上有一个 datacube
这种形式然后:
datacube[w, h, 3 * n_frames]
所以你应该对datacube
这样做,这样更容易对付:
datacube = transpose(reform(datacube, w, h, 3, n_frames), [2, 0, 1, 3])
然后,要获取第 i
帧,您可以这样做:
frame = reform(datacube[*, *, *, i])