在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);
原文:
最满意答案
试图对抗像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#没有宏?(Why aren't there macros in C#?)[2023-09-21]
从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", $ ...
-
在C#中模拟打开Excel(Emulate Open Excel in C#)[2023-01-15]
如果不先打开工作簿,则无法设置“计算”属性。 这听起来像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 ... -
在C#中模拟IDispatchEx(Emulate IDispatchEx in C#)[2022-04-23]
那么,你可以为你的“新”方法创建一个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强 ...
-
什么是宏?(What are macros?)[2022-05-08]
在这里,您可以找到所需的一切: 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 ...
-
Little Endian Macros(Little Endian Macros)[2022-05-03]
您需要包含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 ...