I would like to know if it is possible to keep only coloured parts (for example red eyes) from a b/w image, removing all the other parts not coloured (i.e. in grayscale or black and white). I was thinking of RemoveBackground or in using

  ColorNegate@DeleteSmallComponents@MorphologicalBinarize[img, ...], 

but it removes also the coloured parts.. Any suggestions?

Thank you for your time. I really appreciate your help. Please find below an example of picture.

enter image description here

(Courtesy: https://vustudents.ning.com/profiles/blogs/the-red-focus-black-and-white-photography-with-red-focus)

  • $\begingroup$ Yes, it's possible. More people would be willing to show you how if you would provide a sample picture for people to work with. $\endgroup$ – C. E. Sep 23 '19 at 17:21
  • $\begingroup$ Sorry, C.E.. I thought I was adding it on the post, but I did not click on add at the end. $\endgroup$ – Val Sep 23 '19 at 18:05

First, let's split this image into three channels: hue, saturation, and brightness.

img = Import["https://i.stack.imgur.com/qwwmp.jpg"];
{h, s, b} = ColorSeparate[img, "HSB"]

Color separation

It turns out that the leave has a much higher saturation than the black and white background. By using Binarize, we can create a white mask for the region that the leave covers. And finally, we get this:

ImageMultiply[img, Binarize[s]]

Mathematica graphics

| improve this answer | |
  • $\begingroup$ Thanks C.E.. I did not think to separate the colour, but only to remove the background. Thank you very much. The result is awesome! $\endgroup$ – Val Sep 23 '19 at 18:35

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.