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?????

조회 수: 3 (최근 30일)
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개)

Guillaume
Guillaume 2014년 11월 20일
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];

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by