Clear Filters
Clear Filters

How to threshold a color range in image processing[HSV]?

4 views (last 30 days)
I want to selectively choose a specific color set from an image and set all the other values that don't fall in this range as zero like the one in the colorThresholder App (but that is an app, i need a function or a code segement)
I can choose a specific set of values as shown below
Consider a range defined by the vairables min and max as min = [h1 s1 v1] and max = [h2 s2 v2] now i want an image to let all the values in this color set(i.e. hue from h1->h2, similarly s1->s2 and v1->v2) to be set as 1 and the rest to be set as 0s. Previously i was able to achieve this in python using the following code: x = cv2.inRange(inputimage, min, max) I have been searching for and equivalent function and even trying to make my own but to no avail I would be grateful if someone can help me out.

Answers (1)

Image Analyst
Image Analyst on 18 Jan 2018
Grab the blue handles and move the threshold bars to segment the image the way you want. Then click on the Export button and select Export Function.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!