how to do this

3 ビュー (過去 30 日間)
thelong le
thelong le 2021 年 6 月 11 日
回答済み: Kishan Dhakan 2021 年 6 月 16 日
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 Center および File ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by