how can I calculate the LBP code for every pixel of 10*10 matrix except pixels in border and save the result in a new 10*10 matrix,the following codes are just for one pixel

6 visualizzazioni (ultimi 30 giorni)
% This example computes the LBP transformation of the pixel (2,2) input image A
clear all;
close all;
clc;
A = [ 5 4 3; 4 3 1; 2 0 3]; %build a an 3X3 image with center pixel 3
[N M]=size(A); % N=number of rows, M=number of columns
T=A(N-1,M-1); %Threshold value T is the gray level of middle element in 3X3
for i=1:N;
for j=1:M
B(i,j)=A(i,j)>= T;% B=1 if B>=A, otherwise B=0
end
end
n=[0 1 2;7 -inf 3;6 5 4] % -inf : minus infinity 2^(-inf)=0
w = 2.^n %Define weight matrix as 2^n, n= 0,1,2,...,7
B
C=w.*B %times Element-wise multiplication
LBPdec=sum(sum(C)),% LBP code in decimal
LBPbin=de2bi(LBPdec,'left-msb'), % LBP code in binary

Risposta accettata

Walter Roberson
Walter Roberson il 12 Ott 2015

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by