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.
1 Answer
$\begingroup$ $\endgroup$
1 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
- $\begingroup$ Thank you so much Sir.It's completely clear and useful $\endgroup$Mr.E– Mr.E2015-12-22 07:36:08 +00:00Commented Dec 22, 2015 at 7:36

ImageClip. $\endgroup$