【问题标题】:how to calculate the feature vectors approximately for storing in excel sheet?如何近似计算特征向量以存储在excel表中?
【发布时间】:2015-03-30 11:47:49
【问题描述】:

在我的 GUI 中,我使用此 matlab 代码将值存储在 excel 表中。此代码正在计算 glcm 六个特征。

function [Contrast,cor,ener,homo,Var,Entropy] = glcm_feature_extraction(I1)

Contrast = graycoprops(graycomatrix(rgb2gray(I1)),'Contrast')  
cor= graycoprops(graycomatrix(rgb2gray(I1)), 'Correlation')  
ener = graycoprops(graycomatrix(rgb2gray(I1)), 'Energy')  
homo = graycoprops(graycomatrix(rgb2gray(I1)), 'Homogeneity')  
img = double(I1);  
Var = var((img(:)))  
Entropy=entropy(I1)

这里假设我在计算后得到这些值:

[0.603606103 : 0.785092239 : 0.271728411 : 0.855429408 :1889.578963 : 7.178149206]

但我只需要近似值,例如:

[0.6 : 0.7 : .2 ....]

如何修改这段代码得到这个结果?

【问题讨论】:

  • 您可以使用x_round = round(x, N) 将值四舍五入到小数点右侧的N 位数。有关详细信息,请参阅round 的文档。
  • 我收到错误 Error using ==> round Too many input arguments.

标签: excel matlab feature-extraction glcm


【解决方案1】:

例如,让我们考虑对比度=0.603606103

而您希望大约为 0.6,然后使用以下内容:

sprintf('%.1f',Contrast);

这应该会给你准确的结果 Contrast=0.6

对所有剩余的 5 个变量进行类似的操作。

【讨论】:

  • 我用过这个 y=sprintf('%.1f',Contrast);将其存储在 excel xlswrite('abc.xlsx',[y]);我没有得到正确的结果,因为在 excel 文件中结果 0.6 需要三个单元格来存储自己而不是一个在 excel 文件中提前谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-05
相关资源
最近更新 更多