Replicate a colormap in MATLAB
5 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone
I have been asked to replicate this type of color coding based on the value of angles in spherical coordinates (see file attached) in MATLAB. How could I do it? Any advice?
0 件のコメント
回答 (2 件)
DGM
2023 年 3 月 7 日
編集済み: DGM
2023 年 3 月 7 日
I am not even remotely familiar with POV-ray, so I have no expecations or any way to verify this. That said, this is what it looks like as I wrote it:
% generate angle fields
n = 100; % page geometry
theta0 = linspace(0,360,n);
phi0 = linspace(0,180,n);
[theta phi] = meshgrid(theta0,phi0);
% generate color field
outpict = colorball2(theta,phi);
image(theta0,phi0,outpict)
That doesn't look generally useful. Given the odd reference colors and the uneven variation, I have no idea what it's supposed to be used for. Something tells me that part of this may not be intended to be done in sRGB.
If you think my interpretation is wrong, this example uses a rather literal copy of what's given.
% generate angle vectors
n = 100; % page geometry
theta = linspace(0,360,n);
phi = linspace(0,180,n);
% generate color field pointwise
outpict = zeros(n,n,3);
for r = 1:n
for c = 1:n
thisrgb = colorball(theta(c),phi(r));
outpict(r,c,:) = thisrgb;
end
end
image(theta,phi,outpict)
Attached are both function files and their supporting files.
If that's not what's expected and you have an example of what the results should look like for a full sweep, then post them.
0 件のコメント
Image Analyst
2023 年 3 月 7 日
Not sure what that does but if you're interested in a color wheel, see my attached demo.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!