php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 610|回复: 0

计算图像的局部二值模式特征LBP

[复制链接]

3138

主题

3148

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
7946
贡献
0
注册时间
2021-4-14
最后登录
2024-11-21
在线时间
762 小时
QQ
发表于 2022-5-14 12:43:53 | 显示全部楼层 |阅读模式
[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]

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )

GMT+8, 2024-11-21 18:10 , Processed in 0.304771 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表