Skip to content

Commit

Permalink
*.m: mlint 2013a error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pdollar committed Jun 12, 2013
1 parent 05c5cba commit ac7dbbc
Show file tree
Hide file tree
Showing 41 changed files with 79 additions and 78 deletions.
2 changes: 1 addition & 1 deletion channels/chnsPyramid.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
ss=(0:.01:1-eps)*(s1-s0)+s0;
es0=d0*ss; es0=abs(es0-round(es0/shrink)*shrink);
es1=d1*ss; es1=abs(es1-round(es1/shrink)*shrink);
[e,x]=min(max(es0,es1)); scales(i)=ss(x);
[~,x]=min(max(es0,es1)); scales(i)=ss(x);
end
kp=[scales(1:end-1)~=scales(2:end) true]; scales=scales(kp);
scaleshw = [round(sz(1)*scales/shrink)*shrink/sz(1);
Expand Down
2 changes: 1 addition & 1 deletion classify/fernsClfApply.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
inds = fernsInds(data,ferns.fids,ferns.thrs); end
[N,M]=size(inds); H=ferns.H; probs=zeros(N,H);
for m=1:M, probs = probs + ferns.pFern(inds(:,m),:,m); end
if(ferns.bayes==0), probs=probs/M; end; [d,hs]=max(probs,[],2);
if(ferns.bayes==0), probs=probs/M; end; [~,hs]=max(probs,[],2);
end
2 changes: 1 addition & 1 deletion classify/fernsRegTrain.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@
function m = medianw(x,w)
% Compute weighted median of x.
[x,ord]=sort(x(:)); w=w(ord);
[disc,ind]=max(cumsum(w)>=sum(w)/2);
[~,ind]=max(cumsum(w)>=sum(w)/2);
m = x(ind);
end
8 changes: 4 additions & 4 deletions classify/kmeans2.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

% error checking
if(k<1); error('k must be greater than 1'); end
if(ndims(X)~=2 || any(size(X)==0)); error('Illegal X'); end
if(~ismatrix(X) || any(size(X)==0)); error('Illegal X'); end
if(outFrac<0 || outFrac>=1), error('outFrac must be in [0,1)'); end
nOut = floor( size(X,1)*outFrac );

Expand All @@ -84,23 +84,23 @@

% sort IDX to have biggest clusters have lower indicies
cnts = zeros(1,k); for i=1:k; cnts(i) = sum( IDX==i ); end
[ids,order] = sort( -cnts ); C = C(order,:); d = d(order);
[~,order] = sort( -cnts ); C = C(order,:); d = d(order);
IDX2=IDX; for i=1:k; IDX2(IDX==order(i))=i; end; IDX = IDX2;

end

function [IDX,C,d] = kmeans2main( X, k, nOut, minCl, maxt, dsp, metric, C )

% initialize cluster centers to be k random X points
[N p] = size(X); k = min(k,N);
[N,p] = size(X); k = min(k,N);
IDX = ones(N,1); oldIDX = zeros(N,1);
if(isempty(C)), C = X(randSample(N,k),:); end; t=0;

% MAIN LOOP: loop until the cluster assigments do not change
if(dsp), nDg=ceil(log10(maxt-1)); fprintf(int2str2(0,nDg)); end
while( any(oldIDX~=IDX) && t<maxt )
% assign each point to closest cluster center
oldIDX=IDX; D=pdist2(X,C,metric); [mind IDX]=min(D,[],2);
oldIDX=IDX; D=pdist2(X,C,metric); [mind,IDX]=min(D,[],2);

% do not use most distant nOut elements in computation of centers
mind1=sort(mind); thr=mind1(end-nOut); IDX(mind>thr)=-1;
Expand Down
2 changes: 1 addition & 1 deletion classify/meanShift.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
meansFinal = meansFinal';

% calculate final cluster means per cluster
[N,p] = size(X); k = max(IDX);
p = size(X,2); k = max(IDX);
M = zeros(k,p); for i=1:k; M(i,:) = mean( meansFinal(IDX==i,:), 1 ); end

% sort clusters [largest first] and remove all smaller then minCsize
Expand Down
2 changes: 1 addition & 1 deletion classify/meanShiftIm.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
if( nargin<6 || isempty(minDel)); minDel = .001; end

[mrows, ncols, p] = size(X); p = p+2;
[gridRs gridCs] = ndgrid( 1:mrows, 1:ncols );
[gridRs, gridCs] = ndgrid( 1:mrows, 1:ncols );
data = cat( 3, cat( 3, gridRs/sigSpt, gridCs/sigSpt), X/sigRng );

%%% MAIN LOOP
Expand Down
2 changes: 1 addition & 1 deletion classify/meanShiftImExplore.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function meanShiftImExplore( I, X, sigSpt, sigRng, show )
r=round(r); c=round(c);

%%% get D and S
[gridRs gridCs] = ndgrid( 1:mrows, 1:ncols );
[gridRs, gridCs] = ndgrid( 1:mrows, 1:ncols );
Deuc = ((gridRs-r).^2 + (gridCs-c).^2) / sigSpt^2;
x = X(r,c,:); x = x(:)'; Xflat = reshape(X,[],p);
Drange = pdist2( x, Xflat );
Expand Down
4 changes: 2 additions & 2 deletions classify/pca.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
% get principal components using the SVD- X=U*S*V'; maxrank=min(n-1,D)
% basically same as svd(X,'econ'), slightly faster?
if( D>n )
[V,SS,V] = svd( X' * X );
[~,SS,V] = svd( X' * X );
keepLocs = diag(SS) > 1e-30;
SS = SS(keepLocs,keepLocs);
V = V(:,keepLocs);
U = X * V * diag(1./sqrt(diag(SS)));
else
[U,SS,U] = svd( X * X' );
[~,SS,U] = svd( X * X' );
keepLocs = diag(SS) > 1e-30;
SS = SS(keepLocs,keepLocs);
U = U(:,keepLocs);
Expand Down
2 changes: 1 addition & 1 deletion classify/pcaVisualize.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
x = double( X(inds{:},index) );
xhats = x; diffs = []; errors = zeros(1,length(ks));
for k=1:length(ks)
[ Yk, xhat, errors(k) ] = pcaApply( x, U, mu, ks(k) );
[ ~, xhat, errors(k) ] = pcaApply( x, U, mu, ks(k) );
xhats = cat( nd, xhats, xhat );
diffs = cat( nd, diffs, (xhat-x).^2 );
end
Expand Down
2 changes: 1 addition & 1 deletion classify/rbfComputeBasis.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
if( nargin<3 || isempty(cluster)); cluster=1; end
if( nargin<4 || isempty(scale)); scale=5; end
if( nargin<5 || isempty(show)); show=0; end
[N d] = size(X);
[N, d] = size(X);

if( cluster )
%%% CLUSTERS subsample, run kmeans
Expand Down
4 changes: 2 additions & 2 deletions classify/softMin.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
% Licensed under the Simplified BSD License [see external/bsd.txt]

if( sigma==0 ) % special case, make fast
[vs, inds] = min(D,[],2); [n k] = size(D);
[~, inds] = min(D,[],2); [n, k] = size(D);
M = subsToArray( [(1:n)' inds], ones(n,1), [n k] );

else % general case
Expand All @@ -56,7 +56,7 @@
sumM = sum( M, 2 );
sumMzero = (sumM==0);
if( any(sumMzero) )
[vs, inds] = min(D,[],2); [n k] = size(D);
[~, inds] = min(D,[],2); [n, k] = size(D);
Mhard = subsToArray( [(1:n)' inds], ones(n,1), [n k] );
M( sumMzero, : ) = Mhard( sumMzero, : );
sumM = sum( M, 2 );
Expand Down
2 changes: 2 additions & 0 deletions external/history.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Version NEW
-TODO: automatic delete of rgb/png read crap, fix for 2013
-NO LONGER SUPPORTING MATLAB VERSIONS PRIOR TO MATLAB 2011b
-mlint error fixes throughout for Matlab 2013a
-forestTrain.m: optimizations and minor fix if hs small (thanks Stefan Gachter)
-bbGt.m: minor fix to bbGt>loadAll (thanks Phuc Nguyen)
-minor: savefig
Expand Down
4 changes: 2 additions & 2 deletions filters/modefilt1.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
% Licensed under the Simplified BSD License [see external/bsd.txt]

% get unique values in x
[vals,disc,inds]=unique(x(:)'); m=length(vals); n=length(x);
[vals,~,inds]=unique(x(:)'); m=length(vals); n=length(x);
if(m>256), warning('x takes on large number of diff vals'); end %#ok<WNTAG>

% create quantized representation [H(i,j)==1 iff x(j)==vals(i)]
Expand All @@ -44,6 +44,6 @@
H=localSum(H,[0 s],'same');

% compute mode for each j and map inds back to original vals
[disc,inds]=max(H,[],1); y=vals(inds);
[~,inds]=max(H,[],1); y=vals(inds);

end
2 changes: 1 addition & 1 deletion images/bbApply.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
n=size(bb,1); bb(:,1:4)=round(bb(:,1:4));
if(size(col,1)==1), col=col(ones(1,n),:); end
if(size(fcol,1)==1), fcol=fcol(ones(1,n),:); end
if( ndims(I)==2 ), I=I(:,:,[1 1 1]); end
if( ismatrix(I) ), I=I(:,:,[1 1 1]); end
% embed each bb
x0=bb(:,1); x1=x0+bb(:,3)-1; y0=bb(:,2); y1=y0+bb(:,4)-1;
j0=floor((lw-1)/2); j1=ceil((lw-1)/2); h=size(I,1); w=size(I,2);
Expand Down
8 changes: 4 additions & 4 deletions images/bbGt.m
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@
assert( size(gt0,2)==5 ); ng=size(gt0,1);

% sort dt highest score first, sort gt ignore last
[disc,ord]=sort(dt0(:,5),'descend'); dt0=dt0(ord,:);
[disc,ord]=sort(gt0(:,5),'ascend'); gt0=gt0(ord,:);
[~,ord]=sort(dt0(:,5),'descend'); dt0=dt0(ord,:);
[~,ord]=sort(gt0(:,5),'ascend'); gt0=gt0(ord,:);
gt=gt0; gt(:,5)=-gt(:,5); dt=dt0; dt=[dt zeros(nd,1)];

% Attempt to match each (sorted) dt to each (sorted) gt
Expand Down Expand Up @@ -728,7 +728,7 @@
if( roc ), tp=tp/np; fppi=fp/nImg; xs=fppi; ys=tp;
else rec=tp/np; prec=tp./(fp+tp); xs=rec; ys=prec; end
% reference point
[d,ind]=min(abs(xs-ref)); ref=ys(ind);
[~,ind]=min(abs(xs-ref)); ref=ys(ind);
end

function [Is,scores,imgIds] = cropRes( gt, dt, imFs, varargin )
Expand Down Expand Up @@ -776,7 +776,7 @@
% flatten bbs and keep relevent subset
bbs=cat(1,bbs{:}); K=keep(bbs); bbs=bbs(K,:); ids=ids(K); n=min(n,sum(K));
% reorder bbs appropriately
if(~strcmp(type,'fn')), [d,ord]=sort(bbs(:,5),'descend'); else
if(~strcmp(type,'fn')), [~,ord]=sort(bbs(:,5),'descend'); else
if(size(bbs,1)<n), ord=randperm(size(bbs,1)); else ord=1:n; end; end
bbs=bbs(ord(1:n),:); ids=ids(ord(1:n));
% extract patches from each image
Expand Down
8 changes: 4 additions & 4 deletions images/bbNms.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
function bbs = nms1( bbs, type, thr, maxn, radii, overlap, isy )
% if big split in two, recurse, merge, then run on merged
if( size(bbs,1)>maxn )
n2=floor(size(bbs,1)/2); [d,ord]=sort(bbs(:,1+isy)+bbs(:,3+isy)/2);
n2=floor(size(bbs,1)/2); [~,ord]=sort(bbs(:,1+isy)+bbs(:,3+isy)/2);
bbs0=nms1(bbs(ord(1:n2),:),type,thr,maxn,radii,overlap,~isy);
bbs1=nms1(bbs(ord(n2+1:end),:),type,thr,maxn,radii,overlap,~isy);
bbs=[bbs0; bbs1];
Expand All @@ -111,7 +111,7 @@

function bbs = nmsMax( bbs, overlap, greedy, ovrDnm )
% for each i suppress all j st j>i and area-overlap>overlap
[score,ord]=sort(bbs(:,5),'descend'); bbs=bbs(ord,:);
[~,ord]=sort(bbs(:,5),'descend'); bbs=bbs(ord,:);
n=size(bbs,1); kp=true(1,n); as=bbs(:,3).*bbs(:,4);
xs=bbs(:,1); xe=bbs(:,1)+bbs(:,3); ys=bbs(:,2); ye=bbs(:,2)+bbs(:,4);
for i=1:n, if(greedy && ~kp(i)), continue; end
Expand All @@ -131,7 +131,7 @@
ps=[bbs(:,1)+w/2 bbs(:,2)+h/2 log2(w) log2(h)];
% find modes starting from each elt, then merge nodes that are same
ps1=zeros(n,4); ws1=zeros(n,1); stopThr=1e-2;
for i=1:n, [ps1(i,:) ws1(i,:)]=nmsMs1(i); end
for i=1:n, [ps1(i,:), ws1(i,:)]=nmsMs1(i); end
[ps,ws] = nonMaxSuprList(ps1,ws1,stopThr*100,[],[],2);
% convert back to bbs format and sort by weight
w=pow2(ps(:,3)); h=pow2(ps(:,4));
Expand Down Expand Up @@ -169,7 +169,7 @@
end
% perform set cover operation (greedily choose next best)
N=N+N'; bbs1=zeros(n,5); n1=n; c=0;
while( n1>0 ), [s,i0]=max(N*bbs(:,5));
while( n1>0 ), [~,i0]=max(N*bbs(:,5));
N0=N(:,i0)==1; n1=n1-sum(N0); N(N0,:)=0; N(:,N0)=0;
c=c+1; bbs1(c,1:4)=bbs(i0,1:4); bbs1(c,5)=sum(bbs(N0,5));
end
Expand Down
14 changes: 7 additions & 7 deletions images/behaviorAnnotator.m
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ function setFrame( curInd1, speed1, setCenter )

function api = menuMakeApi()
% create api
[fVid fAnn lastSave]=deal([]);
[fVid, fAnn, lastSave]=deal([]);
api = struct('vidClose',@vidClose, 'annClose',@annClose, ...
'vidOpen',@vidOpen, 'audOpen',@audOpen, 'trkOpen',@trkOpen, ...
'annOpen',@annOpen, 'annBackup',@annBackup );
Expand All @@ -570,7 +570,7 @@ function updateMenus()
if(isempty(A)), en='off'; else en='on'; end
set([m.hAnnSav m.hAnnCls m.hAnnCnf m.hAnnMrg],'Enable',en);
nm='Caltech Behavior Annotator';
if(~isempty(fVid)), [d,nm1]=fileparts(fVid); nm=[nm ' - ' nm1]; end
if(~isempty(fVid)), [~,nm1]=fileparts(fVid); nm=[nm ' - ' nm1]; end
set(hFig,'Name',nm); annApi.updateAnn(); dispApi.requestUpdate();
end

Expand All @@ -582,7 +582,7 @@ function vidClose()
function vidOpen( flag )
if(isempty(fVid)), d='.'; else d=fileparts(fVid); end
if(all(ischar(flag)))
[d f]=fileparts(flag); if(isempty(d)), d='.'; end;
[d,f]=fileparts(flag); if(isempty(d)), d='.'; end;
d=[d '/']; f=[f '.seq']; flag=1;
elseif( flag==1 )
[f,d]=uigetfile('*.seq','Select video',[d '/*.seq']);
Expand Down Expand Up @@ -626,7 +626,7 @@ function audOpen( fAud )
if( nargin==0 ), [f,d]=uigetfile('*.wav','Select audio',...
[fVid(1:end-3) 'wav']); if(f==0), return; end; fAud=[d f]; end
try
[y,fs,nb]=wavread(fAud); dispApi.setAud(y,fs,nb);
[y,fs,nb]=wavread(fAud); dispApi.setAud(y,fs,nb); %#ok<REMFF1>
catch er
errordlg(['Failed to load: ' fAud '. ' er.message],'Error');
end
Expand All @@ -636,7 +636,7 @@ function annClose()
assert(~isempty(A)); qstr='Save Current Annotation?';
button = questdlg(qstr,'Save','yes','no','yes');
if(strcmp(button,'yes')); annSave(); end
[fAnn A lastSave]=deal([]); updateMenus();
[fAnn,A,lastSave]=deal([]); updateMenus();
end

function annOpen( flag )
Expand All @@ -661,7 +661,7 @@ function annOpen( flag )
updateMenus();
catch er
errordlg(['Failed to load: ' fAnn '. ' er.message],'Error');
[fAnn A lastSave]=deal([]); return;
[fAnn,A,lastSave]=deal([]); return;
end
end

Expand Down Expand Up @@ -690,7 +690,7 @@ function annNew( update )

function annBackup()
if( isempty(lastSave) || etime(clock,lastSave)>60 )
[d f]=fileparts(fAnn); f=[d '/' f '-backup.txt'];
[d,f]=fileparts(fAnn); f=[d '/' f '-backup.txt'];
assert(~isempty(A)); A.save(f); lastSave=clock();
end
end
Expand Down
6 changes: 3 additions & 3 deletions images/behaviorData.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function save1( fName )
[d f ext] = fileparts(fName);
[d,f,ext] = fileparts(fName);
if(strcmp(ext,'.txt')), saveTxt(fName); return; end
vers=.5; if(isempty(d)), d='.'; end; f=[d '/' f '.bAnn']; %#ok<NASGU>
save('-v6',f,'bnds','types','names','keys','vers');
end

function load1( fName, cName )
[d f ext] = fileparts(fName); if(nargin<2), cName=[]; end
[d,f,ext] = fileparts(fName); if(nargin<2), cName=[]; end
if(strcmp(ext,'.txt')), loadTxt(fName,cName); return; end
vers=.5; if(isempty(d)), d='.'; end; f=[d '/' f '.bAnn'];
L=load( '-mat', f );
Expand Down Expand Up @@ -276,7 +276,7 @@ function recreate( cName )

function frame = getEnd( id ), frame=bnds{s}(id+1)-1; end

function id = getId( frame ), [v,id]=min(bnds{s}<=frame); id=id-1; end
function id = getId( frame ), [~,id]=min(bnds{s}<=frame); id=id-1; end

function ids = getIds( type ), ids=find(types{s}==type); end

Expand Down
2 changes: 1 addition & 1 deletion images/convnFast.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
% Licensed under the Simplified BSD License [see external/bsd.txt]

if( nargin<3 || isempty(shape)); shape='full'; end
if(isempty(strmatch(shape, char({'same', 'valid', 'full', 'smooth'}))))
if( ~any(strcmp(shape,{'same', 'valid', 'full', 'smooth'})) )
error( 'convnFast: unknown shape flag' ); end

shapeorig = shape;
Expand Down
2 changes: 1 addition & 1 deletion images/filmStrip.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
I = double(I); I = I/max(I(:)); sizI = size(I);
if(~any(sizI(3)==[1 3])); I=reshape(I,[sizI(1:2),1,sizI(3:end)]); end
I = padarray( I, [border border 0 0 0], 0, 'both' );
[mRows nCols nColor nFrame nStrip] = size(I);
[mRows, nCols, nColor, nFrame, nStrip] = size(I);

% size of final filmstip object
sizF1 = [mRows+delta*(nFrame-1), nFrame*nCols-overlap*(nFrame-1), nColor];
Expand Down
4 changes: 2 additions & 2 deletions images/histc2.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

if( nargin<3 ); wtMask=[]; end;
if( ~isa(A,'double') ); A=double(A); end;
if( ndims(A)>2 ); error('A must be a 2 dim array'); end;
[n nd] = size(A);
if( ~ismatrix(A) ); error('A must be a 2 dim array'); end;
[n,nd] = size(A);
if( ~isempty(wtMask) && n~=numel(wtMask) )
error( 'wtMask must have n elements (A is nxnd)' ); end

Expand Down
8 changes: 4 additions & 4 deletions images/imRectRot.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function intitialize( varargin )
set( hFig, 'CurrentAxes', hAx );

% optionally display limits
if(showLims && ~isempty(lims)), [disc,xs,ys]=rectToCorners(lims);
if(showLims && ~isempty(lims)), [~,xs,ys]=rectToCorners(lims);
for j=1:4, ids=mod([j-1 j],4)+1; line(xs(ids),ys(ids)); end
end

Expand Down Expand Up @@ -166,7 +166,7 @@ function intitialize( varargin )

function pos1 = cornersToRect( pos0, x0, y0, x1, y1 )
% compute pos from 4 corners given in rect coords
[pc,rs,R] = rectInfo( pos0 );
[pc,~,R] = rectInfo( pos0 );
p0=[x0 y0]*R'+pc; p1=[x1 y1]*R'+pc;
pc=(p1+p0)/2; p0=(p0-pc)*R; p1=(p1-pc)*R;
pos1 = [pc+p0 p1-p0 pos0(5)];
Expand All @@ -192,7 +192,7 @@ function setPos( posNew, ignoreLims )
end
end
% create invisible patch to captures key presses
pos=posNew; [pts,xs,ys]=rectToCorners(pos);
pos=posNew; [~,xs,ys]=rectToCorners(pos);
vert=[xs ys ones(4,1)]; face=1:4;
set(hPatch,'Faces',face,'Vertices',vert);
% draw ellipse
Expand Down Expand Up @@ -286,7 +286,7 @@ function drag( h, evnt, flag, anchor, pos0 ) %#ok<INUSL>
end; p0a=min(p0,p1); p1=max(p0,p1); p0=p0a;
setPos(cornersToRect(pos0,p0(1),p0(2),p1(1),p1(2)));
elseif( flag==2 || flag==4 ) % rotate rectangle
[pts,xs,ys]=rectToCorners(pos0);
[~,xs,ys]=rectToCorners(pos0);
if(anchor(2)==-1), ids=[3 4]; else ids=[1 2]; end
p0=mean([xs(ids) ys(ids)]); pc=(p0+pnt)/2;
if(anchor(2)==-1), d=pnt-p0; else d=p0-pnt; end
Expand Down
Loading

0 comments on commit ac7dbbc

Please sign in to comment.