how to do this

1 次查看(过去 30 天)
thelong le
thelong le 2021-6-11
I want my input data to be an image that has been converted to XYZ color space to represent on color space instead of having to enter input data, please help me, thanks!
my code ( input data is entered manually )
How do I make the input data an image that has been converted to XYZ space?
% generate two clusters of color points
rgb = min(abs(randn(2000,3).*[0.5 0.3 0.1] + [0 0 0]),1);
rgb = [rgb; 1-rgb];
xyz = rgb2xyz(rgb);
xlabel('X');
ylabel('Z');
zlabel('Y');
hold on;
% plot the points
scatter3(xyz(:,1),xyz(:,3),xyz(:,2),10,rgb,'.');
view(3); grid on;
axis equal
axis([0 1 0 1.1 0 1]);
set(gca,'color','k','gridcolor','k','gridalpha',0.3)
set(gca,'projection','perspective');

回答(1 个)

Kishan Dhakan
Kishan Dhakan 2021-6-16
To convert an image to an XYZ space (or, an m-by-n-by-3 array which RGB color space uses, according to here), you can use the imread function:
X = X = im2double(imread('images.jpg'));
R = X(:,:,1); % Only Red channel
G = X(:,:,2); % Only Green Channel
B = X(:,:,3); % Only Blue Channel
Then, you can easily continue with rgb2xyz(X);

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by