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

15 views (last 30 days)
Rashedur Rahman on 30 Jul 2018
Commented: 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?

Image Analyst on 30 Jul 2018
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?
Rashedur Rahman on 31 Jul 2018
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.

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.
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')

KALYAN ACHARJYA on 30 Jul 2018
Rashedur Rahman on 31 Jul 2018
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.