フィルターのクリア

I want to take R, G, B color components of an pixel by logical indexing, check channel values, and create new binary image but error occures at the command related with logical indexing

1 回表示 (過去 30 日間)
I want to take a RGB image, read it and hold it as an matrix, extract color components R, G, B as R=arr(:,:,1), G=arr(:,:,2) and B=arr(:,:,3). Then I want to create new matrix -image- by pay attention to channel values. For example; if R value is greater than 50 and G value is lower than 20 and B value is lower than 165 I make the pixel value at this location to 1, otherwise 0. And I want to access pixels by logical indexing. To achieve this, I run the command given below. But at the third command -logical indexing related- an error occurs "Operands to the || and && operators must be convertible to logical scalar values. " How can I fix this problem friends, thank you in advance.
arr=imread('image.jpg');
binaryImage = zeros(size(arr,1),size(arr,2));
binaryImage( (arr(:,:,1)>50) && (arr(:,:,2)<20) && (arr(:,:,3)<165)) = 1;

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 4 月 8 日
Replace && with &
binaryImage( (arr(:,:,1)>50) & (arr(:,:,2)<20) & (arr(:,:,3)<165)) = 1

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by