最新版本中缺少倍频程rgb2ntsc [英] Octave rgb2ntsc missing in latest version
本文介绍了最新版本中缺少倍频程rgb2ntsc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习一门课程,其中他们有一个样例,该样例读取图像并创建20.20像素。 有rgb2ntsc,但在最新版本的Octave中不可用。 将用什么来替代它?
推荐答案
我不知道下面是否回答了您的问题,但我使用source:
编写了代码function yiq_img = rgb2ntsc(rgb_img)
%RGB2NTSC Transform a colormap or image from red-green-blue (RGB)
% color space to luminance-chrominance (NTSC) space.
% The input may be of class uint8, uint16, single, or double.
% The output is of class double.
% https://octave.sourceforge.io/octave/function/rgb2ntsc.html
if isa(rgb_img, 'uint8') || isa(rgb_img, 'uint16') || ...
isa(rgb_img, 'double')
red = rgb_img(:, :, 1);
green = rgb_img(:, :, 2);
blue = rgb_img(:, :, 3);
y = 0.299 * red + 0.587 * green + 0.114 * blue;
i = 0.596 * red - 0.274 * green - 0.322 * blue;
q = 0.211 * red - 0.523 * green + 0.312 * blue;
yiq(:, :, 1) = y;
yiq(:, :, 2) = i;
yiq(:, :, 3) = q;
yiq_img = double(yiq);
else
error('Input image datatype is not supported')
end
end
如何确保代码正常工作?
示例:
>>> I = rgb2ntsc(imread('samur.jpeg'));
>>> imshow(I)
在哪里
已转换为:
这篇关于最新版本中缺少倍频程rgb2ntsc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文