Operands to the || and && operators must be convertible to logical scalar values.

2 ビュー (過去 30 日間)
Dinuka Ravimal
Dinuka Ravimal 2020 年 6 月 8 日
コメント済み: Dinuka Ravimal 2020 年 6 月 8 日
I want to find how many pixels are on the image between 150 and 200 gray values. So I created a code, but I'm receiving this error.
% extracted rows from the column
ext_rows = imgray(start_row:end_row,start_column:end_column);
whitePixels=ext_rows((150<ext_rows) && (ext_rows<200));
numberWhitePixels=numel(whitePixels);
I'm receiving this error.
Operands to the || and && operators must be convertible to logical scalar values.
How can I solve this error? Could you please write down correct code here?

採用された回答

Tommy
Tommy 2020 年 6 月 8 日
Use & instead for element-wise and (or | for element-wise or):
whitePixels=ext_rows((150<ext_rows) & (ext_rows<200));

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by