[英]Undefined variable when using rgb2ind
I have this simple program where I'm trying to set the number of colors of an image to 1000, but I get the following error: Undefined function or variable 'rgb'.
我有一个简单的程序,试图将图像的颜色数设置为1000,但出现以下错误: Undefined function or variable 'rgb'.
I also tried with uppercase and quotes, although in the examples I found there where no quotes. 我也尝试使用大写和引号,尽管在示例中我发现那里没有引号。 I am using Matlab R2012a. 我正在使用Matlab R2012a。
clc
clear all
rgbImage = imread('peppers.png');
[rgbImage,map]=rgb2ind(RGB,1000);
The variable you're using as the first parameter to rgb2ind
is wrong. 您用作rgb2ind
的第一个参数的rgb2ind
是错误的。 You need to do: 您需要做:
[rgbImage, map] = rgb2ind(rgbImage, 1000);
My guess is that you consulted the MATLAB documentation on rgb2ind
and you literally took the first parameter to be substituted as RGB
. 我的猜测是,您查阅了有关rgb2ind
的MATLAB文档,并且确实采用了第一个要替换为RGB
参数。 The documentation clearly says that RGB
is an image loaded into MATLAB. 该文档明确指出RGB
是加载到MATLAB中的图像 。 This is not a constant. 这不是一个常数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.