Skip to content
Snippets Groups Projects
Commit f8533777 authored by patmjen's avatar patmjen
Browse files

Add README

parent 90fad429
No related branches found
No related tags found
No related merge requests found
# 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.
```matlab
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.
```matlab
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**.
```matlab
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)]);
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment