実現したいこと
「該当のソースコード」はこちらにあります。
11行目の関数radon、40行目の関数iradonのソースがどうなっているかを知ることができるかどうか、という質問です。radonやiradonは等間隔のデータに対して適用できるものです。
不等間隔のデータに対して、ラドン変換やラドン逆変換をやりたいときは自分でコードを書かなければいけないと思うのですが、その参考に等間隔のときのソースコードを読みたいと思っています。
該当のソースコード
python
1import numpy as np 2import matplotlib.pyplot as plt 3from skimage.data import shepp_logan_phantom 4from skimage.transform import radon, rescale 5 6image = shepp_logan_phantom() 7 8fig, ax2 = plt.subplots(1, 1, figsize=(4, 4)) 9 10theta = np.linspace(0., 180., max(image.shape), endpoint=False) 11sinogram = radon(image, theta=theta) 12dx, dy = 0.5 * 180.0 / max(image.shape), 0.5 / sinogram.shape[0] 13ax2.imshow(sinogram, cmap=plt.cm.Greys_r, 14 extent=(-dx, 180.0 + dx, -dy, sinogram.shape[0] + dy), 15 aspect='auto') 16fig.tight_layout() 17plt.show() 18 19####################################### 20# Reconstruction with the Filtered Back Projection (FBP) 21 22from skimage.transform.radon_transform import _get_fourier_filter 23 24filters = ['ramp', 'shepp-logan', 'cosine', 'hamming', 'hann'] 25 26for ix, f in enumerate(filters): 27 response = _get_fourier_filter(2000, f) 28 plt.plot(response, label=f) 29 30plt.xlim([0, 1000]) 31plt.xlabel('frequency') 32plt.legend() 33plt.show() 34 35##################################### 36# Applying the inverse radon transformation with the 'ramp' filter, we get: 37 38from skimage.transform import iradon 39 40reconstruction_fbp = iradon(sinogram, theta=theta, filter_name='ramp') 41error = reconstruction_fbp - image 42 43imkwargs = dict(vmin=-0.2, vmax=0.2) 44fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4.5), 45 sharex=True, sharey=True) 46ax1.set_title("Reconstruction\nFiltered back projection") 47ax1.imshow(reconstruction_fbp, cmap=plt.cm.Greys_r) 48ax2.set_title("Reconstruction error\nFiltered back projection") 49ax2.imshow(reconstruction_fbp - image, cmap=plt.cm.Greys_r, **imkwargs) 50plt.show()
試したこと
ネットでいろいろ検索しましたが、ソースは見つけられませんでした。
scikit-image の API リファレンスにソースコードへのリンクがあります。
skimage.transform — skimage 0.23.2 documentation
https://scikit-image.org/docs/stable/api/skimage.transform.html
radon
https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.radon
https://github.com/scikit-image/scikit-image/blob/v0.23.2/skimage/transform/radon_transform.py#L16-L114
iradon
https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.iradon
https://github.com/scikit-image/scikit-image/blob/v0.23.2/skimage/transform/radon_transform.py#L187-L323
>melian様
ありがとうございました。
githubの方は見つけられていなかったので助かりました。

回答2件
あなたの回答
tips
プレビュー