Code covered by the BSD License  

Highlights from
Image segmentation using statistical region merging

image thumbnail
from Image segmentation using statistical region merging by Sylvain Boltz
Very simple and fast image segmentation code using statistical region merging.

srm_randimseg(map)
function Q = srm_randimseg(map)
% IMSEG Color an image based on the segmentation
%   ISEG = IMSEG(I,LABELS) Labels ISEG with the average color from I of
%   each cluster indicated by LABELS

[M,N] = size(map) ;
Q = zeros(M,N,3) ;

l=unique(map);
for i=1:length(l)
    idx=find(map==l(i));
    b=rand(1,3);
    Q([idx;idx+M*N;idx+2*M*N])=repmat(b,[length(idx) 1]);
end

Q = min(1,Q);

Contact us at files@mathworks.com