Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensor-voting is slow #3

Open
jewettaij opened this issue Mar 20, 2019 · 3 comments
Open

tensor-voting is slow #3

jewettaij opened this issue Mar 20, 2019 · 3 comments

Comments

@jewettaij
Copy link
Owner

jewettaij commented Mar 20, 2019

Tensor-voting is slower than the implementation from Martinez-Sanchez, J.Struct.Biol. (‎2014).
This is for two reasons:

  1. I am using true 3D tensor voting. (Martinez-Sanchez et al. are applying 2D tensor voting to each XY slice.) Using 3D tensor voting presumably will improve the signal to noise ratio, although I have not tried comparing with the 2D version. 3D tensor voting also enables more accurate calculation of the surface normal directions. (These normal directions are very useful later on for clustering and surface reconstruction.)
  2. I am not using the fast "steerable filters" optimization. Steerable filters are a bit messier to implement in 3D compared to 2D. However, I was at least careful to choose an equation for tensor-voting which should be compatible with steerable filters. This hopefully means that the behavior of the program should not change should we choose to implement this speed optimization later on.

Using GPUs (once I get OpenAcc working) should also help.
I don't have plans to address this issue in the immediate future.

Andrew

@jewettaij
Copy link
Owner Author

jewettaij commented Jun 19, 2021

I just added a feature ("-save-progress") which should partially alleviate this problem. The process of stitching together a closed membrane surface (or a continuous filamentous curve) typically involves many iterations of trial and error, using different thresholds and constraints until the resulting surface (or curve) is reasonable.

In the past, the "filter_mrc" program required the user to repeat the tensor voting process each time. But today, I implemented the "-save-progress" and "-load-progress" arguments for "filter_mrc". Using these arguments allows the user to skip over the time consuming process of tensor-voting each time. The tensor voting process remains unforgivably slow, however the user only has to endure it once.

@jewettaij
Copy link
Owner Author

jewettaij commented Jun 20, 2021

Today, I added the ability to reduce image size and resolution using the "-bin" argument to "filter_mrc". (This feature is implemented in the "resample.hpp" file in the VISFD library.) Together with "-save-progress", this will make a dramatic difference in the computation time needed to perform some operations (like tensor voting and blob detection) where single-voxel resolution is not always necessary. The user does not have to create a new image file for the reduced-size image.. Just add the "-bin N" argument to the existing argument list to "filter_mrc" (where "N" is the width of each bin, in voxels). I have updated the examples (and the tutorial) to take advantage of this feature.

Note that to the user, this change will have no effect. The voxel width will also be automatically scaled so that the thickness parameter used in surface detection does not need to be altered. And when generating surface mesh files (PLY files for use with 3rd-party programs), the location of points on the detected surface will be scaled up accordingly to compensate for the reduction in resolution that results from binning.

Update: As of 2021-8-11, binning happens automatically whenever the "sigma" parameter for tensor-voting exceeds (roughly) 4.3 times 3.5 times the voxel-width. Users can override this by specifying the amount of binning using the "-bin N" argument.

@jewettaij
Copy link
Owner Author

jewettaij commented Jul 17, 2021

Users should now be able to use membrane detection ("-menbrane") with tensor-voting ("-tv") without worrying about the resolution of their images.

As of v0.29.3, binning happens automatically whenever the surface or curve target width is more than about 4-5 voxels wide. This was done in an attempt to reduce the computational time, hopefully without sacrificing detection capability. (Users can override automatic binning by specifying the "-bin" argument.) This means that the computation time should never become too horrifically slow (depending on your definition of "horrific").

benchmarks

Initial tests on small tomograms suggest that it should be possible to run tensor-voting (ie. "-tv 4") to detect all membranes in a 1000x1000x600 image in about 1-4 hours (on a cheap laptop 2-core CPU with hyperthreading). Due to automatic resolution-binning, this statement is (hopefully) true is regardless of the target membrane thickness or original image resolution. (Of course, if the user crops the image, uses aggressive binning, or uses an image mask to exclude some of the voxels, the computation can be much faster than this. Incidentally, the user can now use the "-mask-rect", "-mask-sphere", "-mask-rect-subtract", and "-mask-sphere-subtract" arguments to specify simple or complex mask regions relatively easily, as well as the "-mask FILE.rec" argument.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant