matlab图像处理错误
我正在尝试在 matlab 中找到图像的傅里叶变换。我在没有库函数帮助的情况下执行此操作。代码是:
clc;
clear;
N=128;
a=imread('lena128','bmp');
zeros(N,N);
for m=1:N
for n=1:N
w(m,n)=(exp(-1i*2*pi/N))^((m-1)*(n-1));
end
end
af1=(w*a);
af=((w*(af1.')).');
当我编译此程序时,会发生以下错误:
??? Error using ==> mtimes
Complex integer arithmetic is not supported.
Error in ==> qn4 at 12
af1=(w*a);
当我使用 a=rand(1,128) 而不是 a=imread('lena128','bmp') 时,我没有收到该错误。 我在网上搜索了一下,发现了类似的问题。但没有解决办法。有人能为我指出错误吗?
I am trying to find the fourier transform of an image in matlab. I am doing this without the hep of the library function. The code is:
clc;
clear;
N=128;
a=imread('lena128','bmp');
zeros(N,N);
for m=1:N
for n=1:N
w(m,n)=(exp(-1i*2*pi/N))^((m-1)*(n-1));
end
end
af1=(w*a);
af=((w*(af1.')).');
When I compile this program the following error occurs:
??? Error using ==> mtimes
Complex integer arithmetic is not supported.
Error in ==> qn4 at 12
af1=(w*a);
When I use a=rand(1,128), instead of a=imread('lena128','bmp'), I dont get that error.
I searched online and found similar problems. But no solution. Can anyone point out the error for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
imread
给你一个数组,其元素是整数(我认为是uint8
类型)。然后你尝试将它们与复数结合起来,但这不起作用。特别是,MATLAB 不会自动将它们转换为double
或float
或任何类似类型。你可能应该说
imread
is giving you an array whose elements are integers (of typeuint8
, I think). You're then trying to combine those with complex numbers, and that doesn't work. In particular, MATLAB will not automatically turn them intodouble
s orfloat
s or anything of the kind.You should probably just say
imread
函数返回灰度 bmp 图像的uint8
元素矩阵。许多 MatLab 函数和运算仅适用于double
元素。使用im2double
将图像转换为双精度矩阵。The
imread
function returns a matrix ofuint8
elements for grayscale bmp images. Many MatLab functions and operations work ondouble
elements only. Convert your image to a double matrix withim2double
.