MATLAB Answers

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

29 views (last 30 days)
Rashedur Rahman
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?
  2 Comments
Rashedur Rahman
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.

Sign in to comment.

Answers (1)

KALYAN ACHARJYA
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')

Community Treasure Hunt

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

Start Hunting!