Hi,
Even though I use acceptable matrix dimensions, I am getting Matrix dimensions error. dft matrix size is: 500x332 H_blurring matrix size is: 332x500 I multiply these 2 matrix.
"Error using .*
Matrix dimensions must agree."
if true
% A=load('Blurred.mat');
B=A.blurred;
image = im2double(B);
[rows, cols] = size(image);
figure; imshow(image,[]); title('Original image');
%%Blurring (atmospheric turbulence)
dft = fftshift(fft2(image));
k = 0.002;
u0 = floor(rows/2)+1;
v0 = floor(cols/2)+1;
u = (1:rows)-u0;
v = (1:cols)-v0;
[U,V] = meshgrid(u,v);
D = (U.^2+V.^2);
H_blurring = exp(-k*(D.^(5/6)));
figure;
imshow(dft); title('dft');
figure;
imshow(H_blurring); title('Blurred');
result = dft .* H_blurring;
end

 Accepted Answer

Ismail - using the .* implies that you want to do element-wise multiplication i.e. multiply each element of one matrix with the corresponding (same row and column) element of the other matrix. Since your matrices are of different dimensions then the error makes sense. Just change this line to
result = dft * H_blurring;
and you will now be doing the usual matrix multiplication.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!