matlab 2014b问题:错误使用 repmat问题:复制因子必须为整数行矢量或整数标量。

seg = GaborTextureSegment(I, K, gamma, Lambda, b, Theta, phi, shape);
%imseg = uint8(seg) * floor(255 / K); % cluster id to gray scale (max 255)
[nRow, nCol] = size(seg);
color = [0 0 0; 255 255 255; 255 0 0; 0 255 0; 0 0 255]; % 5 colors reserved
imseg = zeros(nRow*nCol, 3);
for i=1:K
idx = find(seg == i);
imseg(idx, :) = repmat(color(i, :), [], length(idx));
%repma复制个数组

错误使用 repmat
复制因子必须为整数行矢量或整数标量。

出错 demo_GaborTextureSegment (line 22)
imseg(idx, :) = repmat(round(color(i, :)), round([]), round(length(idx)));

第1个回答  2019-12-05
不知道你还不需要解决,此问题的原因是数组对应错误,改成如下即可:
imseg(idx, :) = repmat(color(i, :), length(idx),1);
相似回答