www.gusucode.com > vision 源码程序 matlab案例代码 > vision/VisualizeLBPFeatureHistogramsExample.m

    %% Apply L1 Normalization to LBP Features
%
%%
% Read in a sample image and convert it to grayscale.

% Copyright 2015 The MathWorks, Inc.

I = imread('gantrycrane.png');
I = rgb2gray(I);
%%
% Extract unnormalized LBP features so that you can apply a custom normalization. 
lbpFeatures = extractLBPFeatures(I,'CellSize',[32 32],'Normalization','None'); 
%%
% Reshape the LBP features into a _number of neighbors_ -by- _number of cells_ array to access histograms for each individual cell.
numNeighbors = 8;
numBins = numNeighbors*(numNeighbors-1)+3;
lbpCellHists = reshape(lbpFeatures,numBins,[]); 
%%
% Normalize each LBP cell histogram using L1 norm.
lbpCellHists = bsxfun(@rdivide,lbpCellHists,sum(lbpCellHists)); 
%%
% Reshape the LBP features vector back to 1-by- _N_ feature vector.
lbpFeatures = reshape(lbpCellHists,1,[]);