matlab - Distance between connected components -


i wanted know if there inbuilt function distance between different connected components in matlab. using bwlabel various connected components.is there way distance between these connected components?

i guess use regionprops locate centroid of each connected component , apply pdist find pairwise distance between each of them.

simple example:

clear clc close  %// create logical array bw = logical ([1     1     1     0     0     0     0     0                1     1     1     0     1     1     0     0                1     1     1     0     1     1     0     0                1     1     1     0     0     0     1     0                1     1     1     0     0     0     1     0                1     1     1     0     0     0     1     0                1     1     1     0     0     1     1     0                1     1     1     0     0     0     0     0])  %/ call regionprops , concatenate centroid coordinates s = regionprops(bwlabel(bw,4),'centroid')  centroids = vertcat(s.centroid)  %// measure pairwise distance d = pdist(centroids,'euclidean') 

outputs in command window:

bw =       1     1     1     0     0     0     0     0      1     1     1     0     1     1     0     0      1     1     1     0     1     1     0     0      1     1     1     0     0     0     1     0      1     1     1     0     0     0     1     0      1     1     1     0     0     0     1     0      1     1     1     0     0     1     1     0      1     1     1     0     0     0     0     0   s =   3x1 struct array fields:      centroid   centroids =      2.0000    4.5000     5.5000    2.5000     6.8000    5.8000   d =      4.0311    4.9729    3.5468 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -