简体   繁体   English

在Matlab中单向UINT8转换?

[英]Single into UINT8 conversion in Matlab?

I have a problem in Matrix type conversion. 我在矩阵类型转换中有问题。

So, I want to extract the SIFT features from an image by using VLFEAT function " vl_covdet " 因此,我想通过使用VLFEAT函数“ vl_covdet ”从图像中提取SIFT特征

Here is the detail: 这是详细信息:

 Input images = <141x142x3 uint8>

And because vl_covdet only can read 1 channel and an image with type of single , I give R channel of my input image to vl_covdet: 而且由于vl_covdet 只能读取1个通道和一个类型为single的图像 ,因此我将输入图像的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');

And now, I got features 现在,我有了功能

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

But to compute BoW, I have to use K-Means clustering from VLFEAT (" vl_hikmeans ") which require uint8 input type . 但是要计算BoW,我必须使用VLFEAT(“ vl_hikmeans ”)中的K-Means聚类,这需要uint8输入类型

  descrs must be of class UINT8.

So then I tried to convert it again into uint8 因此,我尝试将其再次转换为uint8

   descrs=uint8(descrs);

Now 现在

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

What I have to do now?? 我现在要做什么?

values are ranging from 0 - 0.368 值范围是0-0.368

Well, if you round those to integer, it's no surprise they become zeros. 好吧,如果将它们四舍五入为整数,它们变为零也就不足为奇了。

Since an image in floating-point format has range 0-1, and in uint8 format has range 0-255, try 由于浮点格式的图像的范围是0-1,而uint8格式的图像的范围是0-255,请尝试

descrs = uint8(descrs * 255);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM