Magnification of a colored image through two color space: RGB & YCbCr I have tried to magnify a colored image using bicubic method. I did this in two ways; First, I resize R, G, and B parts of it. Second, I transformed RGB to YCbCr color space and then resized Y, Cb, and Cr parts of it. When I use YCbCr color space, final image changes in color but not in whole shape of the image. I could not realize the reason. May you help me?

code:

clear all
clc

A=imread('Sun.jpg');
R=A(:,:,1);
G=A(:,:,2);
B=A(:,:,3);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Y  = 0.257.*R + 0.504.*G + 0.098.*B + 16;
Cb = -0.148.*R - 0.291.*G + 0.439.*B + 128;
Cr = 0.439.*R - 0.368.*G - 0.071.*B + 128;

Y1  = imresize(Y, 2, 'bicubic');
Cb1 = imresize(Cb, 2, 'bicubic');
Cr1 = imresize(Cr, 2, 'bicubic');

R1 = 1.164.*(Y1-16) + 1.596.*(Cr1-128);
G1 = 1.164.*(Y1-16) - 0.813.*(Cr1-128) - 0.391.*(Cb1-128);
B1 = 1.164.*(Y1-16) + 2.018.*(Cb1-128); 

A1 = cat(3,R1,G1,B1);

imwrite(A1,'Sun1.jpg');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R2=imresize(R, 2, 'bicubic');
G2=imresize(G, 2, 'bicubic');
B2=imresize(B, 2, 'bicubic');

A2 = cat(3,R2,G2,B2);

imwrite(A2,'Sun2.jpg');


Original image:


Resized image(YCbCr color space):
I have checked your code and it worked fine in my matab 6.0 implementation with the following lines of of modification: 

A=double(imread('Sun.jpg'));  % convert uint8 data to double
...                           % further operations here
A1(A1(:)&lt;0.0) = 0.0;          % check and correct out of range values
A1(A1(:)&gt;255.0) = 255.0;      % check and correct out of range values
imwrite(A1/255.0,'Sun1.jpg'); % while writing the data of class double use [0,1] data range 


According to this, as I said you must deal with numerical issues such as an out of range value.