理力灌篮高手影响力帮忙 谢谢了

查看: 2092|回复: 4|关注: 0
LBP算法提取图像纹理程序执行有错,请高手帮忙谢谢
LBP算法提取图像纹理程序执行有错,请高手帮忙谢谢
getmapping.m
%GETMAPPING returns a structure containing a mapping table for LBP codes.
%&&MAPPING = GETMAPPING(SAMPLES,MAPPINGTYPE) 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(I,2,16,MAPPING,'hist');
%&&Now LBPHIST contains a rotation-invariant uniform LBP
%&&histogram in a (16,2) neighbourhood.
function mapping = getmapping(samples,mappingtype)
% 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(i,1,samples),1,bitget(i,samples)); %rotate left
& & numt = sum(bitget(bitxor(i,j),1:samples)); %number of 1-&0 and
& && && && && && && && && && && && && && && &&&%0-&1 transitions
& && && && && && && && && && && && && && && &&&%in binary string
& && && && && && && && && && && && && && && &&&%x is equal to the
& && && && && && && && && && && && && && && &&&%number of 1-bits in
& && && && && && && && && && && && && && && &&&%XOR(x,Rotate left(x))
& & if numt &= 2
& && &table(i+1) =
& && &index = index + 1;
& && &table(i+1) = newMax - 1;
if strcmp(mappingtype,'ri') %Rotation invariant
&&tmpMap = zeros(2^samples,1) - 1;
&&for i = 0:2^samples-1
& & for j = 1:samples-1
& && &r = bitset(bitshift(r,1,samples),1,bitget(r,samples)); %rotate
& && && && && && && && && && && && && && && && && && && && & %left
& && &if r & rm
& && &&&rm =
& & if tmpMap(rm+1) & 0
& && &tmpMap(rm+1) = newM
& && &newMax = newMax + 1;
& & table(i+1) = tmpMap(rm+1);
if strcmp(mappingtype,'riu2') %Uniform & Rotation invariant
&&newMax = samples + 2;
&&for i = 0:2^samples - 1
& & j = bitset(bitshift(i,1,samples),1,bitget(i,samples)); %rotate left
& & numt = sum(bitget(bitxor(i,j),1:samples));
& & if numt &= 2
& && &table(i+1) = sum(bitget(i,1:samples));
& && &table(i+1) = samples+1;
mapping.table=
mapping.samples=
mapping.num=newM
%LBP returns the local binary pattern image or LBP histogram of an image.
%&&J = LBP(I,R,N,MAPPING,MODE) returns either a local binary pattern
%&&coded image or the local binary pattern histogram of an intensity
%&&image I. The LBP codes are computed using N sampling points on a
%&&circle of radius R and using mapping table defined by MAPPING.
%&&See the getmapping function for different mappings and use 0 for
%&&no mapping. Possible values for MODE are
%& && & 'h' or 'hist'&&to get a histogram of LBP codes
%& && & 'nh'& && && &&&to get a normalized histogram
%&&Otherwise an LBP code image is returned.
%&&J = LBP(I) returns the original (basic) LBP histogram of image I
%&&J = LBP(I,SP,MAPPING,MODE) computes the LBP codes using n sampling
%&&points defined in (n * 2) matrix SP. The sampling points should be
%&&defined around the origin (coordinates (0,0)).
%&&Examples
%&&--------
%& && & I=imread('rice.png');
%& && & mapping=getmapping(8,'u2');
%& && & H1=LBP(I,1,8,mapping,'h'); %LBP histogram in (8,1) neighborhood
%& && && && && && && && && && && & %using uniform patterns
%& && & subplot(2,1,1),stem(H1);
%& && & H2=LBP(I);
%& && & subplot(2,1,2),stem(H2);
%& && & SP=[-1 -1; -1 0; -1 1; 0 -1; -0 1; 1 -1; 1 0; 1 1];
%& && & I2=LBP(I,SP,0,'i'); %LBP code image using sampling points in SP
%& && && && && && && && && &%and no mapping. Now H2 is equal to histogram
%& && && && && && && && && &%of I2.
function result = lbp(varargin) % image,radius,neighbors,mapping,mode)
% Version 0.3.2
% Authors: Marko Heikkil?and Timo Ahonen
% Changelog
% Version 0.3.2: A bug fix to enable using mappings together with a
% predefined spoints array
% Version 0.3.1: Changed MAPPING input to be a struct containing the mapping
% table and the number of bins to make the function run faster with high number
% of sampling points. Lauge Sorensen is acknowledged for spotting this problem.
% Check number of input arguments.
error(nargchk(1,5,nargin));
image=varargin{1};
d_image=double(image);
if nargin==1
& & spoints=[-1 -1; -1 0; -1 1; 0 -1; -0 1; 1 -1; 1 0; 1 1];
& & neighbors=8;
& & mapping=0;
& & mode='h';
if (nargin == 2) && (length(varargin{2}) == 1)
& & error('Input arguments');
if (nargin & 2) && (length(varargin{2}) == 1)
& & radius=varargin{2};
& & neighbors=varargin{3};
& & spoints=zeros(neighbors,2);
& & % Angle step.
& & a = 2*pi/
& & for i = 1:neighbors
& && &&&spoints(i,1) = -radius*sin((i-1)*a);
& && &&&spoints(i,2) = radius*cos((i-1)*a);
& & if(nargin &= 4)
& && &&&mapping=varargin{4};
& && &&&if(isstruct(mapping) && mapping.samples ~= neighbors)
& && && && &error('Incompatible mapping');
& && &&&end
& && &&&mapping=0;
& & if(nargin &= 5)
& && &&&mode=varargin{5};
& && &&&mode='h';
if (nargin & 1) && (length(varargin{2}) & 1)
& & spoints=varargin{2};
& & neighbors=size(spoints,1);
& & if(nargin &= 3)
& && &&&mapping=varargin{3};
& && &&&if(isstruct(mapping) && mapping.samples ~= neighbors)
& && && && &error('Incompatible mapping');
& && &&&end
& && &&&mapping=0;
& & if(nargin &= 4)
& && &&&mode=varargin{4};
& && &&&mode='h';
% Determine the dimensions of the input image.
[ysize xsize] = size(image);
miny=min(spoints(:,1));
maxy=max(spoints(:,1));
minx=min(spoints(:,2));
maxx=max(spoints(:,2));
% Block size, each LBP code is computed within a block of size bsizey*bsizex
bsizey=ceil(max(maxy,0))-floor(min(miny,0))+1;
bsizex=ceil(max(maxx,0))-floor(min(minx,0))+1;
% Coordinates of origin (0,0) in the block
origy=1-floor(min(miny,0));
origx=1-floor(min(minx,0));
% Minimum allowed size for the input image depends
% on the radius of the used LBP operator.
if(xsize & bsizex || ysize & bsizey)
&&error('Too small input image. Should be at least (2*radius+1) x (2*radius+1)');
dx = xsize -
dy = ysize -
% Fill the center pixel matrix C.
C = image(origy:origy+dy,origx:origx+dx);
d_C = double(C);
% Initialize the result matrix with zeros.
result=zeros(dy+1,dx+1);
%Compute the LBP code image
for i = 1:neighbors
&&y = spoints(i,1)+
&&x = spoints(i,2)+
&&% Calculate floors, ceils and rounds for the x and y.
&&fy = floor(y); cy = ceil(y); ry = round(y);
&&fx = floor(x); cx = ceil(x); rx = round(x);
&&% Check if interpolation is needed.
&&if (abs(x - rx) & 1e-6) && (abs(y - ry) & 1e-6)
& & % Interpolation is not needed, use original datatypes
& & N = image(ry:ry+dy,rx:rx+dx);
& & D = N &= C;
& & % Interpolation needed, use double type images
& & ty = y -
& & tx = x -
& & % Calculate the interpolation weights.
& & w1 = (1 - tx) * (1 - ty);
& & w2 =& && &tx&&* (1 - ty);
& & w3 = (1 - tx) *& && &
& & w4 =& && &tx&&*& && &
& & % Compute interpolated pixel values
& & N = w1*d_image(fy:fy+dy,fx:fx+dx) + w2*d_image(fy:fy+dy,cx:cx+dx) + ...
& && &&&w3*d_image(cy:cy+dy,fx:fx+dx) + w4*d_image(cy:cy+dy,cx:cx+dx);
& & D = N &= d_C;
&&% Update the result matrix.
&&v = 2^(i-1);
&&result = result + v*D;
%Apply mapping if it is defined
if isstruct(mapping)
& & bins = mapping.
& & for i = 1:size(result,1)
& && &&&for j = 1:size(result,2)
& && && && &result(i,j) = mapping.table(result(i,j)+1);
& && &&&end
if (strcmp(mode,'h') || strcmp(mode,'hist') || strcmp(mode,'nh'))
& & % Return with LBP histogram if mode equals 'hist'.
& & result=hist(result(:),0:(bins-1));
& & if (strcmp(mode,'nh'))
& && &&&result=result/sum(result);
& & %Otherwise return a matrix of unsigned integers
& & if ((bins-1)&=intmax('uint8'))
& && &&&result=uint8(result);
& & elseif ((bins-1)&=intmax('uint16'))
& && &&&result=uint16(result);
& && &&&result=uint32(result);
本帖最后由 alexyau 于
21:44 编辑
建议你连同错误信息一起贴出来,也许别人一下就看出是什么问题,而不是非要别人去运行一下你的代码
alexyau 发表于
建议你连同错误信息一起贴出来,也许别人一下就看出是什么问题,而不是非要别人去运行一下你的代码 ...
每次执行的时候就出来这个,就执行不下去了,不知道应该怎样修改下,谢谢
Error: File: Untitled.m Line: 18 Column: 1
Function definitions are not permitted in this context.
胡萝卜静静 发表于
每次执行的时候就出来这个,就执行不下去了,不知道应该怎样修改下,谢谢
Error: File: Untitled.m Line: ...
在editor中新建一个,再把Function放到里面,主函数对Function进行调用,Function函数不能和主函数写到一起
初学,有些帮助
Powered by天龙八部求BB高手,帮我看这BB,提双10上多少ZZ,估计,推测,乱说的,请自便,给理解释,谢谢
天龙八部求BB高手,帮我看这BB,提双10上多少ZZ,估计,推测,乱说的,请自便,给理解释,谢谢
裸资2567,双十4864,宝宝不错
其他回答 (3)
这BB不错、是什么Bb?
因为 也有个花 差不多 你这个双10 顶多4200
我也有个差不多的BB
要我我当初就不提它= =
你都提到八了灵气还没过4000
相关知识等待您来回答
天龙八部2领域专家求高手帮忙分析超声波发射电路,谢谢啦 ,需要详细的解释工作原理。(T0输入40KHZ方波信号)_百度知道
求高手帮忙分析超声波发射电路,谢谢啦 ,需要详细的解释工作原理。(T0输入40KHZ方波信号)
偏门用MAX232毕竟干用用5V电源驱超声波探巧妙案MAX232TTL-RS232电平转换IC内部电荷泵吧5V电源电压变±10v~±15v并电压输信号电路典型RS232工作电路输接超声波传器MCU输TTL信号(0-5V)转换±15v输超声波传器般压电陶瓷材料容性器件驱电压较高、电流较用5V直接驱效差电路设计者用MAX232升压达提升驱电压目巧妙偏门做习习(我习)规产品要谨慎使用呵呵
请问下“偏门的用法”具体是什么意思呢,那么左边部分的工作原理是怎样的呢,还是不懂啊,求解答?
一般来讲,超声波发射电路是采用脉冲变压器来升压驱动;简单一些的电路,采用一个电感来升压(升至2倍的电源电压);再简单的电路,就用9V-12V电源,接一个CMOS门电路直接驱动。这种采用MAX232电荷泵升压的电路,本人还是头一回看到呵呵,学习了。左边的电路,除了最下面的电源指示灯以外,我认为那两个二极管是为保护MAX232器件设计的。
其他&1&条热心网友回答
学习中,超声波电路网上很多的~~!请高手帮我丰富丰富这几点合理化建议的内容,填充下,高分回报 谢谢!是关于汽车站的合理化建议_百度知道
请高手帮我丰富丰富这几点合理化建议的内容,填充下,高分回报 谢谢!是关于汽车站的合理化建议
1.针节车站旅客剧增换乘设立临票务综合服类窗口避免发混乱2.节期间设立VIP员军武警残疾等特殊群体优先购票临窗口3.鉴于节期间旅客剧增 易发旅客滞留候车情绪稳定现象建议旅客候车程量送发宣传刊物及乘车班刻手册打发旅客候车间仅仅宣传企业能便旅客乘车起稳定情绪避免混乱作用三点意见请懂朋友 帮我丰富丰富每条理由作用 要理据三四百字左右急用用高作报另外追加数奉送谢谢
提问者采纳
提问者评价
果然高手 = =!
其他类似问题
按默认排序
其他2条回答
职工培养能手断调整岗位使职工新鲜号召基层管理员要善说气激职场让职工快乐工作产品坏取决于基层管理员善与恶
合理化建议的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 校花的贴身高手 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信