标签: back-projection

在 TensorFlow 中将张量保存为图像

这可能是一个简单的问题。我只是想对图像进行氡变换并使用 TensorFlow 中的函数保存它。但结果不对。我知道我可以使用 plt.imsave() 来正确保存图像,但我想知道如何在 TensorFlow 中做到这一点。

我是 TensorFlow 的新手,感谢您的帮助。

这是shepp-logan.jpg我使用的图像。它是大小为 64*64 的灰度图像

这是保存的图片

这是我的代码。

from skimage.transform import radon,iradon
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np

sess = tf.Session()
img = plt.imread('shepp-logan.jpg')
theta = np.linspace(0., 180., max(img.shape), endpoint=False)
sinogram = radon(img, theta=theta, circle=True)
sinogram = tf.cast(sinogram, tf.uint8)
sinogram = tf.expand_dims(sinogram, -1)
sinogram = tf.image.encode_jpeg(sinogram, quality=100, format='grayscale')
writer = tf.write_file('test_sinogram.jpg', sinogram)
sess.run(writer)
Run Code Online (Sandbox Code Playgroud)

python back-projection tensorflow

5
推荐指数
1
解决办法
4504
查看次数

标签 统计

back-projection ×1

python ×1

tensorflow ×1