Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

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.