File Exchange

image thumbnail

Color Threshold

Allows users to interactively select/deselect pixels to threshold images using RGB or HSV filters.

9 Ratings



View License

Quickly setting RGB or HSV values for color thresholding is a common problem in laboratory robotics. ColorThreshold.m allows you to load an image and interactively set either RGB or HSV thresholds. Call the function ColorThreshold('image_name'), select your Region Of Interest, then select and deselect pixels and watch the thresholded image and RGB/HSV scatter plots to fine tune your threshold filter. You can switch between HSV and RGB while the program is running, and can choose to split the Hue threshold (single color objects commonly have a wraparound in the Hue value). The update allows users to interactively tune their filters with slider bars and move the ROI.

Comments and Ratings (10)

Image Analyst

Image Analyst (view profile)

This functionality is now built into MATLAB. See the Color Thresholder app on the Apps tab of the tool ribbon, if you have the Image Processing Toolbox.


XiaoLong LI

Thank you for your wonderful work,very useful!

Thx,very useful!


Aasd (view profile)


maida (view profile)

will you kindly turn this code to recognize the color of ROI.. or somebody who can do this plz mail me at


Kenz (view profile)

Interesting idea, but fails majorly due to leftover non-standard RGB2HSV calculation. The code needs to be fixed to use Matlab's rgb2hsv, and then possibly offer the non-standard one as an interesting case for a faster, less processor-intensive calculation.

Muhammed Talu

Very useful

Great :)



Allow user to move the ROI and error checking


The update allows users to interactively tune their filters with slider bars.

MATLAB Release
MATLAB 7.3 (R2006b)

Inspired: Buoy Detection Using Simulink

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today