I have a problem in converting the binary to decimal (it seems very lengthy).
%% Read
clear all;
close all;
clc;
I=imread('test.png');
imshow(I);
%% Crop
I2 = imcrop(I);
figure, imshow(I2)
w=size(I2,1);
h=size(I2,2);
%% LBP
for i=2:w-1
for j=2:h-1
J0=I2(i,j);
I3(i-1,j-1)=I2(i-1,j-1)>J0;
I3(i-1,j)=I2(i-1,j)>J0;
I3(i-1,j+1)=I2(i-1,j+1)>J0;
I3(i,j+1)=I2(i,j+1)>J0;
I3(i+1,j+1)=I2(i+1,j+1)>J0;
I3(i+1,j)=I2(i+1,j)>J0;
I3(i+1,j-1)=I2(i+1,j-1)>J0;
I3(i,j-1)=I2(i,j-1)>J0;
LBP(i,j)=I3(i-1,j-1)*2^8+I3(i-1,j)*2^7+I3(i-1,j+1)*2^6+I3(i,j+1)*2^5+I3(i+1,j+1)*2^4+I3(i+1,j)*2^3+I3(i+1,j-1)*2^2+I3(i,j-1)*2^1;
end
end
figure,imshow(I3)
figure,imhist(LBP)
Is it possible to change this line
LBP(i,j)=I3(i-1,j-1)*2^8+I3(i-1,j)*2^7+I3(i-1,j+1)*2^6+I3(i,j+1)*2^5+I3(i+1,j+1)*2^4+I3(i+1,j)*2^3+I3(i+1,j-1)*2^2+I3(i,j-1)*2^1;
to something shorter?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…