Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to store each ans which we get from loop in a 2-d array ?

1 回表示 (過去 30 日間)
Nupur Goyal
Nupur Goyal 2019 年 7 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
[rows, colm]=size(Thin_image);
% Avoid the boundary pixels
bifurcation=0;
ridge=0;
for i=2:rows-1
for j=2:colm-1
sub_matrix=(Thin_image(i-1:i+1,j-1:j+1));
if sub_matrix(2,2)==1
sub_matrix=sum(sub_matrix(:))-1;
if sub_matrix==1
P=fprintf('it is a ridge termination');
i
j
ridge=ridge+1;
else if sub_matrix==3
Q=fprintf('it is a bifurcation');
i
j
bifurcation=bifurcation+1;
end
end
end
end
end
i have this code i want to plot each value.

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2019 年 7 月 9 日
編集済み: Andrei Bobrov 2019 年 7 月 9 日
Thin_image = single(rand(7) > .8); % for example
out = conv2(Thin_image,ones(3),'valid');
ridge = sum(out(:) == 1);
bifurcation = sum(out(:) == 3);

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by