Skip to content

Commit

Permalink
update tuto7: added very different noise level to improve appreciation
Browse files Browse the repository at this point in the history
  • Loading branch information
jabascal committed May 17, 2024
1 parent b77b9c2 commit 0ad0f0d
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions tutorial/tuto_07_drunet_split_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,33 +227,42 @@
) # reconstruct from raw measurements

###############################################################################
# We can set another noise level and reconstruct another image.
# We can set other noise levels and reconstruct the images to see how
# a higher noise level increases the blurring effect.

from spyrit.misc.disp import add_colorbar, noaxis

# Set noise level
noise_level_2 = 3
denoi_drunet.set_noise_level(noise_level_2)

# Set new noise levels and reconstruct
with torch.no_grad():
# reconstruct from raw measurements
noise_level_2 = 1
denoi_drunet.set_noise_level(noise_level_2)
z_dcnet_drunet_2 = dcnet_drunet.reconstruct(y.to(device))

noise_level_3 = 20
denoi_drunet.set_noise_level(noise_level_3)
z_dcnet_drunet_3 = dcnet_drunet.reconstruct(y.to(device))

# Plot the two reconstructions
x_plot = z_dcnet_drunet.view(-1, h, h).cpu().numpy()
x_plot2 = z_dcnet_drunet_2.view(-1, h, h).cpu().numpy()
x_plot3 = z_dcnet_drunet_3.view(-1, h, h).cpu().numpy()

f, axs = plt.subplots(1, 2, figsize=(10, 5))
im1 = axs[0].imshow(x_plot[0, :, :], cmap="gray")
axs[0].set_title(f"DCNET with DRUNet\n (n map={noise_level})", fontsize=16)
f, axs = plt.subplots(1, 3, figsize=(10, 5))
im1 = axs[0].imshow(x_plot2[0, :, :], cmap="gray")
axs[0].set_title(f"DCNET with DRUNet\n (n map={noise_level_2})", fontsize=16)
noaxis(axs[0])
add_colorbar(im1, "bottom")

im2 = axs[1].imshow(x_plot2[0, :, :], cmap="gray")
axs[1].set_title(f"DCNET with DRUNet\n (n map={noise_level_2})", fontsize=16)
im2 = axs[1].imshow(x_plot[0, :, :], cmap="gray")
axs[1].set_title(f"DCNET with DRUNet\n (n map={noise_level})", fontsize=16)
noaxis(axs[1])
add_colorbar(im2, "bottom")

im3 = axs[2].imshow(x_plot3[0, :, :], cmap="gray")
axs[2].set_title(f"DCNET with DRUNet\n (n map={noise_level_3})", fontsize=16)
noaxis(axs[2])
add_colorbar(im3, "bottom")

# %%
# DRUNet denoising
# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 0ad0f0d

Please sign in to comment.