what is the difference between rgb2gray and im2bw ?
5 ビュー (過去 30 日間)
古いコメントを表示
I want to know the difference between the two functions ... arent both convert the rgb image to black and white image ?!
0 件のコメント
採用された回答
Walter Roberson
2019 年 4 月 21 日
No, rgb2gray() converts to grayscale. For uint8 images, the output could have up to 256 unique values in the matrix. im2bw() converts to bi-level, and has only 2 unique values in its output matrix.
Effectively rgb2gray() converts RGB to "brightness", whereas im2bw() converts to two color ("logical" data type in fact.)
2 件のコメント
Walter Roberson
2019 年 4 月 21 日
You can apply im2bw() to an RGB image or to a grayscale image.
But as discussed in my answer to your other question, https://www.mathworks.com/matlabcentral/answers/457695-how-to-know-if-image-is-rgb#answer_371591 there is a possibility that you are not using an RGB image. You might have RGBA or you might have a DICOM volume. Or maybe what you are passing is not a numeric array at all. Check with class() and size()
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!