VideoReader - cropped frame
조회 수: 14 (최근 30일)
이전 댓글 표시
Hello,
I'm using VideoReader to import *.avi file to Matlab.
My original file is quite large, it's 480x480 pixels, 24 bits per pixel.
If I'm trying to read all the frames using getFrame as in the code below, it takes a lot of time.
k = 1;
while hasFrame(xyloObj)
mov(k).cdata = readFrame(xyloObj);
k = k+1;
end
So I get a struct, mov, with frames size of 480x480x3.
My questions are: A) how can read only 8 bits per pixel, so my struct would be only "one layer"... 480x480x1? B) how can I read only a cropped region every frame? I mean can I read 64x64 ROI every loop, instead of read the full frame every time?
Thank You!
댓글 수: 0
채택된 답변
Walter Roberson
2015년 10월 6일
If your image is RGB24 then VideoReader always reads and outputs the entire data. If your image was indexed then you could specify 'native' to get back a struct that had the indexing information and the colormap and so would be slightly faster.
VideoReader always returns the entire frame; there is no crop option (at least up to R2015b).
The methods of setting cropping and format to return data only work for live video, not reading from a file.
댓글 수: 3
Michal Semonsky
2020년 6월 8일
Hello, is this information still up too date or is there any crop function within video reader? Thank you
Walter Roberson
2020년 6월 8일
The information is still up to date: there is no crop function within VideoReader, or vision.VideoFileReader
What is different since that time is that there is now an imcrop3 that can be (carefully) applied to a Rows x Columns x Panes x Images 4D array to reduce the numeber of rows and columns on every image, which could be useful in cropping if you used the read() method to read multiple frames.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!