フィルターのクリア

Undefined function or variable

3 ビュー (過去 30 日間)
tsai kai shung
tsai kai shung 2017 年 10 月 26 日
コメント済み: tsai kai shung 2017 年 10 月 26 日
function y = ratioimg(u)
[L2,num2]=bwlabel(u,8); %連通區域標記
B2=zeros(size(u));
for i=1:num2
[r,c] = find(L2==i);
left(i)=min(c);
right(i)=max(c);
up(i)=min(r);
down(i)=max(r);
if ((down(i)-up(i))/(right(i)-left(i)))>0.8&((down(i)-up(i))/(right(i)-left(i)))<1
[x,y]=find(L2==i);
B2=B2+bwselect(u,y,x,8);%%%把滿足長寬比在0.8到2的區域留下
end
end
y = B2;
end
i use this function on simulink simulation but show the error :
Undefined function or variable 'left'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#35.120.124), line 6, column 5:
"left"
Launch diagnostic report.
how can i solve this problem!

採用された回答

Jan
Jan 2017 年 10 月 26 日
You do not use left as a vector and it is not replied as output also. Then omit the "(i)":
function y = ratioimg(u)
[L2,num2] = bwlabel(u,8); %連通區域標記
y = zeros(size(u)); % Better than creating B2 and copy it to y
for i=1:num2
[r,c] = find(L2==i);
left = min(c);
right = max(c);
up = min(r);
down = max(r);
d = (down-up) / (right-left);
if d > 0.8 & d < 1
% [x,y]=find(L2==i); % Done above already
y = y + bwselect(u, c, r, 8); %%%把滿足長寬比在0.8到2的區域留下
end
end
end
  1 件のコメント
tsai kai shung
tsai kai shung 2017 年 10 月 26 日
Thank you for your help

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColor Space Formatting and Conversions についてさらに検索

Community Treasure Hunt

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

Start Hunting!