separate the red part of imge

5 ビュー (過去 30 日間)
PK
PK 2016 年 10 月 6 日
コメント済み: Image Analyst 2016 年 10 月 6 日
I have an red flower image with green leaf. I want to separate only red flower. How can I do? Please help!

採用された回答

Matthew Eicholtz
Matthew Eicholtz 2016 年 10 月 6 日
編集済み: Matthew Eicholtz 2016 年 10 月 6 日
A naive approach would be to extract "red" colors from the image:
I = imread('peppers.png');
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);
% Here I am naively defining "red" as the red layer being greater than
% some threshold and the blue and green layers being less than that threshold
thold = 100;
mask = R>thold & G<thold & B<thold;
R(~mask) = 255;
G(~mask) = 255;
B(~mask) = 255;
J = cat(3,R,G,B);
figure; montage(cat(4,I,J),'Size',[1 2]);
More advanced approaches exists (google "image segmentation"). For instance, see the MATLAB example for color-based segmentation using k-means clustering.
  2 件のコメント
PK
PK 2016 年 10 月 6 日
May I know threshold value for colors. Please!
Image Analyst
Image Analyst 2016 年 10 月 6 日
The Color thresholder app, like I recommended, will tell you those.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 10 月 6 日
Use the Color Thresholder on the Apps tab of the toolbar ribbon.
Or else see my File Exchange for several color segmentation demos. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Community Treasure Hunt

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

Start Hunting!

Translated by