Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

how transfer ycbcr to rgb?

Asked by nadia naji

nadia naji (view profile)

on 31 Jan 2013

hi i have a vector with 3 columns that contain y, cb and cr values of ycbcr. when i use ycbcr2rgb function with this vector as a input the output values only are 0 and 1 which are wrong. can you help me why i have this problem?

0 Comments

nadia naji

nadia naji (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst

Image Analyst (view profile)

on 31 Jan 2013
Accepted answer

Perhaps this will help explain:

% Make ycbcr a double array in the range 0-1.
ycbcrD = rand(5, 3)
% rgbD will also be a double array in the range 0-1.
rgbD = ycbcr2rgb(ycbcrD)
% Make ycbcr a uint8 array in the range 0-255.
ycbcrU = randi(256, 5, 3, 'uint8') - 1
% rgb will also be a uint8 array in the range 0-255.
rgbU = ycbcr2rgb(ycbcrU)

In the command window:

ycbcrD =
         0.106652770180584          0.86869470536351         0.431413827463545
         0.961898080855054        0.0844358455109103         0.910647594429523
       0.00463422413406744         0.399782649098896         0.181847028302852
         0.774910464711502         0.259870402850654          0.26380291652199
         0.817303220653433         0.800068480224308         0.145538980384717
rgbD =
                         0                         0         0.790912791776732
                         1         0.878280165059014         0.204715266448422
                         0         0.232608552972118                         0
         0.449127212799794                         1         0.340880299518819
         0.309736381740937                         1                         1
ycbcrU =
   35  218   20
  222  159   62
  148   90   32
  141  131   47
   37  103   62
rgbU =
    0   75  204
  135  255  255
    0  247   77
   16  210  152
    0   88    0

1 Comment

nadia naji

nadia naji (view profile)

on 1 Feb 2013

thanks a lot

Image Analyst

Image Analyst (view profile)

Contact us