How to generate the hsv cone graph using Matlab?

6 visualizaciones (últimos 30 días)
Salad Box
Salad Box el 10 de En. de 2023
Respondida: Kevin Holly el 13 de En. de 2023
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.

Respuestas (1)

Kevin Holly
Kevin Holly el 13 de En. de 2023
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

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by