Skip to content
Snippets Groups Projects
Select Git revision
  • f85337776b1cc9bc25697437d4230e3a9f1d232a
  • master default protected
2 results

structure-tensor

  • Open with
  • Download source code
  • Your workspaces

      A workspace is a virtual sandbox environment for your code in GitLab.

      No agents available to create workspaces. Please consult Workspaces documentation for troubleshooting.

  • patmjen's avatar
    patmjen authored
    f8533777
    History
    Name Last commit Last update
    structuretensor
    README.md

    Structure Tensor

    Simple MATLAB package for computing structure tensors for 3D images. Uses GPU block processing for high performance.

    Installation

    Simply copy the structuretensor directory to you project.

    Then call addpath structuretensor in MATLAB.

    Examples

    Simple example: just get the eigenvalues and eigenvectors.

    addpath structuretensor
    
    % Make simple volume with one rod aligned with the Y-axis.
    vol = zeros(128, 128, 128);
    vol(60:70, :, 60:70) = 1;
    
    % Set structure tensor parameters.
    sigma = 2;
    rho = 4;
    
    % Compute structure tensor eigenvalues and eigenvectors.
    % By default, the function uses the GPU if one is available.
    % See also help StructureTensorEig3 for more info.
    [E, X, Y, Z] = StructureTensorEig3(vol, sigma, rho,...
    	 'BlockSize', 64,... % Use 64x64x64 blocks. Can also give block as [W,H,D].
    	 'Verbose', true);   % Print a loadbar to show progress.
    
    % Show smallest eigenvector in the middle of the volume.
    % Notice it is aligned with the Y-axis.
    disp([X{1}(65,65,65), Y{1}(65,65,65), Z{1}(65,65,65)]);

    Only compute the smallest eigenvector. This saves a lot of time and memory. Since the smallest eigenvector gives the local orientation it is usually the only one we care about.

    addpath structuretensor
    
    % Make simple volume with one rod aligned with the Y-axis.
    vol = zeros(128, 128, 128);
    vol(60:70, :, 60:70) = 1;
    
    % Set structure tensor parameters.
    sigma = 2;
    rho = 4;
    
    % Compute structure tensor eigenvalues and eigenvectors.
    % By default, the function uses the GPU if one is available.
    % See also help StructureTensorEig3 for more info.
    [E, X, Y, Z] = StructureTensorEig3(vol, sigma, rho,...
    	 'BlockSize', 64,... % Use 64x64x64 blocks.  Can also give block as [W,H,D].
    	 'Verbose', true,... % Print a loadbar to show progress.
    	 'NumEigVecs', 1);   % Only return 1 eigenvector (the smallest).
    
    % Show smallest eigenvector in the middle of the volume.
    % Notice it is aligned with the Y-axis.
    disp([X{1}(65,65,65), Y{1}(65,65,65), Z{1}(65,65,65)]);

    Compute both the structure tensor components and eigenvectors/values.

    addpath structuretensor
    
    % Make simple volume with one rod aligned with the Y-axis.
    vol = zeros(128, 128, 128);
    vol(60:70, :, 60:70) = 1;
    
    % Set structure tensor parameters.
    sigma = 2;
    rho = 4;
    
    % Compute structure tensor components.
    % By default, the function uses the GPU if one is available.
    % See also help StructureTensor3 for more info.
    [T11, T22, T33, T12, T13, T23] = StructureTensor3(vol, sigma, rho,...
    	'BlockSize', 64,... % Use 64x64x64 blocks. Can also give block as [W,H,D].
    	'Verbose', true);   % Print a loadbar to show progress.
    
    % Compute structure tensor eigenvalues and eigenvectors.
    % By default, the function uses the GPU if one is available.
    % See also help EigRealSymm3 for more info.
    [E, X, Y, Z] = EigRealSymm3(T11, T22, T33, T12, T13, T23,...
    	 'BlockSize', 64,... % Use 64x64x64 blocks. Can also give block as [W,H,D].
    	 'Verbose', true); % Print a loadbar to show progress.
    
    % Show smallest eigenvector in the middle of the volume.
    % Notice it is aligned with the Y-axis.
    disp([X{1}(65,65,65), Y{1}(65,65,65), Z{1}(65,65,65)]);