MATLAB: Error using .* Matrix dimensions must agree on line I_f1=I_f.*(H_em) i didn’t understand how to remove this bug.

matrix dimension

[f1,f2] = freqspace(size(J), 'meshgrid' ); D = sqrt(f1.^2 + f2.^2); H_b=1./((1+0.1./D).^2); %Butterworth high-pass filter H_em=0.5+0.75*H_b; %High frequency emphasis filter H_em=ifftshift(H_em); % Perform filtering in frequency domain
I_f=fft2(J); I_f1=I_f.*(H_em); I2=uint8(ifft2(I_f1)); imshow(I2); histeq(I2);

Best Answer

Ensure that I_f and (H_em) having the same size. Analyze(size) of one by one line, you will get the error.
Note
[f1,f2]=freqspace(n) returns the two-dimensional frequency vectors f1 and f2 for an n-by-n matrix.
Related Question