12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- %% Clusters Distance
- % The function provides the computation of Euclidean Distance
- % Between Clusters and input Data Matrices.
- % If the flag CMinDistON is active, it returns the Cluster Matrix
- % corresponding to input Data which are minimum at distance.
- %
- % Inputs:
- % - XSet Input Matrix: each row is a multidimensional data
- % - CSet Cluster Matrix: each row is a multidimensional data
- % - CMinDistON Flag which allows to return the Minimum Distance Clusters
- %
- % Outputs:
- % - XCDist Matrix containing the Distances between Data and Clusters
- % - CMinDist Matrix containing the Clusters at Minimum Distance
- %%
- function [ CMinDist, iCMinDist] = Quantization( XSet, CSet)
- % Ntr = size(XSet,2);
- % imgSzSq=size(CSet,1);
- % kCent = size(CSet,2);
- %
- % XCDist=zeros(kCent,Ntr);
- % CMinDist=zeros(imgSzSq,Ntr);
- % iCMinDist=zeros(1,Ntr);
- %
- % for jj=1:Ntr
- % for ii=1:kCent
- % XCDist(ii,jj)=sqrt(sum((XSet(:,jj)-CSet(:,ii)).^2));
- % end
- % [~,iCMinDist(jj)]=min(XCDist(:,jj));
- % CMinDist(:,jj)=CSet(:,iCMinDist(jj));
- % end
-
-
- CSetSq = sum (CSet.^2) / 2;
- XSetSq = sum (XSet.^2) / 2;
- XCDist = bsxfun (@plus, XSetSq', bsxfun (@minus, CSetSq, XSet'*CSet));
- % if nRecall == 1
- [CMinDist, iCMinDist] = min (XCDist, [], 2);
- % else
- % [CMinDist, iCMinDist] = sort (XCDist, 2);
- % CMinDist = CMinDist (:, 1:nRecall);
- % iCMinDist = iCMinDist (:, 1:nRecall);
- % end
-
- % CMinDist = CMinDist' * 2;
- % iCMinDist = iCMinDist';
- end
|