资源简介
说明:一共有三个m文件,一个是lbp.m, 存放主要的lbp算法,一个是getmapping,用以做算法的辅助函数,一个是lbptest.m,存放着测试代码。这三个文件需要放到同一个文件夹,并在文件夹中添加相应的图片,具体的图片名字见lbptest.m的代码,运行lbptest.m可以查看结果。

代码片段和文件信息
% GETMAPPING returns a structure containing a mapping table for LBP codes.
% MAPPING = GETMAPPING(SAMPLESMAPPINGTYPE) returns a
% structure containing a mapping table for
% LBP codes in a neighbourhood of SAMPLES sampling
% points. Possible values for MAPPINGTYPE are
% ‘u2‘ for uniform LBP
% ‘ri‘ for rotation-invariant LBP
% ‘riu2‘ for uniform rotation-invariant LBP.
%
% Example:
% I=imread(‘rice.tif‘);
% MAPPING=getmapping(16‘riu2‘);
% LBPHIST=lbp(I216MAPPING‘hist‘);
% Now LBPHIST contains a rotation-invariant uniform LBP
% histogram in a (162) neighbourhood.
%
function mapping = getmapping(samplesmappingtype)
% Version 0.1.1
% Authors: Marko Heikkil?and Timo Ahonen
% Changelog
% 0.1.1 Changed output to be a structure
% Fixed a bug causing out of memory errors when generating rotation
% invariant mappings with high number of sampling points.
% Lauge Sorensen is acknowledged for spotting this problem.
table = 0:2^samples-1;
newMax = 0; %number of patterns in the resulting LBP code
index = 0;
if strcmp(mappingtype‘u2‘) %Uniform 2
newMax = samples*(samples-1) + 3;
for i = 0:2^samples-1
j = bitset(bitshift(i1samples)1bitget(isamples)); %rotate left
numt = sum(bitget(bitxor(ij)1:samples)); %number of 1->0 and
%0->1 transitions
%in binary string
%x is equal to the
%number of 1-bits in
%XOR(xRotate left(x))
if numt <= 2
table(i+1) = index;
index = index + 1;
else
table(i+1) = newMax - 1;
end
end
end
if strcmp(mappingtype‘ri‘) %Rotation invariant
tmpMap = zeros(2^samples1) - 1;
for i = 0:2^samples-1
rm = i;
r = i;
for j = 1:samples-1
r = bitset(bitshift(r1samples)1bitget(rsamples)); %rotate
%left
if r < rm
rm = r;
end
end
if tmpMap(rm+1) < 0
tmpMap(rm+1) = newMax;
newMax = newMax + 1;
end
table(i+1) = tmpMap(rm+1);
end
end
if strcmp(mappingtype‘riu2‘) %Uniform & Rotation invariant
newMax = samples + 2;
for i = 0:2^samples - 1
j = bitset(bitshift(i1samples)1bitget(isamples)); %rotate left
numt = sum(bitget(bitxor(ij)1:samples));
if numt <= 2
table(i+1) = sum(bitget(i1:samples));
else
table(i+1) = samples+1;
end
end
end
mapping.table=table;
mapping.samples=samples;
mapping.num=newMax;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2757 2018-04-17 03:37 新建文件夹\getmapping.m
文件 6068 2018-04-17 03:36 新建文件夹\lbp.m
文件 1657 2018-04-17 03:38 新建文件夹\lbptest.m
- 上一篇:直接扩频序列的simuli
nk仿真 - 下一篇:Comsol渗流模型上边界条件设置
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论