Borrar filtros
Borrar filtros

Cant seem understand the error in code

1 visualización (últimos 30 días)
Divya
Divya el 22 de Ag. de 2023
Respondida: Dyuman Joshi el 22 de Ag. de 2023
%%convolution
for i=1:size(I,1)-M %This line of code gives error as "At least one END is missing. The statement beginning here does not have a matching end."
for j=1:size(I,2)-N
Temp=I(i:i+M,j:j+M).*Kernel;% Multiply kernel with original image
Output(i,j)=sum(Temp(:));
end
Output=uint8(Output);
figure, imshow(Output);
Pl help

Respuestas (2)

Walter Roberson
Walter Roberson el 22 de Ag. de 2023
You have an end statement corresponding to for j but you do not have an end statement corresponding to for i
I suspect you want
%%convolution
for i=1:size(I,1)-M
for j=1:size(I,2)-N
Temp=I(i:i+M,j:j+M).*Kernel;% Multiply kernel with original image
Output(i,j)=sum(Temp(:));
end
end
Output=uint8(Output);
figure, imshow(Output);

Dyuman Joshi
Dyuman Joshi el 22 de Ag. de 2023
for loops need to be completed with "end". You initiated 2 for loops, but you only closed one.
for i=1:size(I,1)-M
for j=1:size(I,2)-N
% v
Temp=I(i:i+M,j:j+M).*Kernel;% Multiply kernel with original image
Output(i,j)=sum(Temp,'all');
end
%Missing end
end
There might be a typo in the index, as I have highlighted above, you might want to use -
j:j+N

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by