0

我知道这看起来不知何故与代码错误和开发无关,但 我想知道是否有人可以理解这些代码 积分图像和本地二进制模式,并告诉我他们如何影响生成的直方图。积分图像如何影响局部二进制模式或中心对称局部二进制模式的结果

在使用积分图像之前,输出直方图是正常的,但在应用积分图像方法后,我发现大部分直方图都变为零。为了澄清事情,使用积分图像的预期益处是加速方法的过程。事实上,我之前没有看到这个,因为我第一次尝试它。有谁知道这个可以帮助我吗?

这些是每个方法的代码:

积分图像

function [outimg] = integral(image) 
[y,x] = size(image); 
outimg = zeros(y+1,x+1); 
disp(y); 
for a = 1:y+1 
    for b = 1:x+1 
     rx = b-1; 
     ry = a-1; 
     while ry>=1 
      while rx>=1 
       outimg(a,b) = outimg(a,b)+image(ry,rx); 
       rx = rx-1; 
      end 
      rx = b-1; 
      ry = ry-1; 
     end 
     % outimg(a,b) = outimg(a,b)-image(a,b); 
    end 
end 
% outimg(1,1) = image(1,1); 
disp('end loop'); 
end 

CS-LBP

function h = CSLBP(I) 
%% this function takes patch or image as input and return Histogram of 
%% CSLBP operator. 
h = zeros(1,16); 
[y,x] = size(I); 
T = 0.1; % threshold given by authors in their paper 
for i = 2:y-1 
    for j = 2:x-1 
     % keeping I(j,i) as center we compute CSLBP 
     % N0 - N4 
     a = ((I(i,j+1) - I(i, j-1) > T) * 2^0);   
     b = ((I(i+1,j+1) - I(i-1, j-1) > T) * 2^1); 
     c = ((I(i+1,j) - I(i-1, j) > T) * 2^2); 
     d = ((I(i+1,j-1) - I(i - 1, j + 1) > T) * 2^3); 
     e = a+b+c+d; 
     h(e+1) = h(e+1) + 1; 
    end 
end 
end 

回答

1

Matlab具有用于创建积分图像的内在功能,integralimage() 。如果你不想使用计算机视觉系统工具箱可以通过调用达到同样的效果:

如果需要
IntIm = cumsum(cumsum(double(I)),2); 

可能添加填充。你应该检查图像不饱和,有时他们会这样做。计算累积和可以很快的达到uint8和uint16的整数范围,我甚至会用一次double来实现!