i want to convert an image from rgb to xyz and want to get the values of x and y and z separately. so i am having a problem. how can i encounter the problem?????
2 views (last 30 days)
Show older comments
RGB = [255; 255; 255 ];
rRGB=RGB(:,:,1);
gRGB=(RGB(:,:,2)./RGB(2)) * 100;
bRGB=RGB(:,:,3);
M = [0.4124564 0.3575761 0.1804375
0.2126729 0.7151522 0.0721750
0.0193339 0.1191920 0.9503041] ;
X = rRGB * 0.4124564 + gRGB * 0.2126729 + bRGB* 0.0193339;
Y = rRGB * 0.3575761 + gRGB * 0.7151522 + bRGB* 0.1191920;
Z= rRGB * 0.0193339 + gRGB * 0.1191920 + bRGB* 0.9503041 ;
so when i am running the programme i am getting this error
??? Index exceeds matrix dimensions.
Error in ==> pd at 3 gRGB=RGB(:,:,2)./RGB(2);
by d way when i am putting RGB=imread('F:\47.jpg', 'jpg') then i m getting a result..... what is the problem in the code???
1 Comment
Answers (1)
Guillaume
on 20 Nov 2014
Your RGB is a 3x1x1 matrix. There's only one valid value for the index in the third dimension (1), so
RGB(:, :, 2)
RGB(:, :, 3)
are both invalid.
Probably, you meant to declare RGB as
RGB(1, 1, :) = [255 255 255];
See Also
Categories
Find more on Blue 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!