首页 \ 问答 \ 在matlab中为kmeans聚类提供了哪些图像数据?(What data of images are given to kmeans clustering in matlab?)

在matlab中为kmeans聚类提供了哪些图像数据?(What data of images are given to kmeans clustering in matlab?)

我在我的数据库中有100个图像。我使用这100个图像作为训练集和测试图像。我必须制作5个簇。我使用特征面(PCA)进行特征提取。应该在matlab中给出kmeans命令的数据?

kmeans命令的语法:

[IDX,C] = kmeans(X,k)

1.什么是X值?

2.我们是否必须将欧几里德距离作为输入?

3.我们是否必须给出输入图像的权重向量?

请详细解释我。

源代码我试过

X = []
    srcFiles = dir('C:\Users\rahul\Desktop\tomorow\*.jpg');  % the folder in which ur images exists
for i = 1 : length(srcFiles)
    filename = strcat('C:\Users\rahul\Desktop\tomorow\',srcFiles(b).name);
    Imgdata = imread(filename);
    X(:,  i) = princomp(Imgdata); 
end
[idx, c] = kmeans(X, 5)

我得到的错误:

指数超过矩阵维度。 pca(第4行)中的错误filename = strcat('C:\ Users \ rahul \ Desktop \ tomorow \',srcFiles(b).name);


Iam having 100 images in my database.Iam using those 100 images as both training set and also test images.I have to make 5 clusters.Iam using eigen faces(PCA) for feature extraction.What data should be given for kmeans command in matlab?

Syntax for kmeans command:

[IDX,C] = kmeans(X,k)

1.What is the X value?

2.Whether we have to give euclidian distance as input?

3.Whether we have to give weight vector of input images?

Please explain me in detail.

Source code i tried

X = []
    srcFiles = dir('C:\Users\rahul\Desktop\tomorow\*.jpg');  % the folder in which ur images exists
for i = 1 : length(srcFiles)
    filename = strcat('C:\Users\rahul\Desktop\tomorow\',srcFiles(b).name);
    Imgdata = imread(filename);
    X(:,  i) = princomp(Imgdata); 
end
[idx, c] = kmeans(X, 5)

Error iam getting:

Index exceeds matrix dimensions. Error in pca (line 4) filename =strcat('C:\Users\rahul\Desktop\tomorow\',srcFiles(b).name);


原文:
更新时间:2022-08-04 08:08

最满意答案

试图对抗像C#这样的语言的语法是一个糟糕的主意。 你使用的工具将会有决心的反击。

顺其自然,不要试图逆流而动。 您很快就会习惯语法,并且对使用该代码的其他人都有意义。


Trying to fight the syntax of a language like C# is simply a bad idea. The tools you use will fight back with determination.

Just go with the flow and stop trying to swim against the current. You'll soon get used to the syntax and it will make sense to everyone else who works with the code.

相关问答

更多
  • 从C#faq。 http://blogs.msdn.com/CSharpFAQ/archive/2004/03/09/86979.aspx 为什么C#不支持#define宏? 在C ++中,我可以定义一个宏,如: #define PRODUCT(x, y, z) x * y * z 然后在代码中使用它: int a = PRODUCT(3, 2, 1); C#不允许你这样做。 为什么? 有几个原因。 第一个是可读性之一。 C#的主要设计目标之一就是保持代码的可读性。 具有编写宏的能力使程序员能够创建自己的语 ...
  • 我想创建一个具有多个参数的宏,就像$ display一样。 你不能。 Verilog和SystemVerilog不支持可变宏 。 如果你的目标是使用它来格式化字符串或输出,并且你想避免在所有地方输入$sformat ,这是一个解决方法。 您可以将宏定义为具有单个参数 ,并将该参数与$sformat结合使用。 这样做的注意事项是,使用宏时必须将参数包含在括号中。 请注意, $sformatf的()不是宏的一部分: `define format_macro(A) \ $write("%s", $ ...
  • 如果不先打开工作簿,则无法设置“计算”属性。 这听起来像Catch 22,但它实际上并不是你想要阻止的“计算” - 你只是不希望它更新链接到外部源的单元格。 Open方法采用可选的UpdateLinks参数。 将此设置为false,您应该没问题。 You can't set the Calculation property without first opening the workbook. This sounds like Catch 22, but it's not actually the 'cal ...
  • 那么,你可以为你的“新”方法创建一个DynamicMethod实例,但是在运行时将它们静态地附加到现有的实例将不起作用,因为它不会被编译。 你可能 (我还没有尝试过)能够将操作码发送到内存中的程序集,但是这可能会远离“语法上的甜蜜”(可能会涉及到大量的反射和InvokeMember调用,我会想) 它也可能值得研究扩展方法 - 尽管我从来没有尝试通过扩展方法附加事件或类似事件的方法......并且它们只有3.5,所以这可能会限制你。 最好看,“纯C#”实现可能是非常类似于你已经有了通用/接口设置... 老实说 ...
  • 请改用新的log4net XXXXFormat方法。 它们以这种方式实现: public virtual void DebugFormat(string format, params object[] args) { if (this.IsDebugEnabled) { this.Logger.Log(declaringType, m_levelDebug, String.Format(format, args)); } } 此外,您将拥有String.Format强 ...
  • 在这里,您可以找到所需的一切: http : //gcc.gnu.org/onlinedocs/cpp/Macros.html 但是为了得到一个基本的想法,它们是代码片段,当你在代码中编写宏代码时,它们会取代宏名称。 在您的示例中,如果您写道: int i = CCRANDOM_0_1(); 它将是相同的: int i = ((random() / (float)0x7fffffff )); Here you'll find everything you need: http://gcc.gnu.or ...
  • 通过快速搜索我发现了这一点 ,它可能有所帮助。 更新:将以下内容添加到我的.csproj项目文件后,我可以使用PluginPath作为后置构建命令行中的宏,并使用copy "$(TargetPath)" "$(PluginPath)\$(ConfigurationName)" (在Visual Studio 2008) ... C:\apps\ With a quick search I found thi ...
  • 使用您选择的脚本语言,注释掉所有#include ,然后运行gcc -E -Wp,-P,-C,-CC foo.c然后取消注释#include s。 或者你可以将#include替换为一些不以#开头的字符串...例如, include#或@include ; 可能性是无止境。 使用@而不是#使您可以完全控制哪些预处理程序指令执行和不扩展...编码您不希望使用@扩展的代码,然后脚本只运行gcc -E然后更改@到# 。 但是,我认为最好以相反的方式进行,使用特殊标记(例如@ )来表示可扩展的宏。 然后脚本会将#s ...
  • 您需要包含endian.h标头。 You need to include the endian.h header.
  • 试图对抗像C#这样的语言的语法是一个糟糕的主意。 你使用的工具将会有决心的反击。 顺其自然,不要试图逆流而动。 您很快就会习惯语法,并且对使用该代码的其他人都有意义。 Trying to fight the syntax of a language like C# is simply a bad idea. The tools you use will fight back with determination. Just go with the flow and stop trying to swim a ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)