insertshape auto find the coordinate of the object

1 visualizzazione (ultimi 30 giorni)
Hi, may i know how to insertshape auto find the coordinate of the object that in black pixel in the image?
Capture.JPG

Risposta accettata

Walter Roberson
Walter Roberson il 10 Nov 2019
Modificato: Walter Roberson il 10 Nov 2019
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 Commenti
MUHAMMAD NAZMI ZAINAL AZALI
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 il 10 Nov 2019
isertShape does not "find" regions in an image. Finding regions is what regionprops() does.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by