I think you're best off creating then from the images you got from bwperim(). Use those images with ind2rgb() to create an RGB image, and just assign the color for the latest image to a running total image. If you want the black to then become white you can get a mask of all pure black areas and set them all to 255. But if you really want to start with these existing white and colored images, you can do (as a start)
masterImage = zeros(rows, columns, 3, 'uint8');
[rMaster, gMaster, bMaster] = imsplit(masterImage);
for k = 1 : numImages]
filename = fullfile(folder, whatever-------------)
thisImage = imread(filename);
% Find pixels that are pure white (255,255,255)
whiteMask = all(thisImage == 255, [], 3);
% Get mask of other pixels that are the
linesMask = ~whiteMask;
[r, g, b] = imsplit(thisImage);
rMaster(linesMask) = r(linesMask);
gMaster(linesMask) = g(linesMask);
bMaster(linesMask) = b(linesMask);
end
masterImage = cat(3, rMaster, gMaster, bMaster);