How can I eliminate the pixels on an image that contain more blue or red than green?
Show older comments
I am working on a project with plants and I would like the program to detect the green objects .
Answers (1)
Joseph Cheng
on 7 Jul 2015
create a mask using a threshold.
samp(:,:,1) = repmat(0:.1:1,11,1);
samp(:,:,3) = repmat([0:.1:1]',1,11);
samp(:,:,2) = .5*ones(size(samp(:,:,1)));
subplot(1,2,1),image(samp)
mask = repmat(samp(:,:,1)<samp(:,:,2) & samp(:,:,3)<samp(:,:,2),1,1,3);
greenIM = zeros(size(samp));
greenIM(mask) = samp(mask);
subplot(1,2,2),imagesc(greenIM)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!