フィルターのクリア

Cant seem understand the error in code

2 ビュー (過去 30 日間)
Divya
Divya 2023 年 8 月 22 日
回答済み: Dyuman Joshi 2023 年 8 月 22 日
%%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

回答 (2 件)

Walter Roberson
Walter Roberson 2023 年 8 月 22 日
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 2023 年 8 月 22 日
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

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by