200万赞助力写作

110. 投影和雷登变换

2025-09-02  本文已影响0人  大龙10

7. 图像复原与重建索引

一、投影重建图像

二、断层成像

三、投影和雷登变换(Radon transform)

四、例程

import cv2
import numpy as np
from matplotlib import pyplot as plt

# # 9.24: 雷登变换正弦图
from scipy import ndimage
def discreteRadonTransform(image, steps):
    channels = image.shape[0]
    res = np.zeros((channels, channels), dtype=np.float32)
    for s in range(steps):
        rotation = ndimage.rotate(image, -s * 180/steps, reshape=False).astype(np.float32)
        res[:, s] = sum(rotation)
    return res

# # 读取原始图像
plt.figure(figsize=(9, 7))
fileImg = ["Fig0534a.tif", "Fig0534b.tif", "Fig0534c.tif"]  # 原始图像 文件名
for i in range(len(fileImg)):
    img = cv2.imread("../images/"+fileImg[i], flags=0)  # flags=0 读取为灰度图像
    imgRadon = discreteRadonTransform(img, img.shape[0])  # Radon 变换
    print(img.shape, imgRadon.shape)

    plt.subplot(2, len(fileImg), i + 1), plt.axis('off')  # 绘制原始图像
    plt.title("origin image"), plt.imshow(img, 'gray')
    plt.subplot(2, len(fileImg), i + len(fileImg) + 1), plt.axis('off')  # 绘制 sinogram 图
    plt.title("Radon transform"), plt.imshow(imgRadon, 'gray')

plt.tight_layout()
plt.show()

五、资料

youcans_的博客:
https://blog.csdn.net/youcans/article/details/123088031
上一篇 下一篇

猜你喜欢

热点阅读