File Exchange

image thumbnail


version (5.33 KB) by Chad Greene
Get RGB values of any point(s) on a figure from mouse click(s)


Updated 23 Oct 2015

View License

colorpicker gets RGB values from mouse clicks anywhere on a figure. Press
Return to exit.

% Syntax
RGB = colorpicker(...)
[R,G,B] = colorpicker(...)

% Description
colorpicker gets RGB values of anywhere you click on the current figure.
Values are temporarily printed at the location of the click until you
click somewhere else or press Return to exit.

colorpicker(256) scales values from 0 to 256 rather than the Matlab
default method of scaling from 0 to 1.

colorpicker(...,TextProperty,TextValue) specifies text formatting for the
temporary RGB labels.

RGB = colorpicker(...) returns RGB values of all clicks while the color
picker is open. If only one output is requested, RGB values a an N-by-3
array, where N is the number of clicks.

[R,G,B] = colorpicker(...) returns RGB values as three individual N-by-1
arrays. I'm not sure when you'd ever need this, but it's certainly an

% Example 1: Open a figure and start clicking around to get RGB values:


% Example 2: Do the same as above, but specify label format:

% Example 3: Get 8 bit integer values:

% Example 4: Return an N-by-3 array of RGB values, where N is the number of times you click:
rgb = colorpicker;

% Example 5: Get individual R, G, and B arrays scaled from 0 to 255 and specify label formatting:
[r,g,b] = colorpicker(256,'fontangle','italic',...

Cite As

Chad Greene (2021). colorpicker (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Chad Greene

@Bech Thanks for asking! Feel free to use this one however you wish. If it makes sense to cite in your bibliography, go for it, but no worries if it's awkward. All I ask is if the colorpicker makes you filthy rich, that maybe you'll buy me a coffee or a vacation home somewhere.

Bech Tnn

Awsome, may i use it in a bigger code (app) I intend to publish in a scientific paper ? Should i Cite you only in the code description or also in the bibliography of the paper (it will be out in a long time from now)


MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!