Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to remove overlapping red and green color regions, leaving only red ones?

enter image description here

share|improve this question
    
ImageApply might be useful – ssch Oct 20 '13 at 21:52
up vote 5 down vote accepted

This removes the "overlapping" areas, assuming the green area doesn't have holes exactly where the red is, leaving the red areas only outside the green area:

img = Import["http://i.stack.imgur.com/hSBJW.png"]
{r, g, b, alpha} = ColorSeparate[img];
n = Image[0*ImageData[r]];
rnew = ImageMultiply[ColorNegate@Closing[Binarize[g], 4], r]
ColorCombine[{rnew, n, n}]

Mathematica graphics

This code simply removes the green:

rnew2 = ImageMultiply[ColorNegate@Binarize[g], r]
ColorCombine[{rnew2, n, n}]

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.