필터 지우기
필터 지우기

Can anybody help me to explain the logic behind bwdist matlab function. thanks

조회 수: 6 (최근 30일)
Muhammad Sohail
Muhammad Sohail 2015년 11월 5일
댓글: Guillaume 2015년 11월 5일
Please guide me if someone have the knowledge that how bwdist function work.

답변 (1개)

Thorsten
Thorsten 2015년 11월 5일
B is a binary image, i.e., an image that contains only 0's and 1's. For every pixel in B, bwdist computes the distance to the nearest 1. So if the pixel is 1, the distance is 0. For a pixel 0 that is e.g., left to a pixel of 1, the distance is 1. And so one. By default, the Euclidean distance is computed, but you can use other distance measures.
X = zeros(10)
X(16) = 1
X(44) = 1
bwdist(X)
  댓글 수: 2
Muhammad Sohail
Muhammad Sohail 2015년 11월 5일
Thanks Thorsten for the reply, but actually i am looking for how bwdist measure the distance transform.What are the steps to calculate the distance transform in our own code without using bwdist, for example if use city block distance measure.
Guillaume
Guillaume 2015년 11월 5일
Well, as Thorsten says you go through each pixel (with a for loop for example), find the nearest 1 (you could do that with another for loop, expanding outward from your pixel) and calculate the distance between the two. That would be one (slow!) way of doing it.
Another way of doing it would be to dilate the image by 1 pixel orthogonally each step. At each step, the new pixels reached by the dilation are assigned a distance of 1 + previous step distance. That would only require one loop

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by