简体   繁体   English

rgb2gray中的错误:MAP必须是amx 3数组

[英]Error in rgb2gray: MAP must be a m x 3 array

I am doing image segmentation of round objects that have similar color to their background. 我正在对颜色与背景颜色相似的圆形对象进行图像分割。 The image is RGB but the RGB values give tones of gray, notice even though the image looks gray it is not in grayscale. 图像是RGB,但是RGB值给出灰色调,请注意,即使图像看起来是灰色,也不是灰度。 In the segmentation process I have to apply gradient filters and opening and closing by reconstruction in order to separate the round objects from the background before making the binary mask that I will use for segmentation. 在分割过程中,我必须应用渐变过滤器并通过重构来打开和关闭,以便在制作将用于分割的二进制蒙版之前将圆形对象与背景分离。 Some of the functions I used in this process accept 2D arrays inputs only. 我在此过程中使用的某些功能仅接受2D数组输入。 In fact, binarization of the image itself can only be done in 2D array inputs, not in RGB images which are a 3D array. 实际上,图像本身的二值化只能在2D阵列输入中完成,而不能在3D阵列的RGB图像中完成。 So, I am trying to convert my RGB image which looks gray but is not in grayscale before doing anything else. 因此,在尝试执行其他操作之前,我正在尝试转换看起来是灰色但不是灰度的RGB图像。 But, I get the following error form MATLAB when I use the rgb2gray function: Error using rgb2gray>parse_inputs (line 77) MAP must be amx 3 array. 但是,当我使用rgb2gray函数时,从MATLAB中得到以下错误:使用rgb2gray> parse_inputs时出错(第77行)MAP必须为amx 3数组。

Error in rgb2gray (line 52) [X, threeD] = parse_inputs(X); rgb2gray中的错误(第52行)[X,threeD] = parse_inputs(X);

Error in Mask_Biophysics (line 2) Frame= rgb2gray(rgb); Mask_Biophysics错误(第2行)Frame = rgb2gray(rgb);

Does anyone know what this error means and how to fix it ? 有谁知道此错误的含义以及如何解决? This is the part of the code that is giving me the error: 这是给我错误的代码部分:

rgb= imread('kids.tif'); rgb = imread('kids.tif'); Frame= rgb2gray(rgb); 框架= rgb2gray(rgb);

Notice I am using a pre installed matlab image "kids.tif", So, the error has nothing to do with my particular image. 注意,我使用的是预先安装的matlab映像“ kids.tif”,因此,该错误与我的特定映像无关。 kids.tif is an RGB color image in matlab kids.tif是Matlab中的RGB彩色图像

tif files (at least 'kids.tif' ) are 2D index matrices with colormap and not 3D (RGB) matrices. tif文件(至少是'kids.tif' )是带有颜色映射的2D索引矩阵,而不是3D(RGB)矩阵。 rgb2gray accepts 3D RGB matrices or 2D index matrix with its matching colormap. rgb2gray接受具有匹配rgb2gray 3D RGB矩阵或2D索引矩阵。 try: 尝试:

[rgb,cmap]= imread('kids.tif');
Frame= rgb2gray(rgb,cmap);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM