Separating particular pixels based on RGB value

I want to separate a group of pixels in an image which have RGB greater than [120 115 118 ] . How can I do it? The pixels having RGB values above the mentioned ones must appear in black color.How to do it? Thanks in advance.

 採用された回答

Walter Roberson
Walter Roberson 2011 年 3 月 20 日

0 投票

locations = YourImage(:,:,1) > 120 & YourImage(:,:,2) > 115 & YourImage(:,:,3) > 118;
YourImage(repmat(locations,1,1,3)) = 0;

3 件のコメント

Niranjan
Niranjan 2011 年 3 月 20 日
I am getting this error when I use it
??? Error using ==> repmat
Too many input arguments.
Error in ==> xxx at 8
I(repmat(locations,1,1,3)) = 0;
Should I fix the code as
I(repmat(locations,[1,1,3]) = 0; ???
Walter Roberson
Walter Roberson 2011 年 3 月 20 日
Yes, that should work if you are using an old version of Matlab. Matlab has accepted the extended version for several years now.
Niranjan
Niranjan 2011 年 3 月 20 日
oh thanks :)

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by