【发布时间】:2011-12-22 08:18:33
【问题描述】:
我需要在 rgb 图像上使用 kmeans 函数。算法的每个元素都需要有 3 个维度,一个用于图像的每个通道。元素的数量将是图像的像素总数。我需要在集群 #5 上使用kmeans。
这就是我尝试过的:
img = imread('mypic.jpg');
red = img(:,:,1);
green = img(:,:,2);
blue = img(:,:,3);
kmeans(red,5)
我不知道我做的对不对。我有这个错误:
??? Error using ==> plus
Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> kmeans>distfun at 704
D(:,i) = D(:,i) + (X(:,j) - C(i,j)).^2;
Error in ==> kmeans at 313
D = distfun(X, C, distance, 0);
Error in ==> mysegmentation at 9
kmeans(R,2)
谁能帮帮我?谢谢
【问题讨论】: