【发布时间】:2014-11-09 10:22:50
【问题描述】:
我有一个问题:如何在 matlab 中使用 subclust() 函数和加载了 imread() 函数的图像?我有代码
rgb = imread('6_rubets.jpg');
gr = rgb2gray(rgb);
[c, s] = subclust(gr, 0.3);
我需要获取该图像上的聚类中心,结果我需要对图像上的像素进行分类。 但我有错误:
Error using .*
Integers can only be combined with integers of the same class, or scalar doubles.
Error in subclust (line 169)
dx = (thePoint - X) .* new_accumMultp;
Error in lab_1 (line 3)
[c, s] = subclust(gr, 0.3);
我需要做什么才能找到分类中心?
提前致谢
【问题讨论】:
-
你能上传图片吗?还有,你的意思是说整个help page都没有用?
-
@Dev-iL 我可以上传图片,但它是来自互联网的随机图片。填写我的代码
rgb = imread('test.jpg'); gr = rgb2gray(rgb); [c, s] = subclust(gr, 0.3); imshow(gr);,但我有错误Error using .* Integers can only be combined with integers of the same class, or scalar doubles. Error in subclust (line 169) dx = (thePoint - X) .* new_accumMultp; Error in lab_1 (line 3) [c, s] = subclust(gr, 0.3); -
而且我以前从未使用过matlab...对不起,如果我的问题看起来很愚蠢。
-
首先,请编辑问题以包含代码,而不是将其放在评论中。接下来,在提及该功能之前解释您要做什么。也许还有另一种不需要它的解决方案。
-
我无法测试它,但如果你像这样将 gr 转换为 single 会怎样:gr = single(rgb2gray(rgb));看起来 subclust 不喜欢 uint8 类型的数据,就像您的图像一样。
标签: image matlab image-processing cluster-analysis