1

这是我的问题:最近,我通过Simulink Coder了解了一些关于从Simulink模型生成代码的内容。该模型包括一个MATLAB Function块,从灰度的视频信号转换使用至二值:将灰度视频转换为二进制代码生成

编辑: 二进制= im2bw(inputVideo,电平);

,因为,我的应用程序,我发现它比Autothreshold块(我不为什么)更精确,但Simulink Coder不支持im2bw功能(就像你可以在这里看到http://www.mathworks.it/it/help/simulink/ug/functions-supported-for-code-generation--categorical-list.html#bsl0arh-1)。所以,我会尝试创建一个outputVideo使用:

Binary = false(size(inputVideo)); % to inizialize 
Binary(inputVideo>=threshold)==true; 

...但是当我这样做,与灰度图像,outbinary图像是全黑的图像。有没有办法执行此转换,而不使用Autothreshold块或im2bw函数?提前致谢!

回答

3

此行是错误的:

Binary(inputVideo>=threshold)==true; 

在这里,您与true比较Binary(inputVideo>=threshold)。正确的:

Binary(inputVideo>=threshold)=true; 
+0

我编辑上面的代替阈值与水平(从MATLAB帮助)。在我的情况下,它是0.15。我如何在代码中找到阈值? – Orlok

+1

问题是'=='比较,你需要一个'='来分配。 – Daniel

+0

好吧,它的工作,但现在我怎么能找到一个0.15的im2bw水平I阈值(与'单'作为数据类型)?在im2bw中它介于0和1之间。 – Orlok

相关问题