How to solve "Error using .* Matrix dimensions must agree."?

1 回表示 (過去 30 日間)
Nayana R
Nayana R 2018 年 10 月 20 日
コメント済み: Nayana R 2018 年 10 月 20 日
My code is to use Hormomorphic filtering.But i am having an error like matrix dimension must agree.I read many answers related to this but I don't understand how to apply it to my code. My image resolution size is 1935*2400.Is it the problem or how can i solve this problem?
I = imread('cephalogram.bmp');
I = im2double(I);
I = log(1 + I);
M = 2*size(I,1) + 1;
N = 2*size(I,2) + 1;
sigma = 10;
%create the high-pass filter...
[X, Y] = meshgrid(1:N,1:M);
centerX = ceil(N/2);
centerY = ceil(M/2);
gaussianNumerator = (X - centerX).^2 + (Y - centerY).^2;
H = exp(-gaussianNumerator./(2*sigma.^2));
H = 1 - H;
imshow(H,'InitialMagnification',25);
H = fftshift(H);
If = fft2(I, M, N);
Iout = real(ifft2(H.*If));
Iout = Iout(1:size(I,1),1:size(I,2));
Ihmf = exp(Iout) - 1;
imshowpair(I, Ihmf, 'montage');

採用された回答

Walter Roberson
Walter Roberson 2018 年 10 月 20 日
We do not know if your inage is rgb (3 dimensions) or grayscale (2 dimensions)
You construct H to be nearly twice the size of the image but you expect to be able to do element by element multiplication between the two.
  1 件のコメント
Nayana R
Nayana R 2018 年 10 月 20 日
It is rgb image.I convert it to gray image and it worked.Thank you Walter Roberson.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by