简体   繁体   English

MATLAB视频:如何使用'readFrame'输出进行'imbinarize'功能?

[英]MATLAB Video: how to use 'readFrame' output for 'imbinarize' function?

I'm doing the following:1. 我正在做以下事情:1。 Loading the original video 2. converting the video to black and white 3. saving it to a new avi file. 加载原始视频2.将视频转换为黑白3.将其保存到新的avi文件。 Repeating for each frame. 重复每一帧。

; ;

However I got the the following error: 但是我收到以下错误:

Expected I to be two-dimensional 期待我是二维的

Why am I getting this error message? 为什么我收到此错误消息? Isn't a frame going to be two-dimensional? 框架不是二维的吗?

The image from your video is an RGB image so it is M x N x 3 and imbinarize only accepts 2D inputs. 视频中的图像是RGB图像,因此它是M x N x 3imbinarize只接受2D输入。 In order to process your image, you'll want to first convert it from RGB to grayscale using rgb2gray 为了处理您的图像,您需要先使用rgb2gray将其从RGB转换为灰度

img = rgb2gray(readFrame(reader));

Also, since the output of imbinarize is logical , you'll need to first convert it to a double prior to writing it to the output video 此外,由于imbinarize的输出是logical ,因此在将其写入输出视频之前,您需要先将其转换为double

writeVideo(writer, double(BW));

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

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