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_getborders(map)
function borders = srm_getborders(map)

dx = conv2(map, [-1 1], 'same');
dy = conv2(map, [-1 1]', 'same');
dy(end,:) = 0; % ignore the last row of dy
dx(:,end) = 0; % and the last col of dx
borders = find(dx ~= 0 | dy ~= 0);

Contact us at files@mathworks.com