Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Danielsson Function [closed]

I am implementing an image segmentation algorithm, at some point I need to implement a function named "Danielsson Function" which 'transforms a binary image into a grayscale distance map in which each particle pixel is assigned a gray-level value equal to its shortest Euclidean distance from the particle border'.
I'm not an expert in image processing and the only way I can imagine is using a BFS algorithm for every pixel but that would take ages.
I couldn't find much in web, so I want to know is there any optimized way to implement this or is there any Matlab/Octave function that can do such thing?


1 Answers

you can simply do that by using the "bwdist" matlab function, as the comments mentioned
and here is the link for help if you needed any : Distance transform of binary image - MATLAB bwdist
And here is the code :

I=uint8(bwdist(some_binary_image))

Be sure to use the 'uint8' because 'bwdist' only gives you the distance matrix which has double number values.

like image 159
Daniel.V Avatar answered May 20 '26 20:05

Daniel.V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!