Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to change this image to binary

1 vue (au cours des 30 derniers jours)
nurul hafizah
nurul hafizah le 6 Mai 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
I want to convert this image. the red colour part become black and other part become white?? Is there any way to do it??

Réponses (1)

Walter Roberson
Walter Roberson le 6 Mai 2015
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;

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by