How to threshold a color range in image processing[HSV]?
4 views (last 30 days)
Show older comments
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169053/image.jpeg)
I can choose a specific set of values as shown below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169055/image.jpeg)
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.
0 Comments
Answers (1)
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.
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!