フィルターのクリア

How to get coordinates of shapes in image?

7 ビュー (過去 30 日間)
Fabian Lisowski
Fabian Lisowski 2020 年 11 月 30 日
回答済み: Shubham Rawat 2020 年 12 月 4 日
Hello,
I have an image with three different shapes on it and need to get the coordinates of the middle of each shape. I would be grateful for help in solving the problem.
Thanks a lot!
The Image is in the attachment
  3 件のコメント
Image Analyst
Image Analyst 2020 年 11 月 30 日
Each shape has lots of coordinates. Do you want them all? If so, why? Or do you just want the centroids?
Check out the Color Thresholder on the Apps tab of the tool ribbon.
Check out my Image Segmentation Tutorial and color segmentation tutorials in my File Exchange:
Fabian Lisowski
Fabian Lisowski 2020 年 11 月 30 日
I want the coordinates of the center of each shape. The image has a 640x480 resolution. I need the coordinates to control the moves of a 3d crane. The image will be came from a VGA camera on the top of the crane.

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

回答 (1 件)

Shubham Rawat
Shubham Rawat 2020 年 12 月 4 日
Hi Fabian,
You may use regionprops function to calculate the centroid of each shape. Here is the link to the documentation:
For this particular figure i have created a demo code. You may also look into that and take some help:
a = imread('punkty.jpg'); %reading image
I = rgb2gray(a); %change image into grayscale
bw = I < 100; %change image into Black and White
stats = regionprops(bw,'Centroid'); %resulting Centroid of each image
%to show the image with centroids
imshow(bw)
hold on
plot(centers(:,1),centers(:,2),'b*')
hold off
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by