how to do this

1 view (last 30 days)
thelong le
thelong le on 11 Jun 2021
Answered: Kishan Dhakan on 16 Jun 2021
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);
hold on;
% plot the points
view(3); grid on;
axis equal
axis([0 1 0 1.1 0 1]);

Answers (1)

Kishan Dhakan
Kishan Dhakan on 16 Jun 2021
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);


Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by