RGB colour pixel plot

3 views (last 30 days)
Oliver
Oliver on 24 Sep 2011
Hello,
I am fairly new to matlab and was wondering if there is a way to create a plot with three axis on for each red green and blue which plots the values of RGB for each pixel in an image. I have the image processing toolbox but cannot work out how to do this.
Thanks for any help
Olly

Answers (3)

Image Analyst
Image Analyst on 24 Sep 2011
You could use scatter3, like I did, to produce somewhat lame 3D color scatterplots. But you're far, far better off using ImageJ ( http://rsb.info.nih.gov/ij/ ) and the color gamut inspection plugin ( http://rsb.info.nih.gov/ij/plugins/color-inspector.html ). At least until MATLAB puts in a similar capability. You can get this plug-in to work in MATLAB if you make a shortcut on your toolbar and follow these directions and put in this code:
% Windows installation instructions:
% First, download and install ImageJ from here:
% http://rsb.info.nih.gov/ij/download.html
% Then download the 3D Color Inspector plug-in for ImageJ here:
% http://rsb.info.nih.gov/ij/plugins/color-inspector.html
% and save it here:
% C:/Program Files/ImageJ/plugins/Color
%
% Now we need to enable the plug-in to work with MATLAB.
% First open your classpath file:
% C:\Program Files\MATLAB\R2011a\toolbox\local\classpath.txt
% for editing. Then add the following lines as new lines to your classpath file:
% C:/Program Files/ImageJ/ij.jar
% C:/Program Files/ImageJ/plugins/Color/Color_Inspector_3D.jar
clc; % Clear the MATLAB command window.
% User must browse for the file they want to open.
% Set up a starting/initial folder that they will start browsing from.
startingFolder = pwd; % Change to something specific if you want.
if ~exist(startingFolder, 'dir')
startingFolder = pwd;
end
% Bring up the "Open File" dialog box.
[baseFileName, folder] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','Image Files (jpg,tif,png,bmp,gif)';...
'*.*','All Files (*.*)' },'Specify image file', startingFolder);
if baseFileName ~= 0
% If they didn't click Cancel, build the full filename:
fullFileName = fullfile(folder, baseFileName)
% Now pass that into the 3D Color Inspector plugin, and you're done.
color_inspector(fullFileName)
end
Then simply click your toolbar button and you'll have an excellent color gamut inspector without having to reinvent it yourself.

Nerea Zubiaurre
Nerea Zubiaurre on 2 Mar 2012
Image Analyst, I have a question regarding this. I am working on a project where I first select some colors by clicking the image (I am not using any specific color space for the moment as I am trying many to check which one works best for me), then I create a convex hull and finally I check every pixel in the image to get to know if they correspond to the range of colors I am looking for. The project is about skin lesions and it seems this algorithm is not very effective. Do you think I could do something with the gamuts?
  3 Comments
Nerea Zubiaurre
Nerea Zubiaurre on 5 Mar 2012
Thank you Image Analyst. And where can I get the imageJ plug-in???
Image Analyst
Image Analyst on 5 Mar 2012
Read the comments in the code above. It's in the first few lines.

Sign in to comment.


Nerea Zubiaurre
Nerea Zubiaurre on 5 Mar 2012
Thanks! :)

Community Treasure Hunt

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

Start Hunting!