You just want the outlines of the colored regions stored in another image, right?
You can use the gradient function:
% Convert image to double (gradients are always returned as double arrays)
J = im2double(I);
% Loop through color channels (assuming original image is stored in I)
for i = 1 : 3
G(:,:,i) = imgradient(I(:,:,i));
end
% Convert the gradient to grayscale and flip black and white
E = 1 - rgb2gray(G);