4
$\begingroup$

I'm trying to detect a specific range of RGB color from an image with the lower threshold [180.150.0] and upper threshold [255,255,150]. I am just new on Mathematica please help me with clear details.

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Commented Dec 21, 2015 at 6:21
  • 1
    $\begingroup$ You are more likely to receive help if you show what you have tried so far. I suggest you start by reading about basic image manipulation, note that RGB colour values are in the range 0-1 in Mathematica, and perhaps focus on ImageClip. $\endgroup$ Commented Dec 21, 2015 at 10:06
  • $\begingroup$ Please help us with clear details too! What do you mean by detect? Do you just want an output that says "colors in the range were found in the image" or something else? $\endgroup$ Commented Dec 21, 2015 at 10:13
  • $\begingroup$ the notion of a "range" or 3-channel colors is not obviously defined. Do you want each component in the specified range? $\endgroup$ Commented Dec 21, 2015 at 14:47

1 Answer 1

4
$\begingroup$

The obvious way to do this turns out to be very slow:

flower = ExampleData[{"TestImage", "Flower"}]; ImageApply[ If[ 180 <= #[[1]] 255 <= 255 && 150 <= #[[2]] 255 <= 255 && 0 <= #[[3]] 255 <= 150 , #, {0, 0, 0}] & , flower ] 

enter image description here

much faster to use Binarize on each channel to create a mask:

 ImageMultiply[ Binarize[ #[[1, 1]], {180/255, 1}], Binarize[ #[[1, 2]], {150/255, 1}], Binarize[ #[[1, 3]], {0, 150/255}], #[[2]]] &@ ({ColorSeparate[#], #} &)@flower 

Note that if your notion of a color being in range doesn't decouple so simply you may need to use ImageApply

$\endgroup$
1
  • $\begingroup$ Thank you so much Sir.It's completely clear and useful $\endgroup$ Commented Dec 22, 2015 at 7:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.