forked from sf-Liu/LBP_3D-Operator-Descriptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LBP_3D_diagonal.m
33 lines (29 loc) · 1014 Bytes
/
LBP_3D_diagonal.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [ res ] = LBP_3D_diagonal( vol, bg_threshold )
%% Apr.28.2019
% SF Liu
% This code is an LBP (diagonal) algorithm in 3D.
% vol: the unprocessed MRI image
% Return the matrix as the same size as the vol, which is the texture feature
% of each voxel.The value is between -1 and 2^8. The -1 means the value
% of the voxel is less than the bg_threshold. The real value is between 1
% and 2^8.
%%
[height,width,depth]=size(vol);
LBP_map=zeros(height,width,depth)-1;
for p = 2:height-1
for q = 2:width-1
for r = 2:depth-1
if vol(p,q,r)<=bg_threshold
continue;
end
temp=0;
neighbor = [vol(p-1,q-1,r-1) vol(p-1,q-1,r+1) vol(p-1,q+1,r-1) vol(p-1,q+1,r+1) vol(p+1,q-1,r-1) vol(p+1,q-1,r+1) vol(p+1,q+1,r-1) vol(p+1,q+1,r+1)] > vol(p,q,r);
for i = 1:8
temp = temp+neighbor(i)*2^(i-1);
end
LBP_map(p,q,r)=temp+1;
end
end
end
res=LBP_map;
end