📜  如何使用 MATLAB 将 RGB 图像转换为 YIQ 图像?

📅  最后修改于: 2022-05-13 01:54:20.139000             🧑  作者: Mango

如何使用 MATLAB 将 RGB 图像转换为 YIQ 图像?

MATLAB 中的图像处理使用图像处理工具箱中的函数。此工具箱通常将颜色表示为 RGB 数值。还存在用于以数字方式表示颜色的不同模型。这些模型的官方术语是“色彩空间”,是从向量空间的定义中创造出来的,因为它们可以映射到 2D、3D 或 4D 坐标系中。

拥有不同色彩空间并在它们之间切换的最重要优势是,它们使某些计算更方便,具体取决于用户所需的结果类型。数学变换用于在颜色空间之间进行交换。 YIQ 色彩空间用于美国的电视。该色彩空间将灰度信息与色彩数据分开,因此相同的信号可用于彩色和黑白电视机,从而提高可用性。

在本文中,我们将了解如何使用 MATLAB 将 RGB 图像转换为 YIQ。

方法:

  • 阅读 RGB 图像。
  • 使用 rgb2ntsc() 命令应用转换并转换为 YIQ 空间。
  • 将两个图像一起显示以进行比较。

示例 1:

Matlab
% Matlab Code to convert an RGB
% Image to Binary image reading image
I = imread('GFG.jpeg');
 
% Creating figure window for input image
% Displaying the input image
imshow(I);
 
% Converting the image from rgb to
% binary using thresholding
J = rgb2ntsc(I);
 
% Creating figure window for the output image
% Displaying the output image
imshow(J);


Matlab
% Matlab Code to convert an RGB Image
% to Binary image reading image
I = imread('lighthouse.png');
 
% Creating figure window for input image
% Displaying the input image
imshow(I);
 
% Converting the image from rgb to
% binary using thresholding
J = rgb2ntsc(I);
 
% Creating figure window for the output image
% Displaying the output image
imshow(J);



输出:

图 1:输入图像

图 2:输出图像

考虑另一个使用 MATLAB 内置灯塔图像的示例。

示例 2:

MATLAB

% Matlab Code to convert an RGB Image
% to Binary image reading image
I = imread('lighthouse.png');
 
% Creating figure window for input image
% Displaying the input image
imshow(I);
 
% Converting the image from rgb to
% binary using thresholding
J = rgb2ntsc(I);
 
% Creating figure window for the output image
% Displaying the output image
imshow(J);


输出 :

图 3:输入图像

图 4:输出图像

代码说明:

  • I = imread('lighthouse.png');此行读取图像
  • 显示(一);此行在图形窗口中显示输入图像 I
  • J = rgb2ntsc(I);此行将图像从 RGB 颜色空间转换为 YIQ 颜色空间。
  • 显示(J);此行在另一个图形窗口中显示输出图像 J。