필터 지우기
필터 지우기

Better "probabilities"?

조회 수: 24 (최근 30일)
Roger Breton
Roger Breton 2024년 5월 13일 18:05
댓글: Roger Breton 2024년 5월 21일 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)];

답변 (1개)

John D'Errico
John D'Errico 2024년 5월 13일 18:24
편집: John D'Errico 2024년 5월 13일 19:40
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
Roger Breton
Roger Breton 2024년 5월 14일 21:03
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 2024년 5월 21일 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by