MATLAB Answers

Help regarding the Munsell and Kubelka-Munk Toolbox - RGB to Munsell conversion

9 views (last 30 days)
Kyop on 23 Nov 2020
Commented: Kyop on 23 Nov 2020
I am currently having trouble, and in need of help.
For some project of mine I am trying to use the Munsell and Kubelka-Munk Toolbox that can be found here .
Basically I am trying to convert an rgb combination into a Munsell specification.
However I am retrieving the following error :
"ERROR: No optimal colour file for Illuminant C.
Output argument "InsideLimits" (and maybe others) not assigned during call to "IsWithinMacAdamLimits"."
And as I am very new in the colored image analysis domain, I have no clue as to why am I retrieving such error from the IsWithinMacAdamLimits function.
%some random red picture
sample = imread('my_image_test.jpg');
%Retrieve the averaged rgb data for simplification of the case
r = mean(mean(sample(:,:,1))); g = mean(mean(sample(:,:,2))); b = mean(mean(sample(:,:,3)));
rgb = round([r,g,b]);
%Get the routine to work
[MunsellSpec, MunsellVec, InMacAdamLimitsFlag, Status] = sRGBtoMunsell(rgb);
I would be glad if someone had some insight as to where am I doing things wrong.
Feel free to incquire more information or underline somethings I am not clear about (this is my first time posting on the mathworks forum, so I don't really know the conventions in details).
Thank you for reading me,
I know this not a question directly related to Matlab, but probably more related to the fields of colors, but I hoped that perhaps someone already worked with such concepts or even with the toolbox I mentionned.


Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 23 Nov 2020
Edited: Stephen Cobeldick on 23 Nov 2020
The function sRGBtoMunsell calls the function xyYtoMunsell which calls the function IsWithinMacAdamLimits . The author wrote some unusual "features" in the code, such as using disp and return instead of actual error or assert calls... but that "error" message (which is not really an error, just some displayed text) is easy to find on line 161. The code around that point makes it clear that the function must load a file named 'OptimalColoursForIlluminantC.txt', and such a file is listed on the page which you linked to. So basically you get the "error" because you are missing a file which that function needs.
Solution: download OptimalColoursForIlluminantC.txt from that page and put in the same location as where you saved those Mfiles.

  1 Comment

Kyop on 23 Nov 2020
I see,
I did think that a file was missing at some point but didn't find it when I searched in the code, I guess I didn't look well enough.
Thank you very much for your quick reply and your help!

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!