威望0
积分7946
贡献0
在线时间763 小时
UID1
注册时间2021-4-14
最后登录2024-11-21
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7946
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-21
- 在线时间
- 763 小时
|
[mw_shl_code=applescript,true]
function [ Vout ] = CalcImgLBPFeature( Iin )
% Calc image Local Binary Pattern( LBP ) feature
%
% < Input arguments >
% 'Iin' - input image( 'uint8' | 'uint16' | 'double' format )
%
% < Output arguments >
% 'Vout' - feature vector
% init return value ...
Vout = [];
% gray color image ...
if ( ndims( Iin ) == 3 )
Ig = ( 0.3 .* Iin( :, :, 1 ) + 0.59 .* Iin( :, :, 2 ) + 0.11 .* Iin( :, :, 3 ) );
else
Ig = Iin;
end;
% '3 x 3' neigbourhood 'sliding' operation ...
M = colfilt( Ig, [ 3 3 ], 'sliding', @CalcTextureUnit );
% create histogram ...
[ Vout ] = CalcHistogram( M, 256 );
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sub Function %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ Lt ] = CalcTextureUnit( Mt )
% Compute the texture unit for ONE pixel ...
%
% < Input arguments >
% 'Mt' - neigbourhood block value
%
% < Output arguments >
% 'Lt' - neigbourhood 'sliding' operation result value
% '3 x 3' template value(s) ...
Ve = [ 1 8 32 2 0 64 4 16 128 ];
% compute the threshold value, which is the mean value ...
Lt = mean( Mt, 1 );
% duplicate ...
Mc = repmat( Lt, size( Mt, 1 ), 1 );
% compute by threshold value ...
K = ( Mt > Mc );
% return result ...
Lt = Ve * K;
[/mw_shl_code] |
|