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
|
clear all; close all; clc;
A=imread('originale.jpg');
B=rgb2gray(A);
% Radius R is the input parameter of the function.
R =1;
%%%%%%%%%%%%%%%%%%
L = 2*R + 1; %% The size of the LBP label
C = round(L/2);
Input_Im = uint8(B);
row_max = size(Input_Im,1)-L+1;
col_max = size(Input_Im,2)-L+1;
LBP_Im = zeros(row_max, col_max);
for i = 1:row_max
for j = 1:col_max
A = Input_Im(i:i+L-1, j:j+L-1);
A = A+1-A(C,C);
A(A>0) = 1;
OC_LBP1_Im(i,j) = A(C,L)*2^0 + A(L,C)*2^1 + A(C,1)*2^2 + A(1,C)*2^3 ;
OC_LBP2_Im(i,j) = A(L,L)*2^0 + A(L,1)*2^1 + A(1,1)*2^2 + A(1,L)*2^3;
OC_LBP_Im(i,j) =[OC_LBP1_Im(i,j) OC_LBP2_Im(i,j)];
end;
end; |
Partager