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!