insertshape auto find the coordinate of the object

1 回表示 (過去 30 日間)
MUHAMMAD NAZMI ZAINAL AZALI
MUHAMMAD NAZMI ZAINAL AZALI 2019 年 11 月 10 日
コメント済み: Image Analyst 2019 年 11 月 10 日
Hi, may i know how to insertshape auto find the coordinate of the object that in black pixel in the image?
Capture.JPG

採用された回答

Walter Roberson
Walter Roberson 2019 年 11 月 10 日
編集済み: Walter Roberson 2019 年 11 月 10 日
info = regionprops(~TheImage, 'Centroid');
coords = vertcat(info.Centroid);
x_coords = coords(:,1);
y_coords = coords(:,2);
but remember that x corresponds to columns and y corresponds to rows.
  2 件のコメント
MUHAMMAD NAZMI ZAINAL AZALI
MUHAMMAD NAZMI ZAINAL AZALI 2019 年 11 月 10 日
This is my coding, so this part will put at where?
clear all
% read original image
a = imread('pcb2.jpg');
imshow(a)
% read test image
b = imread('pcb2_openckt.jpg');
imshow(b)
% subtraction
c = imabsdiff(a,b)
imshow(c)
d = imcomplement(c)
imshow(d)
% to find the coordinate of the object from d
f = insertShape(a,'circle',[33 20, 20],'LineWidth',5);
subplot(3,3,1), imshow(a), title('Original')
subplot(3,3,2), imshow(b), title('Test')
subplot(3,3,3), imshow(c), title('Difference')
subplot(3,3,4), imshow(d), title('Inverted Difference')
subplot(3,3,5), imshow(f), title('Labeled')
Image Analyst
Image Analyst 2019 年 11 月 10 日
isertShape does not "find" regions in an image. Finding regions is what regionprops() does.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTracking and Motion Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by