How to get xy coordinates from a binary image matrix
Show older comments
How do I get the xy coordinates of all the 1's in a binary matrix?
Accepted Answer
More Answers (1)
Juan Alberto Antonio Velazquez
on 3 May 2018
0 votes
if you want to find the center of mass of a binary image
%Codigo que sirve para encontrar el centro de masa de una objeto en una %imagen clc; clear all; close all; dir='/Users/jalberto/Documents/PROYECTO DETECCION DE PERSONAS/ACTIVESHAPEMODEL/ASMNEW/ModeloFondo/Testing/fotomov1/sinfondo138'; I = imread([dir,'.png']); Im=im2bw(I); %figure, imshow(Im); [y,x]=find(Im==1); xy=[x,y]; media=mean(xy); figure, imshow(Im); hold on plot(media(:,1),media(:,2),'*b');
by Juan Alberto Antonio Velazquez from Toluca, México
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!