Calculating the distance between patches

4 ビュー (過去 30 日間)
med-sweng
med-sweng 2013 年 11 月 29 日
コメント済み: Image Analyst 2013 年 11 月 29 日
Is there a way in MATLAB to calculate the distance between patches of two images?
Thanks.
  2 件のコメント
Image Analyst
Image Analyst 2013 年 11 月 29 日
Which distance? The Hausdrof distance, distance between closest vertices, or distance between centroids?
med-sweng
med-sweng 2013 年 11 月 29 日
@Image Analyst. Thanks for your reply. Say that we have patches of size `3x3`, how would the "Hausdorff distance" or the "Euclidean distance" be applied on that? That is, patches instead of pixel points?

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

回答 (1 件)

Image Analyst
Image Analyst 2013 年 11 月 29 日
If you know the vertices, you can calculate centroid and the Hausdorf distance from formulas you can find on the web. For a 3x3 rectangular array, the centroid is obviously at the middle element. For arbitrary polygons, it seems not so straightforward: https://en.wikipedia.org/wiki/Centroid#Locating_the_centroid but you can use regionprops() to compute the centroid, if you want to create an image out of the vertices with poly2mask().
  2 件のコメント
med-sweng
med-sweng 2013 年 11 月 29 日
@Image Analyst. Say I use `pdist` to find the distance, how can I combine the `centroid` (patches) with that?
Image Analyst
Image Analyst 2013 年 11 月 29 日
I don't have pdist(). See my image segmentation tutorial for how you can get centroids: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Once you have the centroid, you can plug into norm(), hypot(), or pdist(), or the Pythagorean theorem to get the Euclidean distance.

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

Community Treasure Hunt

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

Start Hunting!

Translated by