How to remove frame boundary from object boundary
1 回表示 (過去 30 日間)
古いコメントを表示
How can I remove the false object boundaries detected at the frame edges ? I only need the curve part to be my boundary.
Here is my code:
clc; clear; close all;
OM = imread('002.jpg');
imshow(OM)
W = rgb2gray(OM);
imshow(W)
binaryImage=imbinarize(W);
hold on
imshow(binaryImage);
BW = bwareafilt(binaryImage,1);
[B,L,N] = bwboundaries(BW,'noholes');
imshow(BW); hold on;
for k=1:length(B),
boundary = B{k};
if(k > N)
plot(boundary(:,2), boundary(:,1), 'g','LineWidth',2);
else
plot(boundary(:,2), boundary(:,1), 'r','LineWidth',2);
end
end
2 件のコメント
回答 (1 件)
KSSV
2018 年 6 月 5 日
If (x,y) are your boundary points......something like below should work:
[m,n] = size(I) ;
%
x(x==1) = [] ;y(x==1)= [] ;
x(x==m) = [] ;y(x==m) = [] ;
x(y==n) = [] ;y(y==n) = [] ;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Mathematics and Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!