I can't calculate psnr,mse,mad,rmse for below Lowpass Frequency Domain Filters code. i get (??? Error using ==> minus Matrix dimensions must agree.) this kind of error....

1 view (last 30 days)
%%Lowpass Frequency Domain Filters clc clear all close all fontSize = 20; footBall1=imread('C:\Users\shankar\Documents\MATLAB\filtering\lowpass\ship.jpg'); footBall=rgb2gray(footBall1); [m n]=size(footBall); footBall1=footBall1(:,:,1); % Grab only the Red component to fake gray scaling subplot(2,2,1),imshow(footBall),title('original image', 'FontSize', fontSize), PQ = paddedsize(size(footBall)); D0 = 0.05*PQ(1); H = lpfilter('gaussian', PQ(1), PQ(2), D0); % Calculate the LPF F=fft2(double(footBall),size(H,1),size(H,2)); % Calculate the discrete Fourier transform of the image LPF_football=real(ifft2(H.*F)); % multiply the Fourier spectrum by the LPF and apply the inverse, discrete Fourier transform LPF_football=LPF_football(1:size(footBall,1), 1:size(footBall,2)); % Resize the image to undo padding subplot(2,2,2), imshow(LPF_football, []),title('lpf image', 'FontSize', fontSize), % Display the Fourier Spectrum Fc=fftshift(F); % move the origin of the transform to the center of the frequency rectangle S2=log(1+abs(Fc)); % use abs to compute the magnitude (handling imaginary) and use log to brighten display subplot(2,2,3), imshow(S2,[]),title(' image', 'FontSize', fontSize),
squaredErrorImage = (double(footBall1) - double(S2)) .^ 2; mse = sum(sum(squaredErrorImage)) / (m * n); RMSE = sqrt(mse); PSNR = 10 * log10( 256^2 / mse); mad = mean2(abs(double(b)-double(S2))); message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f.\n THE RMSE=%.2f.\n THE mad=%.2f',mse, PSNR,RMSE,mad); msgbox(message);

Answers (0)

Community Treasure Hunt

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

Start Hunting!