orzzzjq / Parallel-Banding-Algorithm-plus

Compute the exact Euclidean Distance Transform and Voronoi Diagram for 2D and 3D binary images using the GPU.
https://www.comp.nus.edu.sg/~tants/pba.html
MIT License
73 stars 8 forks source link

Can I compute the rectangle image not the square image? #5

Closed G-YY closed 3 years ago

G-YY commented 3 years ago

I try to test the 1280*1024 image ,but the result is not correct,Thank you

orzzzjq commented 3 years ago

Cannot compute a rectangle image directly due to efficient consideration. But you can simply put the rectangle image into a large square image. Or maybe you can try to modify the transpose operation in the code, to let it work for rectangle images, but it's a little difficult.

y123l commented 4 months ago

The new version of the code without transpose operation seems to handle the rectangle image wrong as well, do you have any suggestions

orzzzjq commented 4 months ago

You are right, I didn't implement a version that handles rectangle images. The new version performs an implicit transpose of the image. However, the code can be modified to support rectangle inputs.

The current method divides the image into small squares and does some computation within the small squares, then writes the result to the transposed position of the square. If we divide a rectangle image into small pieces of squares and do the implicit transpose for the rectangle image correspondingly, then we can support rectangle images as well.

Unfortunately, currently I don't have time to implement it. Someone achieved this using the above method, even for 3D PBA, but they may not be willing to share due to commercial considerations.

You may try to do so if you really want to handle rectangle images. It would be much easier for 2D PBA. Otherwise, for now, you may simply put the image into a large square and pass it to PBA. It won't be too slow if the rectangle image is well-shaped (close to a square).

y123l commented 4 months ago

Thank you for your detailed explanation. I will consider trying to adapt the method for rectangular inputs myself.