1
$\begingroup$

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

enter image description here

$\endgroup$
1
  • $\begingroup$ ImageApply might be useful $\endgroup$ – ssch Oct 20 '13 at 21:52
5
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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