Replicate a colormap in MATLAB

조회 수: 5 (최근 30일)
Richard Wood
Richard Wood 2023년 3월 7일
편집: DGM 2023년 3월 7일
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?

답변 (2개)

DGM
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.

Image Analyst
Image Analyst 2023년 3월 7일
Not sure what that does but if you're interested in a color wheel, see my attached demo.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by