From cf213903955f952e978b7a6e9f3a45101870ea22 Mon Sep 17 00:00:00 2001 From: otto Date: Fri, 24 Oct 2025 17:07:41 +0300 Subject: [PATCH] image and noisy image mse as first mse, visibility changes --- deconvolve_func.py | 29 +---------------------------- pohi.py | 10 +++++++--- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/deconvolve_func.py b/deconvolve_func.py index 0121f98..56b7ba9 100644 --- a/deconvolve_func.py +++ b/deconvolve_func.py @@ -100,9 +100,7 @@ class DeconvolveWithBead: win_size = 7 #default = 7 #ms_ssim = [] - # minimum = None #[] - # previous = None - best_mse = np.inf #float('inf') + best_mse = np.inf minn = None print("Deconvolving:", psf.min(), psf.max(), psf.sum(), otf.sum(), on.sum()) @@ -116,35 +114,10 @@ class DeconvolveWithBead: #slicing mse to remove unwanted irrelevant data around the "sõõr" onsum = on.sum() - # # saving the previous image - # if previous is None: - # minimum = on.copy() #[on] - # else: - # minimum = previous.copy() #[previous] - # previous = on.copy() - if mse[-1] < best_mse: best_mse = mse[-1] minn = on.copy() - # if len(mse) >= 2 and mse[-2] < mse[-1]: - # minn = minimum - # print("---------------------miinimum-pilt-on-leitud------------------------------------") - - - # fig = plt.figure() - # ax1 = fig.add_subplot(141) - # ax2 = fig.add_subplot(142) - # ax3 = fig.add_subplot(143) - # ax4 = fig.add_subplot(144) - - # ax1.imshow(bead) - # ax2.imshow(im) - # ax3.imshow(on) - # ax4.imshow(bead-on) - # plt.show() - #ms_ssim.append(msssim(on,bead)) - itr.append(it) # for iterations _mssim = ssim(bead, on, win_size = win_size, # okaalsem siis 3,5,7, kui globaalsem võrdlus, siis suurem diff --git a/pohi.py b/pohi.py index f99f056..9490d2a 100644 --- a/pohi.py +++ b/pohi.py @@ -86,8 +86,9 @@ with h5py.File(args.output, 'w') as hdf5_file: vox = np.array(vox) mses = [] mssim = [] - + for j in g_sigma: + MSE = np.sum((noisy_image - scaled_original)**2) / noisy_image.size # adding image and noisy image mse image_kerneled = gaussian_filter(noisy_image, sigma = j) psf_kerneled = gaussian_filter(psf, sigma = j) print(np.sum(image_kerneled),np.sum(noisy_image), np.sum(psf_kerneled), np.sum(psf)) @@ -101,8 +102,11 @@ with h5py.File(args.output, 'w') as hdf5_file: hdf5_file.create_dataset(f'ch{w:03d}/intensity_{i:08.3f}/SIGMA_{j:03.1f}', data = dec[0]) hdf5_file.create_dataset(f"ch{w:03d}/intensity_{i:08.3f}/minimum_image_{j:03.1f}", data = dec[4]) - - mses.append(dec[1]) + + dec[1][-1] = MSE + meansquare = np.concatenate(([dec[1][-1]], dec[1][:-1])) + mses.append(meansquare) + #mses.append(dec[1]) mssim.append(dec[2])