How to resolve "Index Exceeds Matrix Dimensions" error?
Mostrar comentarios más antiguos
Hello! I tried to create a low-pass filter to mask for an image regarding to filtering of an image in frequency domain.
After I have compute my code, it return with a "Index Exceeds Matrix Dimensions" error.
warning off
a = imread('valley.jpg');
b = im2double(a);
[m,n] = size(b);
c = zeros(2*m,2*n);
[p,q] = size(c);
for i=1:p
for j=1:q
if i<=m && j<=n
c(i,j)= b(i,j);
else
c(i,j) = 0;
end
end
end
imshow(b); title('Original Image');
figure
imshow(c); title('Padded Image');
d = zeros(p,q);
for i=1:p
for j=1:q
d(i,j) = c(i,j).*(-1).^(i+j);
end
end
figure
imshow(d); title('Pre Processed Image for Calculating DFT');
e = fft2(d);
figure
imshow(e); title('2D DFT of the Pre Process Image');
[x,y] = freqspace(p,'meshgrid');
z = zeros(p,q);
for i=1:p
for j=1:q
z(i,j) = sqrt((x(i,j).^2)+(y(i,j).^2));
end
end
H = zeros(p,q);
for i=1:p
for j=1:q
if z(i,j)<=0.4
H(i,j)=1;
else
H(i,j)=0;
end
end
end
figure
imshow(H);title('Low Pass Filter Mask');
Index exceeds matrix dimensions.
Error in freqD(line 39)
z(i,j) = sqrt((x(i,j).^2)+(y(i,j).^2));
It would be kind of you guys to guide me for possible solution.
Thank you!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Display Image en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!