Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab image processing error

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?

like image 232
Brahadeesh Avatar asked Jun 27 '26 17:06

Brahadeesh


1 Answers

imread is giving you an array whose elements are integers (of type uint8, 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 into doubles or floats or anything of the kind.

You should probably just say

a=double(imread('lena128','bmp'));
like image 93
Gareth McCaughan Avatar answered Jun 29 '26 07:06

Gareth McCaughan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!