在 MATLAB 中使用 FFT 过滤图像时如何解决“Arrays have incompatible sizes”错误?

问题描述 投票:0回答:0

我正在尝试计算数组的 FFT,但出现错误:“数组大小不兼容”。我该如何解决这个问题?这是我的代码:

% Read the image
im = imread('image2.jpg');

% Convert the image to double precision
im = im2double(im);

% Compute the FFT of the image
F = fft2(im);

% Define the filter mask
mask = [-1 -1 -1; -1 8 -1; -1 -1 -1];

% Filter the FFT using the mask
F_filtered = F .* fftshift(mask);

% Display the magnitude of the filtered FFT
imshow(log(abs(fftshift(F_filtered))), []); 

this error is coming 
Arrays have incompatible sizes for this operation.

Error in task3 (line 32)
F_filtered = F .* fftshift(mask);
matlab
© www.soinside.com 2019 - 2024. All rights reserved.