这是我的代码,我有一个关于数组索引超出范围的错误。 plzz帮助我纠正它
I = imread('E:\degraded images\village.jpg');
imshow(I)
I = im2double(I);
I = log(1 + I);
M = 2*size(I,1) + 1;
N = 2*size(I,2) + 1;
sigma = 10;
[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)); ** here the code has error . ??? Error using ==> times Number of array dimensions must match for binary array op.**
答案 0 :(得分:0)
H
是2-D而If
是3-D。您可以将repmat
与H
或子集If
一起使用。我不知道哪一个对你的情况是正确的。例如,
rempat( H, [1, 1, 3 ] ) .* If;
或
H .* If(:,:,ind); % ind is the index of the 2-D array you want to subset