close all; clear; clc; h = fspecial('gaussian', [9 9], 4); % Beck-Teboulle SIAM 2009 h =…
- User
close all; clear; clc; h = fspecial('gaussian', [9 9], 4); % Beck-Teboulle SIAM 2009 h = h./sum(h(:)); blur = @(im) imfilter(im,h,'conv','circular'); eps_val = 1e-6; noise_mean = 0; noise_var = 0.000001; % 10^{-6} Beck-Teboulle SIAM 2009 % Load image f = im2double(imread('images\barbara_face.png')); %f = im2double(imread('cameraman.tif')); % Apply blur and add noise g = imfilter(f,h,'conv','circular'); % blur g = imnoise(g,'gaussian',noise_mean,noise_var); % adding noise H = psf2otf(h,size(g)); psnr0 = psnr(f,g); psnrISRA = [psnr0]; % Initialize PSNR for ISRA ISRA = g; % Initialize ISRA G = fft2(g); maxiter = 700; for i = 1:maxiter % ISRA iterations: ISRA = ISRA.(h(-x)g./(h(-x)h(x)ISRA)) ISRA = (ISRA . ifft2(fft2(blur(g) ./ (blur(ISRA) + eps_val)) . conj(H))); ISRA = ISRA ./ (ifft2(conj(H) . fft2(blur(ISRA) + eps_val) . conj(H)));
psnr_ISRA = psnr(ISRA,f) psnrISRA = [psnrISRA; psnr_ISRA]; % fprintf('i = %d psnr_ISRA = %f\n', i, psnr_ISRA);end
% Plot PSNR graphs figure(); % Creating a subplot for the PSNR graphs semilogy(1.5,'Color',[0,0,1]),axis([1 maxiter 0 30]); hold on; semilogy(psnrISRA,'LineWidth',1.5,'Color',[0,0,0]); legend( 'ISRA'); xlabel('Iterations'); ylabel('PSNR');
figure; imshow(ISRA)
whats wrong with this code
- Assistant
There are several issues with the code provided. I will enumerate them below with explanations and corrections:
-
Incorrect ISRA iteration formula:
The ISRA algorithm formula seems to be misinterpreted. It should typically be something along the lines of:
ISRA = ISRA .* ifft2(fft2(g) ./ (H .* fft2(ISRA) + eps_val));
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.