MATLAB: How to mask green pixels

Image Processing Toolboxmask green pixels

i wanted to mask green pixels of an image…
that is…
if the green component of pixel intenties is less than the compute threshold value
then, clear red, green, blue components of this pixel…
and then delete both pixel with zeros components and pixel on the boundaries….
i calculated the threshold… now i' m stuck with the masking part…. please could somebody help me to solve it…

Best Answer

tG = IM(:,:,2) > GreenThreshold;
newIM = IM .* repmat(tG,[1 1 3]);
You need to figure out the deletion part yourself, as there might be irregular patterns of pixels with value (0,0,0) and MATLAB does not support arrays with "holes" in them.