フィルターのクリア

Convert Grayscale Image to a Black and White Image by Certain Threshold Number

133 ビュー (過去 30 日間)
Sarah
Sarah 2018 年 9 月 14 日
回答済み: Image Analyst 2018 年 9 月 15 日
I have a greyscale image where the matrix contains numbers between 0 (black) to 255 (white). I want to convert this image/matrix to a black and white image where certain values are white (here, 0 - 127) and the rest to be black (128 - 255). How do I do this? What functions can I use??
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 9 月 15 日
I am confused about whether low values are black as in your first description, or are white as in your second description? Are is the idea that you want the values to be thresholded and you want low values to become white? Or is the idea that you want to threshold and have low value stay low values and high value stay high values (but quantized) but that you want the colormap to switch so that low values are displayed in white and high values are displayed in black even though it was the other way around in the original data?

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2018 年 9 月 15 日
Try this:
binaryImage = grayImage <= 127;

その他の回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 9 月 15 日
編集済み: KALYAN ACHARJYA 2018 年 9 月 15 日
bw_image=im2bw(gray_image); %By Default here threshold is 0.5
Or
bw_image=im2bw(gray_image,threshold_value);
Choose threshold_value as per your requirements (In between 0 and 1)
Your case: Therefore, a level value of 0.5 corresponds to an intensity value halfway between the minimum and maximum value of the class. (0-127-255), Mid 127, so threshold value 0.5 (By default).
After 2016a added the imbinarize function, detail here

カテゴリ

Help Center および File ExchangeWhite についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by