0001 clc;
0002 echo off;
0003
0004
0005
0006 disp('Loading image');
0007
0008 load barbara256;
0009 figure;
0010 imshow(Im/255);
0011 title('Original image');
0012
0013
0014
0015 disp('Degrading image (almost denoising)');
0016
0017
0018 fc = 16;
0019 Val_min = 0.001;
0020
0021
0022
0023 lim_frec = [0 3];
0024
0025
0026 vari = 200;
0027
0028 [Id,PSF,H,noise,Blurred]=degrada2(Im,fc,Val_min,lim_frec,vari);
0029 figure;
0030 imshow(Id/255);
0031 title(['Degraded image (fc = ' num2str(fc) ',sigma^2 = ' num2str(vari) ')']);
0032
0033 disp('Press any key...');
0034 pause;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 Nlambdas = 1;
0046 lambdas = 5;
0047
0048
0049
0050 disp(['Restoring image using L2 (' num2str(Nlambdas) ' values of lambda)']);
0051
0052 imrl2=restaura2(Id,'L2',PSF,lambdas);
0053
0054 figure;
0055 imshow(imrl2/255);
0056 title('Restored (L2)');
0057
0058 disp('Press any key...');
0059 pause;
0060
0061
0062
0063
0064
0065 disp(['Restoring image using CSF (' num2str(Nlambdas) ' values of lambda)']);
0066
0067
0068 imrcsf=restaura2(Id,'CSF',PSF,lambdas);
0069
0070 figure;
0071 imshow(imrcsf/255);
0072 title('Restored (CSF)');
0073
0074 disp('Press any key...');
0075 pause;
0076
0077
0078
0079
0080
0081
0082 disp(['Restoring image using AR4 (' num2str(Nlambdas) ' values of lambda)']);
0083
0084
0085 imrar4=restaura2(Id,'AR4',PSF,lambdas);
0086
0087 figure;
0088 imshow(imrar4/255);
0089 title('Restored (AR4)');
0090
0091 disp('Press any key...');
0092 pause;
0093
0094
0095
0096
0097
0098
0099 disp(['Restoring image using AR8 (' num2str(Nlambdas) ' values of lambda)']);
0100
0101
0102 imrar8=restaura2(Id,'AR8',PSF,lambdas);
0103
0104 figure;
0105 imshow(imrar8/255);
0106 title('Restored (AR8)');
0107
0108 disp('Press any key...');
0109 pause;
0110
0111
0112
0113
0114
0115
0116
0117 disp(['Restoring image using AR12 (' num2str(Nlambdas) ' values of lambda)']);
0118
0119
0120 imrar12=restaura2(Id,'AR12',PSF,lambdas);
0121
0122 figure;
0123 imshow(imrar12/255);
0124 title('Restored (AR12)');
0125
0126 disp('Press any key...');
0127 pause;
0128
0129
0130
0131
0132
0133
0134 disp(['Restoring image using PERCEPTUAL (' num2str(Nlambdas) ' values of lambda)']);
0135
0136
0137 imrper=restaura2(Id,'PER',PSF,lambdas);
0138
0139 figure;
0140 imshow(imrper/255);
0141 title('Restored (PERCEPTUAL)');
0142
0143
0144
0145
0146 disp('ERROR MEASURES:');
0147
0148 disp('PSNR');
0149 cad = sprintf('L2: %6.3f,\t CSF: %6.3f, AR4: %6.3f, AR8: %6.3f, AR12: %6.3f, PER: %6.3f',psnr(Im,imrl2),psnr(Im,imrcsf),psnr(Im,imrar4),psnr(Im,imrar8),psnr(Im,imrar12),psnr(Im,imrper));
0150 disp(cad);
0151
0152
0153 disp('MSE');
0154 cad = sprintf('L2: %6.3f,\t CSF: %6.3f, AR4: %6.3f, AR8: %6.3f, AR12: %6.3f, PER: %6.3f',mse(Im,imrl2),mse(Im,imrcsf),mse(Im,imrar4),mse(Im,imrar8),mse(Im,imrar12),mse(Im,imrper));
0155 disp(cad);
0156