I needed to plot Histograms (or) Loss Information for original image and after restoration of blur image

%% Input Image
Ioriginal = imread('greyface.jpg');
imshow(Ioriginal)
title('Original Image')
% % Restore Motion Blur Without Noise
PSF = fspecial('motion',21,11);
Idouble = im2double(Ioriginal);
blurred = imfilter(Idouble,PSF,'conv','circular');
imshow(blurred)
title('Blurred Image')
%%Restoring blur image
wnr1 = deconvwnr(blurred,PSF);
imshow(wnr1)
title('Restored Blurred Image')
%%Restore Motion Blur and Gaussian Noise
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred,'gaussian',noise_mean,noise_var);
imshow(blurred_noisy)
title('Blurred and Noisy Image')
wnr2 = deconvwnr(blurred_noisy,PSF);
imshow(wnr2)
title('Restoration of Blurred Noisy Image (NSR = 0)')
signal_var = var(Idouble(:));
NSR = noise_var / signal_var;
wnr3 = deconvwnr(blurred_noisy,PSF,NSR);
imshow(wnr3)
title('Restoration of Blurred Noisy Image (Estimated NSR)')

1 Comment

I Have to get a plots or loss information based on original image vs Restoration of Blurred Noisy Image

Sign in to comment.

Answers (1)

Why not use imabsdiff to get the difference between the original image and the restored image and then take the histogram of that difference image?
diffImage = imabsdiff(Ioriginal, wnr1);
histogram(diffImage);

4 Comments

@Image Analyst I am getting error
Error using checkForSameSizeAndClass (line 8)
X and Y must have the same class.
Error in imabsdiff (line 42)
checkForSameSizeAndClass(X, Y, mfilename);
Error in Untitled3 (line 35)
diffImage = imabsdiff(Ioriginal, wnr1);
>> Untitled3
Error using checkForSameSizeAndClass (line 8)
X and Y must have the same class.
Error in imabsdiff (line 42)
checkForSameSizeAndClass(X, Y, mfilename);
Error in Untitled3 (line 35)
diffImage = imabsdiff(Ioriginal, wnr1);
So make them both the same class, like uint8 or double.
@Image Analyst Even though i am getting same error can you please change the code and send me.
Ioriginal = imread('cameraman.tif');
% Restore Motion Blur Without Noise
PSF = fspecial('motion',21,11);
Idouble = im2double(Ioriginal);
blurred = imfilter(Idouble,PSF,'conv','circular');
% Restoring blur image
wnr1 = deconvwnr(blurred,PSF);
% assuming the abs difference is the thing you actually want
err = imabsdiff(Idouble,wnr1);
histogram(err)
% Restore Motion Blur and Gaussian Noise
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred,'gaussian',noise_mean,noise_var);
signal_var = var(Idouble(:));
NSR = noise_var / signal_var;
wnr3 = deconvwnr(blurred_noisy,PSF,NSR);
% assuming the abs difference is the thing you actually want
err = imabsdiff(Idouble,wnr3);
histogram(err)

Sign in to comment.

Asked:

on 20 Oct 2023

Commented:

DGM
on 21 Oct 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!