-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
8 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"mount_file_id":"148avQOP_yupuCfXY_ghYCQM7JzrTiBc_","authorship_tag":"ABX9TyMWxPpKqyjvJ2q/Mrbqmih8"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":34,"metadata":{"id":"YO4wcpAAAY6b","executionInfo":{"status":"ok","timestamp":1700523823098,"user_tz":-60,"elapsed":239,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"outputs":[],"source":["import matplotlib.pyplot as plt\n","from skimage.restoration import (denoise_wavelet, estimate_sigma)\n","from skimage.util import random_noise\n","from skimage.metrics import peak_signal_noise_ratio\n","import skimage.io\n","\n","import warnings\n","warnings.filterwarnings('ignore')"]},{"cell_type":"code","source":["img = skimage.io.imread('/content/drive/MyDrive/FWT_data/lena.bmp')\n","img = skimage.img_as_float(img) # converting image as float"],"metadata":{"id":"TRDeFkCdAz-p","executionInfo":{"status":"ok","timestamp":1700523823349,"user_tz":-60,"elapsed":2,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":35,"outputs":[]},{"cell_type":"code","source":["sigma = 0.1 # Noise standard deviation\n","imgn = random_noise(img, var = sigma**2) # adding noise"],"metadata":{"id":"TC62Rn-MA-Eq","executionInfo":{"status":"ok","timestamp":1700523823349,"user_tz":-60,"elapsed":2,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":36,"outputs":[]},{"cell_type":"code","source":["sigma_est = estimate_sigma(imgn, average_sigmas = True) # noise estimation"],"metadata":{"id":"KU1FSgPRBNTZ","executionInfo":{"status":"ok","timestamp":1700523823715,"user_tz":-60,"elapsed":368,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":37,"outputs":[]},{"cell_type":"code","source":["# Denoising using Bayes\n","img_bayes = denoise_wavelet(imgn,\n"," method = 'BayesShrink',\n"," mode = 'soft',\n"," wavelet_levels = 3,\n"," wavelet = 'bior6.8',\n"," rescale_sigma = True)"],"metadata":{"id":"YjE0gNCDBV1K","executionInfo":{"status":"ok","timestamp":1700523823716,"user_tz":-60,"elapsed":3,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":38,"outputs":[]},{"cell_type":"code","source":["# Denoising using Visushrink\n","img_visushrink = denoise_wavelet(imgn,\n"," method = 'VisuShrink',\n"," mode = 'soft',\n"," sigma = sigma_est/3,\n"," wavelet_levels = 5,\n"," wavelet = 'bior6.8',\n"," rescale_sigma = True)"],"metadata":{"id":"3Y_p9ym_BmaD","executionInfo":{"status":"ok","timestamp":1700523823945,"user_tz":-60,"elapsed":232,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":39,"outputs":[]},{"cell_type":"code","source":["# Finding PSNR\n","psnr_noisy = peak_signal_noise_ratio(img, imgn)\n","psnr_bayes = peak_signal_noise_ratio(img, img_bayes)\n","psnr_visu = peak_signal_noise_ratio(img, img_visushrink)"],"metadata":{"id":"jXx-JXpVCJgW","executionInfo":{"status":"ok","timestamp":1700523823946,"user_tz":-60,"elapsed":6,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":40,"outputs":[]},{"cell_type":"code","source":["plt.figure(figsize = (30, 30))\n","\n","plt.subplot(2, 2, 1)\n","plt.imshow(img, cmap = plt.cm.gray)\n","plt.title('Original image', fontsize = 30)\n","\n","plt.subplot(2, 2, 2)\n","plt.imshow(imgn, cmap = plt.cm.gray)\n","plt.title('Noisy image', fontsize = 30)\n","\n","plt.subplot(2, 2, 3)\n","plt.imshow(img_bayes, cmap = plt.cm.gray)\n","plt.title('Denoised image using Bayes', fontsize = 30)\n","\n","plt.subplot(2, 2, 4)\n","plt.imshow(img_visushrink, cmap = plt.cm.gray)\n","plt.title('Denoised image using VisuShrink', fontsize = 30)\n","\n","plt.show()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":652,"output_embedded_package_id":"1rDKBzdIr68YceMuSFNo61cNqDnLkac9X"},"id":"1nKCjZ_bCgU5","executionInfo":{"status":"ok","timestamp":1700523831813,"user_tz":-60,"elapsed":7872,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}},"outputId":"9744bdda-c0f7-42f5-c7a1-52e7b7cd34ee"},"execution_count":41,"outputs":[{"output_type":"display_data","data":{"text/plain":"Output hidden; open in https://colab.research.google.com to view."},"metadata":{}}]},{"cell_type":"code","source":["print('PSNR (Original vs. Noisy image = ', psnr_noisy)\n","print('PSNR (Original vs. Denoised (VisuShrink) = ', psnr_visu)\n","print('PSNR (Original vs. Denoised (Bayes) = ', psnr_bayes)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gcq2GevYDJKt","executionInfo":{"status":"ok","timestamp":1700523831813,"user_tz":-60,"elapsed":8,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}},"outputId":"eede6ded-2621-4371-f53e-37a6dd9c2e79"},"execution_count":42,"outputs":[{"output_type":"stream","name":"stdout","text":["PSNR (Original vs. Noisy image = 20.08342220096964\n","PSNR (Original vs. Denoised (VisuShrink) = 28.14414205733516\n","PSNR (Original vs. Denoised (Bayes) = 28.99376335153445\n"]}]},{"cell_type":"code","source":[],"metadata":{"id":"1bam4YJUDstB","executionInfo":{"status":"ok","timestamp":1700523831814,"user_tz":-60,"elapsed":6,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":42,"outputs":[]}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"148avQOP_yupuCfXY_ghYCQM7JzrTiBc_","timestamp":1700523064348}],"mount_file_id":"1J_1DjSpg8TnloMlbRKB4Z5xeGGEfiTi4","authorship_tag":"ABX9TyOcs230DwPM0khMuK+kUrz7"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"id":"YO4wcpAAAY6b","executionInfo":{"status":"ok","timestamp":1701041501107,"user_tz":-60,"elapsed":1825,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"outputs":[],"source":["import matplotlib.pyplot as plt\n","from skimage.restoration import (denoise_wavelet, estimate_sigma)\n","from skimage.util import random_noise\n","from skimage.metrics import peak_signal_noise_ratio\n","import skimage.io\n","\n","import warnings\n","warnings.filterwarnings('ignore')"]},{"cell_type":"code","source":["img = skimage.io.imread('/content/drive/MyDrive/FWT_data/peppers.png')\n","img = skimage.img_as_float(img) # converting image as float"],"metadata":{"id":"TRDeFkCdAz-p","executionInfo":{"status":"ok","timestamp":1701041501476,"user_tz":-60,"elapsed":374,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":2,"outputs":[]},{"cell_type":"code","source":["sigma = 0.15 # Noise standard deviation\n","imgn = random_noise(img, var = sigma**2) # adding noise"],"metadata":{"id":"TC62Rn-MA-Eq","executionInfo":{"status":"ok","timestamp":1701041501476,"user_tz":-60,"elapsed":10,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":3,"outputs":[]},{"cell_type":"code","source":["sigma_est = estimate_sigma(imgn, multichannel = True, average_sigmas = True) # noise estimation"],"metadata":{"id":"KU1FSgPRBNTZ","executionInfo":{"status":"ok","timestamp":1701041501477,"user_tz":-60,"elapsed":9,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":4,"outputs":[]},{"cell_type":"code","source":["# Denoising using Bayes\n","img_bayes = denoise_wavelet(imgn,\n"," method = 'BayesShrink',\n"," mode = 'soft',\n"," wavelet_levels = 5,\n"," wavelet = 'coif5',\n"," multichannel = True,\n"," convert2ycbcr = True,\n"," rescale_sigma = True)"],"metadata":{"id":"YjE0gNCDBV1K","executionInfo":{"status":"ok","timestamp":1701041501477,"user_tz":-60,"elapsed":8,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":5,"outputs":[]},{"cell_type":"code","source":["# Denoising using Visushrink\n","img_visushrink = denoise_wavelet(imgn,\n"," method = 'VisuShrink',\n"," mode = 'soft',\n"," sigma = sigma_est/3,\n"," wavelet_levels = 5,\n"," wavelet = 'coif5',\n"," multichannel = True,\n"," convert2ycbcr = True,\n"," rescale_sigma = True)"],"metadata":{"id":"3Y_p9ym_BmaD","executionInfo":{"status":"ok","timestamp":1701041501862,"user_tz":-60,"elapsed":392,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":6,"outputs":[]},{"cell_type":"code","source":["# Finding PSNR\n","psnr_noisy = peak_signal_noise_ratio(img, imgn)\n","psnr_bayes = peak_signal_noise_ratio(img, img_bayes)\n","psnr_visu = peak_signal_noise_ratio(img, img_visushrink)"],"metadata":{"id":"jXx-JXpVCJgW","executionInfo":{"status":"ok","timestamp":1701041501863,"user_tz":-60,"elapsed":18,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":7,"outputs":[]},{"cell_type":"code","source":["plt.figure(figsize = (30, 30))\n","\n","plt.subplot(2, 2, 1)\n","plt.imshow(img, cmap = plt.cm.gray)\n","plt.title('Original image', fontsize = 30)\n","\n","plt.subplot(2, 2, 2)\n","plt.imshow(imgn, cmap = plt.cm.gray)\n","plt.title('Noisy image', fontsize = 30)\n","\n","plt.subplot(2, 2, 3)\n","plt.imshow(img_bayes, cmap = plt.cm.gray)\n","plt.title('Denoised image using Bayes', fontsize = 30)\n","\n","plt.subplot(2, 2, 4)\n","plt.imshow(img_visushrink, cmap = plt.cm.gray)\n","plt.title('Denoised image using VisuShrink', fontsize = 30)\n","\n","plt.show()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":1000,"output_embedded_package_id":"1VhmoqETYSj-1hibKcOJtwoj9iNIMxx2_"},"id":"1nKCjZ_bCgU5","executionInfo":{"status":"ok","timestamp":1701041521577,"user_tz":-60,"elapsed":19730,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}},"outputId":"284101f8-47bd-4546-e2a2-7b5470e50afc"},"execution_count":8,"outputs":[{"output_type":"display_data","data":{"text/plain":"Output hidden; open in https://colab.research.google.com to view."},"metadata":{}}]},{"cell_type":"code","source":["print('PSNR (Original vs. Noisy image = ', psnr_noisy)\n","print('PSNR (Original vs. Denoised (VisuShrink) = ', psnr_visu)\n","print('PSNR (Original vs. Denoised (Bayes) = ', psnr_bayes)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gcq2GevYDJKt","executionInfo":{"status":"ok","timestamp":1701041521578,"user_tz":-60,"elapsed":18,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}},"outputId":"63b613fb-6e0c-43b6-d911-9e2b6654a510"},"execution_count":9,"outputs":[{"output_type":"stream","name":"stdout","text":["PSNR (Original vs. Noisy image = 17.076309958044224\n","PSNR (Original vs. Denoised (VisuShrink) = 25.397400871293012\n","PSNR (Original vs. Denoised (Bayes) = 26.769860368667064\n"]}]},{"cell_type":"code","source":[],"metadata":{"id":"1bam4YJUDstB","executionInfo":{"status":"ok","timestamp":1701041521578,"user_tz":-60,"elapsed":16,"user":{"displayName":"Sachin Bharadwaj Manjunath","userId":"16663052345521703125"}}},"execution_count":9,"outputs":[]}]} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.