# Changing the radius of the LTP feature extractor in this code

1 view (last 30 days)
Faraz on 11 May 2017
Hi,
Ive downloaded the following code for extracting the LTP of an image for classification. The code extracts the LTP code in a circle of radius 2.
% Local ternary patterns
function [high,low,ternary]=ltp_image(in,type,threshold)
[rows,cols]=size(in);
% case 'P8R2' % 8 pixels in a circle of radius 2
% embed input matrix in a larger one, extending with zeros (trim a
% 2 pixel border off of the output matrices if you don't like this)
r=rows+4;
c=cols+4;
A = zeros(r,c);
r0=3:r-2;
c0=3:c-2;
A(r0,c0) = in;
% radius 2 interpolation coefficients for +-45 degree lines
alpha = 2-sqrt(2);
beta = 1-alpha;
% 8 directional derivative images
d0 = A(r0,c0-2) - in;
d2 = A(r0+2,c0) - in;
d4 = A(r0,c0+2) - in;
d6 = A(r0-2,c0) - in;
d1 = alpha*A(r0+1,c0-1) + beta*A(r0+2,c0-2) - in;
d3 = alpha*A(r0+1,c0+1) + beta*A(r0+2,c0+2) - in;
d5 = alpha*A(r0-1,c0+1) + beta*A(r0-2,c0+2) - in;
d7 = alpha*A(r0-1,c0-1) + beta*A(r0-2,c0-2) - in;
% pack derivative images into a single matrix, one per column,
% threshold and code to get output matrices
d = [d0(:),d1(:),d2(:),d3(:),d4(:),d5(:),d6(:),d7(:)];
code = 2.^(7:-1:0)';
high = reshape((d>=threshold)*code,rows,cols);
low = reshape((d<=-threshold)*code,rows,cols);
if nargout>2
code = 3.^(7:-1:0)';
ternary = reshape((d>=threshold)*code+(d<=-threshold)*2*code,rows,cols);
end
%end;
The function tales the input "type", which is unused as it is commented out.
I need to change the radius to 3,6,9 etc. and I cannot find the unedited code of this online. How would I change the radius in this code?
Thank you
Maitreyee Mordekar on 19 May 2017
Hi Faraz,
Could you tell me where did you download this code from? I think the author of this code, will be in a better position to help you.