在Matlab中单入UINT8转换?

时间:2014-05-10 15:34:29

标签: matlab

我在Matrix类型转换中遇到问题。

所以,我想通过使用VLFEAT函数从图像中提取SIFT特征"的 vl_covdet "

以下是详细信息:

 Input images = <141x142x3 uint8>

因为vl_covdet 只能读取1个频道和单个类型的图像,所以我将输入图像的R频道提供给vl_covdet:

 R_input_Images = Input images(:,:,1) <141x142 uint8>
 R_Single_Images= im2single(R_input_Images);


[frames, descrs,info] = vl_covdet(R_Single_Images,'Method','multiscalehessian','EstimateAffineShape', false,'EstimateOrientation', true, 'DoubleImage', false, 'Verbose');

现在,我有了功能

  descrs = <128x240 single> which values are ranging from 0 - 0.368

但是为了计算BoW,我必须使用VLFEAT的K-Means聚类(&#​​34; vl_hikmeans &#34;),这需要 uint8输入类型。 / p>

  descrs must be of class UINT8.

然后我尝试将其再次转换为uint8

   descrs=uint8(descrs);

现在

   descrs = <128x240 uint8> **AND ALL THE VALUES BECOME 0**.

我现在要做什么?

1 个答案:

答案 0 :(得分:0)

  

值范围为0-0.368

好吧,如果你将它们舍入为整数,那么它们就变成零也就不足为奇了。

由于浮点格式的图像范围为0-1,而uint8格式的图像范围为0-255,请尝试

descrs = uint8(descrs * 255);