implement the distance transform algorithm by City-Block distance measurement

Hi Guys I have an assignment to implement the distance transform algorithm by City-Block distance measurement I tried a lot of solutions but it didn't work (That's the photo)

2 件のコメント

Abdelrahman Talaat
Abdelrahman Talaat 2022 年 4 月 2 日
cic?
killerabd
killerabd 2022 年 4 月 4 日
ah ya3m enta bt3ml eh hna

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

回答 (2 件)

Walter Roberson
Walter Roberson 2022 年 4 月 1 日
City block transform between rows of P1 and corresponding rows of P2 is
CB = @(P1, P2) sum(abs(double(P1)-double(P2)), 2)
Image Analyst
Image Analyst 2022 年 4 月 2 日
I don't know if you want the distances between the centroids of the blobs
props = regionprops(mask, 'Centroid');
xy = vertcat(props.Centroid);
or between all the white pixels in the image.
[y, x] = find(mask);
xy = [x(:), y(:)];
But you can use pdist2
distances = pdist2(xy, xy, 'CityBlock');

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2022 年 4 月 1 日

コメント済み:

2022 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by