Replicate a colormap in MATLAB
3 次查看(过去 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!