How to color a binary image?
21 次查看(过去 30 天)
显示 更早的评论
Suppose a binary image is considered, which consists of two colors. Is it possible to assign red color to the white portions in the image?
2 个评论
采纳的回答
Jan
2012-10-2
编辑:Jan
2012-10-2
bin = rand(320, 200) > 0.5; % Binary test image
R = 1; % Value in range [0, 1]
G = 1;
B = 1;
RGB = cat(3, bin * R, bin * G, bin * B);
Now the pixels which have the value 1 in the bin image have the value [R,G,B] in the RGB image, while the other pixels are black.
Alternatively:
CMap = [0.5, 0.2, 0.9; 0.1, 0.8, 0.3];
RGB = ind2rgb(bin + 1, CMap)
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!