Copyright Tristan Aubrey-Jones November 2006.
function img = imcolourmap(im, colour)
% IMCOLOURMAP
%% check is colour image
%% normalize
im = double(im);
imax = max (max ( max (im )));
imin = min(min ( min (im )));
im = (im - imin )/( imax - imin );
colour = colour / 255;
%% calculate distances from mean colour
sz = size(im);
img = zeros(sz(1),sz(2));
im = double(im);
for x = 1:sz(1)
for y = 1:sz(2)
% compute this pixel colour's dist from mean colour
ci = [im(x,y,1); im(x,y,2); im(x,y,3)];
img(x,y) = norm(colour - ci);
% remove noise
if img(x,y) > 0.4, img(x,y) = 1; end
end
end