-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
The Python binding for the MR 2D1D transform gives different results to the executable binary. This needs to be investigated and fixed.
Example
See the following example when running PySAP.
import os
import numpy as np
import matplotlib.pyplot as plt
import pysap
from pysap.data import get_sample_data
from pysap.extensions import mr2d1d_trans
from pysap.extensions.sparse2d import MR2D1D
# Example MR data
mr_image = get_sample_data(dataset_name="multiresolution").data
# Transform settings
type_of_transform=14
normalize=True
number_of_scales_2D=5
number_of_scales_1D=4
# Python Binding for MR 2D1D
MR2D1D_inst = MR2D1D(
type_of_transform=type_of_transform,
normalize=normalize,
NbrScale2d=number_of_scales_2D,
Nbr_Plan=number_of_scales_1D,
)
MR2D1D_inst.transform(mr_image)
MR2D1D_res = MR2D1D_inst.cube
# Python Wrapper for MR 2D1D
with pysap.TempDir(isap=True) as tmpdir:
in_image = os.path.join(tmpdir, "in.fits")
out_file = os.path.join(tmpdir, "out.mr")
pysap.io.save(mr_image, in_image)
mr2d1d_trans(
in_image,
out_file,
type_of_multiresolution_transform=type_of_transform,
normalize=normalize,
number_of_scales_2D=number_of_scales_2D,
number_of_scales_1D=number_of_scales_1D,
)
mr2d1d_trans_res = np.copy(pysap.io.load(out_file))The input data look like this
fig, axes = plt.subplots(nrows=1, ncols=4, figsize=(12, 5))
for index, (ax, image) in enumerate(zip(axes, mr_image.T)):
ax.imshow(image)
ax.axis('off')
ax.set_title(f'Scale {index + 1}')
fig.suptitle('Multiresolution Data', fontsize=20)
plt.show()and the transform results look like this.
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(12, 5))
ax[0].plot(MR2D1D_res, label='Binding')
ax[0].plot(mr2d1d_trans_res, label='Wrapper')
ax[0].legend()
ax[0].set_title('MR 2D1D Transform')
ax[1].plot(MR2D1D_res - mr2d1d_trans_res)
ax[1].set_title('Binding - Wrapper')
plt.show()
