MATLAB Answers

0

How can I convert RGB image to NTSC without using 'rgb2ntsc' command?

Asked by Rashedur Rahman on 30 Jul 2018
Latest activity Commented on by Rashedur Rahman on 31 Jul 2018
I tried the following code. But it did not give me the same output as 'rgb2ntsc'.
%RGBImage is the rgb image which is a m*n*2 matrix
YIQ(:,:,1) = (0.299.*(RGBImage(:,:,1)) + 0.587.*(RGBImage(:,:,2)) + 0.114.*(RGBImage(:,:,3)));
YIQ(:,:,2) = (0.596.*(RGBImage(:,:,1)) - 0.274.*(RGBImage(:,:,2)) - 0.322.*(RGBImage(:,:,3)));
YIQ(:,:,3) = (0.211.*(RGBImage(:,:,1)) - 0.523.*(RGBImage(:,:,2)) + 0.312.*(RGBImage(:,:,3)));
How can I convert RGB image to NTSC without using 'rgb2ntsc' command?

  2 Comments

Looks like the right formula, according to wikipedia. How much are they off? Do you want to attach your RGB image? And your code to show how they are different?
These are the images. NTSCbyCode.bmp is converted by the code mentioned above. NTSCbyMatlab.bmp is converted by MATLAB built-in function. rgbimage.bmp is the original image.

Sign in to comment.

1 Answer

Answer by KALYAN ACHARJYA on 30 Jul 2018

%You are using the correct approach. The answer is the same in both approaches, I have verified, can you share the RGB image, which you have checked.
RGBImage=imread('frame_32.jpg');
YIQ(:,:,1) = (0.299.*(RGBImage(:,:,1)) + 0.587.*(RGBImage(:,:,2)) + 0.114.*(RGBImage(:,:,3)));
YIQ(:,:,2) = (0.596.*(RGBImage(:,:,1)) - 0.274.*(RGBImage(:,:,2)) - 0.322.*(RGBImage(:,:,3)));
YIQ(:,:,3) = (0.211.*(RGBImage(:,:,1)) - 0.523.*(RGBImage(:,:,2)) + 0.312.*(RGBImage(:,:,3)));
subplot(121), imshow(YIQ);title('Without rgb2ntsc')
subplot(122), imshow(rgb2ntsc(RGBImage));title('Using rgb2ntsc')

  2 Comments

Thank you very much for your help. I have attached my files in the above comment. The image looks same, but the values are not the same.

Sign in to comment.