Why is Matlab not setting the RGB colors properly?

I'm trying to change the color settings for my Matlab (R2013A). For example, see this link here. I issue a command:
com.mathworks.services.Prefs.setColorPref('ColorsBackground',
...java.awt.Color(39/255,40/255,34/255))
com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsBackground');
which should set my background to rgb(39/255,40/255,34/255). However, it is much too light. I've checked in Photoshop, and the color is off. In the picture, you see on the top the Matlab command window with the color, which PS puts at rgb(51,52,45)/255. On the bottom right, you see my other editor (Sublime Text) which has a true (39,40,34)/255 scheme, and which is darker.
Any ideas what is the issue?

4 Comments

Theo - what does the following return
com.mathworks.services.Prefs.getColorPref('ColorsBackground')
Do the red, green and blue results match your input colour?
Also, remember that this is unsupported functionality within MATLAB and so may not work as intended. If I run your two lines of code, I don't observe any changes to the background colour..even though my call to com.mathworks.services.Prefs.getColorPref('ColorsBackground') indicates that
ans =
java.awt.Color[r=39,g=40,b=34]
Geoff: Thanks for getting back to me. Running the command indeed verifies the same ans as you (39,40,34), even though as I say, the background color is not that combination (verified in Photoshop).
Did you say that putting in my two commands (which, by the way, had the three dots in the wrong location):
com.mathworks.services.Prefs.setColorPref('ColorsBackground',java.awt.Color(39/255,40/255,34/255));
com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsBackground');
your background window didn't change?
Kind of silly, but is there a way for me to use Matlab to load in a JPEG of the true (39,40,34) color to see what I should be setting the java.awt.Color option to be?
Theo - there was no change to the background colour when I ran the two lines. I'm running R2014a on OS X so that could be why it didn't work.
As for loading an image, you could just create one with the desired colour
bg = uint8(zeros(500,500,3));
bg(:,:,1) = 39;
bg(:,:,2) = 40;
bg(:,:,3) = 34;
image(bg)
By the way, you can initialize the red when you instantiate and also set the class, uint8, at the same time:
rgbImage = 39 * ones(600,400,3, 'uint8'); % All 39 to start with
rgbImage(:,:,2) = 40; % Set green channel
rgbImage(:,:,3) = 34; % Set blue channel
image(rgbImage);

Sign in to comment.

Answers (0)

Categories

Asked:

on 13 Sep 2014

Commented:

on 14 Sep 2014

Community Treasure Hunt

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

Start Hunting!