```Hi Michel

I have this piece of matlab code (pasted below) that does this. It won’t divide into regions of “exactly” the same size, but almost.

Example use:

Cheers

%
% clusters in a voronoi-like fashion
% starting with random equally spread seeds
%
%
rng('shuffle');

v = [x y z];
N = size(v,1);

% random first point

s    = [randi(N);zeros(nclust-1,1)];
list = cell(nclust,1);
list{1} = s(1);
sv2=sum(v.^2,2);
d=zeros(N,nclust);D=d;
d(:,1) = sv2 + sv2(s(1)) - 2*v*v(s(1),:)';
D(:,1) = d(:,1);
for i=2:nclust
d(:,i-1) = sv2 + sv2(s(i-1)) - 2 * v*v(s(i-1),:)';
[~,j] = max(min(d(:,1:i-1),[],2));
s(i)  = j;
list{i} = j;
D(:,i) = sv2 + sv2(j) - 2 * v*v(j,:)';
end
% winner take all on distances
[~,idx]    = min(D,[],2);

Dear experts,

I am looking for a solution to divide a mask into 10 regions of interest of the same size.
Does anyone have a solution for this?

thank you much for your help,
kind regards

michel

Michel Thiebaut de Schotten
Associate Professor, PhD, HDR, CNRS
Sorbonne Universities, UPMC Univ Paris 06
Brain Connectivity and Behaviour Group
Frontlab, Institut du cerveau et la moelle épinière
Hôpital de la Salpêtrière - ICM
47 Bvd de l'Hôpital CS21414
75646 PARIS CEDEX 13

Skype: michel_thiebaut_de_schotten
phone: +33 7 83 50 81 60<tel:%2B33%207%2083%2050%2081%2060>
http://www.bcblab.com<http://www.bcblab.com/>
http://toolkit.bcblab.com<http://toolkit.bcblab.com/>

```