MATLAB: Overlay two images of different type

edgeImage Processing Toolboxoverlaysuperimpose

I have a uint8 image and another logical image of the same dimensions, containing edges found from the first one. I want to make the white pixels (edges) of the logical image red (so must be converted to rgb) and then superimpose it over the original uint8 image. Transparency is not a requirement, I want the simplest code possible! Thanks everyone.

Best Answer

Thanks for your suggestions guys. After some experimentation, I have eventually found out how to do exactly what I needed (and it's not that difficult after all). If you suggest any alterations for coding improvement, I am glad to hear them.
% these 3 conversions from uint8 to RGB are required
% otherwise the images will not overlay
image = uint16(image); % image is the original image
[indexed,map] = gray2ind(image,256);
image2 = ind2rgb(indexed,map); % image2 is the original image in RGB
[rows, columns] = find(edges); % edges is the binary image
pixelcount = size(rows,1);
for i = 1:pixelcount
image2(rows(i),columns(i),1) = 1;
image2(rows(i),columns(i),2) = 0;
image2(rows(i),columns(i),3) = 0;
% ignoring the last two makes red transparent!
end
imwrite(image2, [mysavefolder, '\overlaid.png']);
Related Question