How I can change white color to red?
7 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Jan
2013-2-5
Let me guess what your image is:
img = uint8(rand(640, 480, 3) * 255);
R = img(:, :, 1);
G = img(:, :, 2);
B = img(:, :, 3);
isWhite = R == 255 & B == 255 & G == 255;
G(isWhite) = 0;
B(isWhite) = 0;
newImg = cat(3, R, G, B);
I do not like this solution. Is there an "inplace" method which does not duplicate the data?
2 个评论
Image Analyst
2013-2-5
编辑:Image Analyst
2013-2-5
Is (253,254,251) still white? (BTW, that's what my response was asking.) If so, you can alter the formula to use different thresholds. In that example, you'd use >= instead of == and the new threshold values:
isWhite = R >= 253 & G >= 254 & B >= 251;
更多回答(1 个)
Image Analyst
2013-2-5
Define the range of values that encompass white? Is it only (255,255,255) or could it be more of the possible 16.7 million colors?
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!