How can I convert gray image to binary image on ”specific” value of luminescence

2 views (last 30 days)
I want to make binary image to analyze my gray scale image.
I know there is im2bw function. But I want to select certain color values associated with specific luminescencce
For example, when we convert image to binary image, we designate certain threshold value, such as we designate threshold value as 0.4, luminescence lower than that value turned to black and higher than that value turned to white.
However, I want to convert grayscale image to binary image of selecting the "range" of luminescence, such as I want to turn convert the area has the range between 0.1 and 0.4 too black. and below 0.1 and over 0.4 should be convert to white. That`s because I want to analyze the objects of certain brightness only.
Could you give me appropriiate way for me?regionprops_gray_01.png
post the example of grayscale image.

Answers (1)

Guillaume
Guillaume on 15 May 2019
It's simple comparisons and logical operations:
  • lower than 0.4 to black, higher to white (what about 0.4?)
result = yourgreyimage > 0.4;
  • between 0.1 and 0.4 to black, the rest to white:
result = yourgreyimage < 0.1 | yourgreyimage > 0.4;

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!