📄 partition.m
字号:
%
% function [region] = partition(points, cdbk, blocksize): partion the
% points into 'nwds' partions based on given cdbk
%
%
% Input: points -- the original 2D gray points used to generate code book
% temp_cdbk -- nwds*2 matrix, contains the vector of all code words
%
% Output:
% region -- cell stores "nwds" matrices of different sizes,
% each matrix has certain number of rows and 2 columns,
% which represents all the points in one region
%
function region = partition(points, temp_cdbk)
n_point = size(points,1);
nwds = size(temp_cdbk, 1);
region = cell(nwds,1);
for i_point = 1: n_point
% get the vector of one point
p = points(i_point,:);
% partition this point into one region based on nearest
% neighbor condition
% initialize the parameter to be impractical
mindis = Inf;
index_nwds = 0;
for ic = 1: nwds
cw = temp_cdbk(ic,:);
dis = my_distance(p,cw);
if dis < mindis
mindis = dis;
index_nwds = ic;
end
end
% add the point to the corresponding region cell
region{index_nwds} = [region{index_nwds}; p];
end
%disp 'one partion done ...'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -