You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
Matlab
32 lines
1.2 KiB
Matlab
function plot_codebook(patches,patchClassList,Locations,indeces)
|
|
if nargin<4 || isempty(indeces)
|
|
indeces=1:12;
|
|
end
|
|
|
|
patchLen=sqrt(size(patches,2));
|
|
indPatchesInClass=find(patchClassList>0);
|
|
indPatchesNonClass=find(patchClassList==0);
|
|
numClasses=length(Locations);
|
|
|
|
numClustersToPlot=min(length(indeces),length(indPatchesInClass));
|
|
numNonClustersToPlot=min(length(indeces),length(indPatchesNonClass));
|
|
numCols=max(numClustersToPlot,numNonClustersToPlot);
|
|
for i=1:numClustersToPlot
|
|
%plot voting locations
|
|
for j=1:numClasses
|
|
maxsubplot(numClasses+2,numCols,i+(j-1)*numCols);
|
|
imagesc(Locations{j}{indeces(i)});
|
|
axis('tight','equal'),set(gca,'XTick',[],'YTick',[]);
|
|
end
|
|
%plot patch from cluster
|
|
maxsubplot(numClasses+2,numCols,i+numClasses*numCols);
|
|
imagesc(reshape(patches(indPatchesInClass(indeces(i)),1:patchLen^2),patchLen,patchLen));
|
|
axis('tight','equal'),set(gca,'XTick',[],'YTick',[]);
|
|
end
|
|
for i=1:numNonClustersToPlot
|
|
%plot patch from background cluster
|
|
maxsubplot(numClasses+2,numCols,i+(numClasses+1)*numCols);
|
|
imagesc(reshape(patches(indPatchesNonClass(i),1:patchLen^2),patchLen,patchLen));
|
|
axis('tight','equal'),set(gca,'XTick',[],'YTick',[]);
|
|
end
|
|
colormap('default') |