Effacer les filtres
Effacer les filtres

Better "probabilities"?

7 vues (au cours des 30 derniers jours)
Roger Breton
Roger Breton le 13 Mai 2024
Commenté : Roger Breton le 21 Mai 2024 à 13:48
I created a small script in which I present two random colors to the user. See attached script.
As you can see, on the left, are the two RGB colors calculated using "rand" function. On the left is the colors plotted on an CIE ab diagram. I intend to use this script with my students to discuss "Color Harmonies". This is a "diad". Next up, is a "trad".
First question
What I'd like to know is how "effective" is the rand function? Would there be more "advanced" ways of coming up with those two colors?
The motivation behind this script is to get the students thinking "outside of the box", to move them away from getting "inspiration" from all kinds of "real-world" objects and only look at the "sensation" produced b the colors.
Second question
I would like to explore generating random colors from my Munsell Book of Color 1600 measured CIE Lab colors. This is how I bring in my Munsell color data from an Excel file:
% Import TAB-delimited file
file_path = 'Munsell Glossy All Colors Extracted (2024 03 21) TAB.txt';
my_table = readtable(file_path, 'Delimiter', '\t', 'ReadVariableNames', false);
MunsellNotationTMP = my_table{:, 1}; % Text data
MunsellNotation = string(MunsellNotationTMP);
HVCcolumns_Lab = my_table{:, 2:4}; % Numeric data
HVC_Lab = [HVCcolumns_Lab(:, 1), HVCcolumns_Lab(:, 2), HVCcolumns_Lab(:, 3)];

Réponses (1)

John D'Errico
John D'Errico le 13 Mai 2024
Modifié(e) : John D'Errico le 13 Mai 2024
How effective is rand? I'm not sure what you mean by "effective", or for that matter, "advanced". It is a state of the art random number generator. So no, you cannot do better in terms of randomness, and what you did with it seems reasonable. Perhaps only with the caveat that you could, randomly, have two colors that were very near each other, even indistinguishable to the eye. I don't know if that is an issue. If it was, then you could test to see if the distance (in terms of Euclidean distance when mapped to L*a*b* perhaps) between the two colors generated is too small, and if so, then generate a new set until you get colors that are significantly different.
Anyway, in terms of randomness, literally any random number generator would arguably be sufficient for a simple problem like this. You don't need sophistication.
Your second question is not a question at all, as it looks like you stopped writing before you asked anything. You read in a set of Munsell colors. Then what? Are you looking to choose randomly from that set? RANDI might be useful then, to choose a random index into that set.
  8 commentaires
Roger Breton
Roger Breton le 14 Mai 2024
Solved my problem. I cheated a lot, using global variables but the final product is fine. I'm satisfied.
Now I can experiment with selecting Munsell colors at random :-)
Roger Breton
Roger Breton le 21 Mai 2024 à 13:48
The randi() function seems to yield more interesting pairs of Munsell colors than the randperm() I was using before. Still have to look at your code, William? I understand the idea of sampling the CIE Lab color space more evenly.

Connectez-vous pour commenter.


En savoir plus sur Tables dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by