seung-lab / euclidean-distance-transform-3d

Euclidean distance & signed distance transform for multi-label 3D anisotropic images using marching parabolas.
GNU General Public License v3.0
234 stars 37 forks source link

Strange repeating patterns #49

Closed yinan-wan0 closed 10 months ago

yinan-wan0 commented 10 months ago

Thanks for this useful package!

I was trying to run dt on the following 3D labeled image using the code edt.edt(image, black_border=False, order='F', parallel=4) and it returned very strange repeating patterns: result

Here is my input image: problem_image.zip

I was wondering if this is a bug?

william-silversmith commented 10 months ago

Hi! The first thing that occurs to me is that the image may be read from the TIFF into the numpy array in the wrong order. I would like to eliminate the "order" parameter from edt, that was an early design mistake I made when I first became familiar with this issue.

Give that a try and if it doesn't work, I'll try experimenting with it.

yinan-wan0 commented 10 months ago

Thanks that solved the problem!

I generated the image myself and know that the numpy array has its three dimensions being Z,X,Y. Order 'F' used to work for me but somehow in this new version I have the numpy array stored in c contiguous order.

william-silversmith commented 10 months ago

Great! Sorry about this. When I was first learning about C vs F order, I had this weird idea that sometimes people might want to reinterpret their data as transposed, but that can be accomplished with the numpy .T operator. It almost never happens that this is something people want, they just want the function to automatically figure out what the underlying ordering is and respect it.