How to generate the hsv cone graph using Matlab?
7 次查看(过去 30 天)
显示 更早的评论
Hi
I saw the hsv cone graph on Mathworks webpage
I am wondering how to generate this graph using Matlab.
Any advices would be great. Doesn't have to be the full code.
0 个评论
回答(1 个)
Kevin Holly
2023-1-13
Here is a starting point. I made some modifications from this code:
H = repmat(linspace(0, 1, 100), 100, 1); % 100-by-100 hues
S = repmat([linspace(0, 1, 50) ... % 100-by-100 saturations
linspace(1, 0, 50)].', 1, 100); %'
V = repmat([ones(1, 50) ... % 100-by-100 values
linspace(1, 0, 50)].', 1, 100); %'
hsvImage = cat(3, H, S, V); % Create an HSV image
C = hsv2rgb(hsvImage); % Convert it to an RGB image
% Next, create the conical surface coordinates:
theta = linspace(0, 2*pi, 20); % Angular points
X = [zeros(1, 20); ... % X coordinates
cos(theta); ...
zeros(1, 20)];
Y = [zeros(1, 20); ... % Y coordinates
sin(theta); ...
zeros(1, 20)];
Z = [2.*ones(2, 20); ... % Z coordinates
zeros(1, 20)];
% Finally, plot the texture-mapped surface:
figure
surf(X, Y, Z, C, 'FaceColor', 'texturemap');
axis equal
figure
surf(X(:,1:16), Y(:,1:16), Z(:,1:16), C(1:80,1:80,:), 'FaceColor', 'texturemap');
axis equal
view(30,32) % Adjust camera angle
hold on
patch(X(:,16), Y(:,16), Z(:,16),C(80,80,:)) % add interior purple face
patch(X(:,1), Y(:,1), Z(:,1),[1 0 0]) % add interior red face
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!