Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to change this image to binary
2 次查看(过去 30 天)
显示 更早的评论
I want to convert this image. the red colour part become black and other part become white?? Is there any way to do it??
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149868/image.jpeg)
0 个评论
回答(1 个)
Walter Roberson
2015-5-6
too_dark_for_red = YourImage(:,:,1) < some_low_red_threshold;
too_light_for_black = YourImage(:,:,2) > some_low_green_threshold | YourImage(:,:,3) > some_low_blue_threshold;
isnt_red = too_dark_for_red | too_light_for_black;
The locations that will become false (0) are those where there is enough "red" for it not to be "noise" in the sensor, and there is not enough green or blue for it to be a grey pixel.
Another potential approach would be to check to see if the red component of a pixel is "enough" greater than the blue or green component. shades of grey (white) are those where the components are close to equal, so if the components are sufficiently unequal then there will be a redder cast (if it is red that is the notably stronger component.)
If we make the optimization that the only colors are red or shades of grey then we do not need to check both the green and blue panes: in the locations where there are shades of grey then the two will be nearly equal. So we can make the test:
isnt_red = YourImage(:,:,1) < YourImage(:,:,2) + red_cast_threshold;
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!