如何更改图像尺寸的顺序

2024-09-30 04:27:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有5个波段的图像数据库:

RGB + alpha (a) + topography (t).

我知道如何反转RGB(没有其他波段)以获得BGR:tf.reverse(image_patch, axis = [-1])

image_patchTensor("Sub:0", shape=(256, 256, 5), dtype=float32)

但是我怎样才能改变这个张量的维数,按照这个顺序:BGRat


Tags: 图像imagealpha数据库tf波段rgbpatch
1条回答
网友
1楼 · 发布于 2024-09-30 04:27:44

您可以使用^{}方法

示例代码

import tensorflow as tf

# Parameters
rows = 2
shift = 3

a = tf.placeholder(dtype=tf.int64, shape=(rows, 5))
b = tf.reverse_sequence(a, seq_lengths=[shift] * rows, batch_dim = 0, seq_dim=1)

sess = tf.Session()
print(sess.run(b, feed_dict={a: [[1, 2, 3, 4, 5], 
                                [1, 2, 3, 4, 5]]}))

结果

# a - sample input
[[1 2 3 4 5]
 [1 2 3 4 5]]

# b - shifted columns
[[3 2 1 4 5]
 [3 2 1 4 5]]

相关问题 更多 >

    热门问题