社区
机器视觉
帖子详情
matlab中find函数如何用C++实现
cy_543
2014-08-25 03:30:55
[m,n]=find(IMG<=1);
integerCoord=[m,n];
这是matlab函数,轻松就能获取 IMG中所有等于1的点的坐标。那么在C++里怎么实现呢?安装有opencv库
首先,我知道 无法直接用opencv里的一个函数来实现。
其他,要得到所有点的坐标,而不是只有一个。
如果要写一个 能实现此功能的代码,该怎么写呢?
...全文
319
回复
打赏
收藏
matlab中find函数如何用C++实现
[m,n]=find(IMG<=1); integerCoord=[m,n]; 这是matlab函数,轻松就能获取 IMG中所有等于1的点的坐标。那么在C++里怎么实现呢?安装有opencv库 首先,我知道 无法直接用opencv里的一个函数来实现。 其他,要得到所有点的坐标,而不是只有一个。 如果要写一个 能实现此功能的代码,该怎么写呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Matlab
中
峰值计算
函数
findpeaks()的
c++
源码导出(附.m源码、导出步骤说明及导出的
c++
源码)
寻找峰值算法应用广泛,
matlab
的峰值计算
函数
findpeaks()可设置峰值间隔、峰值门限、峰值宽度等等参数,非常好用。压缩包
中
包含
matlab
中
的findpeaks()
函数
的所有输入参数说明、.m源码、详细导出步骤以及导出的
c++
源码。 注:findpeaks()
函数
只支持查找波峰,如果需要查找波谷,请先取反再调用该
函数
。
c++
find
函数
功能.zip
c++
与opencv结合编写find
函数
,
实现
与
matlab
中
find相同的功能。
svm
matlab
版本
need to conduct installation. If you have modified the sources and would like to re-build the package, type 'mex -setup' in
MATLAB
to choose a compiler for mex first. Then type 'make' to start the installation. Starting from
MATLAB
7.1 (R14SP3), the default MEX file extension is changed from .dll to .mexw32 or .mexw64 (depends on 32-bit or 64-bit Windows). If your
MATLAB
is older than 7.1, you have to build these files yourself. Example:
matlab
> mex -setup (ps:
MATLAB
will show the following messages to setup default compiler.) Please choose your compiler for building external interface (MEX) files: Would you like mex to locate installed compilers [y]/n? y Select a compiler: [1] Microsoft Visual C/
C++
version 7.1 in C:\Program Files\Microsoft Visual Studio [0] None Compiler: 1 Please verify your choices: Compiler: Microsoft Visual C/
C++
7.1 Location: C:\Program Files\Microsoft Visual Studio Are these correct?([y]/n): y
matlab
> make Under 64-bit Windows, Visual Studio 2005 user will need "X64 Compiler and Tools". The package won't be installed by default, but you can find it in customized installation options. For list of supported/compatible compilers for
MATLAB
, please check the following page: http://www.mathworks.com/support/compilers/current_release/ Usage =====
matlab
> model = svmtrain(training_label_vector, training_instance_matrix [, 'libsvm_options']); -training_label_vector: An m by 1 vector of training labels (type must be double). -training_instance_matrix: An m by n matrix of m training instances with n features. It can be dense or sparse (type must be double). -libsvm_options: A string of training options in the same format as that of LIBSVM.
matlab
> [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model [, 'libsvm_options']); -testing_label_vector: An m by 1 vector of prediction labels. If labels of test data are unknown, simply use any random values. (type must be double) -testing_instance_matrix: An m by n matrix of m testing instances with n features. It can be dense or sparse. (type must be double) -model: The output of svmtrain. -libsvm_options: A string of testing options in the same format as that of LIBSVM. Returned Model Structure ======================== The 'svmtrain' function returns a model which can be used for future prediction. It is a structure and is organized as [Parameters, nr_class, totalSV, rho, Label, ProbA, ProbB, nSV, sv_coef, SVs]: -Parameters: parameters -nr_class: number of classes; = 2 for regression/one-class svm -totalSV: total #SV -rho: -b of the decision function(s) wx+b -Label: label of each class; empty for regression/one-class SVM -ProbA: pairwise probability information; empty if -b 0 or in one-class SVM -ProbB: pairwise probability information; empty if -b 0 or in one-class SVM -nSV: number of SVs for each class; empty for regression/one-class SVM -sv_coef: coefficients for SVs in decision functions -SVs: support vectors If you do not use the option '-b 1', ProbA and ProbB are empty matrices. If the '-v' option is specified, cross validation is conducted and the returned model is just a scalar: cross-validation accuracy for classification and mean-squared error for regression. More details about this model can be found in LIBSVM FAQ (http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html) and LIBSVM implementation document (http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf). Result of Prediction ==================== The function 'svmpredict' has three outputs. The first one, predictd_label, is a vector of predicted labels. The second output, accuracy, is a vector including accuracy (for classification), mean squared error, and squared correlation coefficient (for regression). The third is a matrix containing decision values or probability estimates (if '-b 1' is specified). If k is the number of classes, for decision values, each row includes results of predicting k(k-1)/2 binary-class SVMs. For probabilities, each row contains k values indicating the probability that the testing instance is in each class. Note that the order of classes here is the same as 'Label' field in the model structure. Examples ======== Train and test on the provided data heart_scale:
matlab
> load heart_scale.mat
matlab
> model = svmtrain(heart_scale_label, heart_scale_inst, '-c 1 -g 0.07');
matlab
> [predict_label, accuracy, dec_values] = svmpredict(heart_scale_label, heart_scale_inst, model); % test the training data For probability estimates, you need '-b 1' for training and testing:
matlab
> load heart_scale.mat
matlab
> model = svmtrain(heart_scale_label, heart_scale_inst, '-c 1 -g 0.07 -b 1');
matlab
> load heart_scale.mat
matlab
> [predict_label, accuracy, prob_estimates] = svmpredict(heart_scale_label, heart_scale_inst, model, '-b 1'); To use precomputed kernel, you must include sample serial number as the first column of the training and testing data (assume your kernel matrix is K, # of instances is n):
matlab
> K1 = [(1:n)', K]; % include sample serial number as first column
matlab
> model = svmtrain(label_vector, K1, '-t 4');
matlab
> [predict_label, accuracy, dec_values] = svmpredict(label_vector, K1, model); % test the training data We give the following detailed example by splitting heart_scale into 150 training and 120 testing data. Constructing a linear kernel matrix and then using the precomputed kernel gives exactly the same testing error as using the LIBSVM built-in linear kernel.
matlab
> load heart_scale.mat
matlab
>
matlab
> % Split Data
matlab
> train_data = heart_scale_inst(1:150,:);
matlab
> train_label = heart_scale_label(1:150,:);
matlab
> test_data = heart_scale_inst(151:270,:);
matlab
> test_label = heart_scale_label(151:270,:);
matlab
>
matlab
> % Linear Kernel
matlab
> model_linear = svmtrain(train_label, train_data, '-t 0');
matlab
> [predict_label_L, accuracy_L, dec_values_L] = svmpredict(test_label, test_data, model_linear);
matlab
>
matlab
> % Precomputed Kernel
matlab
> model_precomputed = svmtrain(train_label, [(1:150)', train_data*train_data'], '-t 4');
matlab
> [predict_label_P, accuracy_P, dec_values_P] = svmpredict(test_label, [(1:120)', test_data*train_data'], model_precomputed);
matlab
>
matlab
> accuracy_L % Display the accuracy using linear kernel
matlab
> accuracy_P % Display the accuracy using precomputed kernel Note that for testing, you can put anything in the testing_label_vector. For more details of precomputed kernels, please read the section ``Precomputed Kernels'' in the README of the LIBSVM package. Other Utilities =============== A
matlab
function libsvmread reads files in LIBSVM format: [label_vector, instance_matrix] = libsvmread('data.txt'); Two outputs are labels and instances, which can then be used as inputs of svmtrain or svmpredict. A
matlab
function libsvmwrite writes
Matlab
matrix to a file in LIBSVM format: libsvmwrite('data.txt', label_vector, instance_matrix] The instance_matrix must be a sparse matrix. (type must be double) These codes are prepared by Rong-En Fan and Kai-Wei Chang from National Taiwan University. Additional Information ====================== This interface was initially written by Jun-Cheng Chen, Kuan-Jen Peng, Chih-Yuan Yang and Chih-Huai Cheng from Department of Computer Science, National Taiwan University. The current version was prepared by Rong-En Fan and Ting-Fan Wu. If you find this tool useful, please cite LIBSVM as follows Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm For any question, please contact Chih-Jen Lin , or check the FAQ page: http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html#/Q9:_
MATLAB
_interface
strpos()
函数
判断字符串
中
是否包含某字符串的方法
用php的strpos()
函数
判断字符串
中
是否包含某字符串的方法 判断某字符串
中
是否包含某字符串的方法 if(strpos('www.idc-gz.com','idc-gz') !== false){ echo '包含'; }else{ echo '不包含'; } PHP strpos()
函数
strpos()
函数
返回字符串在另一个字符串
中
第一次出现的位置。 如果没有找到该字符串,则返回 false。 语法 strpos(string,find,start) 参数 描述 string 必需。规定被搜索的字符串。 find 必需。规定要查找的字
内存管理内存管理内存管理
内存管理内幕 dragonimp's blog coder.developer.[designer].ArchitecturE.manager.^_^... posts - 29, comments - 121, trackbacks - 27 My Links Home Contact Login News !!! Article Categories ..OT .Mixed Asp.net Cognos Cryptology Database DotText Jabber
MatLab
NetWork OpenGL Programming Tuxedo Unix/C/
C++
Web/Scripts Archives February, 2006 (2) January, 2006 (3) December, 2005 (2) November, 2005 (2) October, 2005 (2) May, 2005 (1) April, 2005 (7) March, 2005 (9) May, 2004 (1) Post Categories collection (rss) Daily Report (rss) NEWS (rss) Projects (rss) say you say me (rss) Image Galleries Application Galleries Funny OpenGL ReverseProxy My Sites blogs.impx.net Finance HomePage Weblogs AKUN's bLog Gin scottdensmore scottelkin.com scottwater's Blogs Sonu's WebLog 内存管理内幕 本文将对 Linux? 程序员可以使用的内存管理技术进行概述,虽然关注的重点是 C 语言,但同样也适用于其他语言。文
中
将为您提供如何管理内存的细节,然后将进一步展示如何手工管理内存,如何使用引用计数或者内存池来半手工地管理内存,以及如何使用垃圾收集自动管理内存。 为什么必须管理内存 内存管理是计算机编程最为基本的领域之一。在很多脚本语言
中
,您不必担心内存是如何管理的,这并不能使得内存管理的重要性有一点点降低。对实际编程来说,理解您的内存管理器的能
机器视觉
4,447
社区成员
15,336
社区内容
发帖
与我相关
我的任务
机器视觉
图形图像/机器视觉
复制链接
扫一扫
分享
社区描述
图形图像/机器视觉
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章