how to convert segmented image composed of edges back to RGB image?

1 view (last 30 days)
So I have an original RGB image. I got the edges using sobel edge detection. I then segmented the image such that one part of the image is color black (which i don't need anymore) while the other part is the remaining image composed of edges. How can I convert this image back to the RGB image? Also, I need the black part to be removed from the RGB image. please please please help me!!!!!

Accepted Answer

Walter Roberson
Walter Roberson on 31 Aug 2015
Your edge image sounds like it is a logical mask. If so then
maskedImage = repmap(EdgeMask, 1, 1, 3) .* TheRGBImage;
This will set locations to 0, which will show up as black. If your image class is double() then you could set the locations to NaN instead:
maskedImage = TheRGBImage;
nanidx = find(~EdgeMask);
pane_size = size(EdgeMask);
maskeImage(nanidx) = nan; %zap red
maskedImage(nanidx + pane_size) = nan; %zap green
maksedImage(nanidx + 2*pane_size) = nan; %zap blue

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!