Error Matrix dimension must agree in binarized statistical image feature
1 回表示 (過去 30 日間)
古いコメントを表示
I'm trying to run BSIF code
but I facing problem in this line of code
codeImg=codeImg+(ci> 0)*(2^(i-1));
I hv try to resovled it by using .*, .^ but still it is giving me same error
function bsifdescription = bsif(img,texturefilters,mode)
%% Default parameters
%sigmaBase=1;
%scl=[1 2 4 8]; %sigma=scl(i)*sigmaBase;
% Output mode
if nargin<3
mode='nh'; % return normalized histogram as default
end
%% Check that input is gray scale
if size(img,3)>1
error('Only gray scale input');
end
%% Initialize
img=double(img); % Convert image to double
numScl=size(texturefilters,3);%length(scl);
codeImg=ones(size(img));
% Make spatial coordinates for sliding window
r=floor(size(texturefilters,1)/2);%3*max(scl)*sigmaBase;
x=-r:r;
% Wrap image (increase image size according to maximum filter radius by wrapping around)
upimg=img(1:r,:);
btimg=img((end-r+1):end,:);
lfimg=img(:,1:r);
rtimg=img(:,(end-r+1):end);
cr11=img(1:r,1:r);
cr12=img(1:r,(end-r+1):end);
cr21=img((end-r+1):end,1:r);
cr22=img((end-r+1):end,(end-r+1):end);
imgWrap=[cr22,btimg,cr21;rtimg,img,lfimg;cr12,upimg,cr11];
%% Loop over scales
%figf=figure;subplot(numScl/2,2,1);
%counter=1;
for i=1:numScl
tmp=texturefilters(:,:,numScl-i+1);
%figure;imagesc(tmp);axis image;axis off; colormap('gray');
ci=filter2(tmp,imgWrap,'valid');
%figure(figf);subplot(numScl/2,2,i);
%imagesc(ci);axis image;axis off;
codeImg=codeImg + (ci > 0).*(2.^(i - 1));
end
%% Return code image if needed
if strcmp(mode,'im')
bsifdescription=codeImg;
end
%% Histogram if needed
if strcmp(mode,'nh') || strcmp(mode,'h')
bsifdescription=histogram(codeImg(:),1:(2^numScl));
end
%% Normalize histogram if needed
if strcmp(mode,'nh')
bsifdescription=bsifdescription/sum(bsifdescription);
end
end
1 件のコメント
Image Analyst
2020 年 2 月 22 日
You forgot to tell us what you passed in for img,texturefilters,mode. Also, attach any images or data if we'll need it to run your code.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!