Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to change this image to binary

1 回表示 (過去 30 日間)
nurul hafizah
nurul hafizah 2015 年 5 月 6 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want to convert this image. the red colour part become black and other part become white?? Is there any way to do it??

回答 (1 件)

Walter Roberson
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;

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by