# mask specific range of RGB color frome an image with lower and upper threshold

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.

• 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! Dec 21 '15 at 6:21
• 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. Dec 21 '15 at 10:06
• 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? Dec 21 '15 at 10:13
• the notion of a "range" or 3-channel colors is not obviously defined. Do you want each component in the specified range? Dec 21 '15 at 14:47

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 ]


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

• Thank you so much Sir.It's completely clear and useful
– Mr.E
Dec 22 '15 at 7:36