Coloring the largest component with different color than others
1 view (last 30 days)
Show older comments
Hello all,
I am looking to mark the largest connected component in an image with special color say 'red', and then color the other components in black while the empty space I wanted to be colored in white.Here are my codes.
Answers (1)
Prashant Arora
on 17 Jul 2017
Hi Sultan,
You can use the method below to achieve your use-case.
image = zeros(size(biggest,1),size(biggest,2),3);
NotBiggest = B - biggest;
image(:,:,1) = biggest + 1*NotBiggest;
image(:,:,2) = 0*biggest + 1*NotBiggest;
image(:,:,3) = 0*biggest + 1*NotBiggest;
imagesc(image);
0 Comments
See Also
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!