How to convert specific part of the image into binary form.

回答 (1 件)

Image Analyst
Image Analyst 2012 年 8 月 4 日

0 投票

How about
binaryImage = grayImage > 50; % Or some other value.

5 件のコメント

Wei Qing
Wei Qing 2012 年 8 月 4 日
did the code convert the image to binary image? no need to use im2bw() function? what is the number mean?
Image Analyst
Image Analyst 2012 年 8 月 4 日
Yes, that is a binary image. It has type logical. The number says that you want every pixel with pixel value greater than 50 to be 1 (true) or "foreground", and that everything else (darker than 51) will be 0 (false) or "background."
Wei Qing
Wei Qing 2012 年 8 月 4 日
i found another way to solve the problem. Thanks for helping anyway.
Image Analyst
Image Analyst 2012 年 8 月 4 日
You're welcome. What way did you use? I never use im2bw() because it takes thresholds in the range of 0-1 and I find that very inconvenient. I'd rather pass in a gray level but it's not smart enough for that (yet - I'm going to bring it up with them). Internally im2bw ()does what I did. It just has to convert either the threshold to an actual gray level or convert the image to the range 0-1. But then it has to do the thresholding like I did it.
Wei Qing
Wei Qing 2012 年 8 月 5 日
actually i am using the wide line detector code to get the above image. http://www.mathworks.nl/matlabcentral/fileexchange/35754-wide-line-detector So i modified the codes in huang_usage.m in order to get what i want.

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

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2012 年 8 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by