Why some of my colored videos load as gray-scale in MATLAB

5 次查看(过去 30 天)
Hi, I downloaded a bunch of videos from youtube. I then load them to matlab to extract/process 10 randomly selected clips. Most of my videos load perfectly fine, however, a lot of them load as a weird gray-scale version of the video. I load the videos using:
vidObj = VideoReader(filename);
duration = vidObj.Duration ;
clips_indx = duration * rand(10,1);
for i = 1 : 10
vidObj.CurrentTime = clips_indx(i);
im = readFrame(vidObj);
end
This is how the clips look like, tilted and gray!
While the video looks normal like:
I would appreciate any input.
Thanks a lot.

回答(2 个)

Walter Roberson
Walter Roberson 2016-5-16
1) It is possible for videos to be pseudocolor; in such a case when you retrieve the frame, the map field will be non-empty and the data field will be 2D.
2) With a shear like that, it is plausible that the video is in YCrCb 4:2:2 or 4:2:0 and needs to be converted to RGB.
  7 个评论

请先登录,再进行评论。


Mona
Mona 2016-6-6
编辑:Mona 2016-6-6
Hi, I wasn't able to resolve this problem. However, I just had to find a way to go around it. So my very inefficient way is to : - Read the file using vision.VideoFileReader
vidObj = vision.VideoFileReader(filename);
Then convert the video using vision.VideoFileWriter to a .avi file
videoFWriter = vision.VideoFileWriter([filename,'.avi'],'FrameRate',videoFReader.info.VideoFrameRate);
while ~isDone(videoFReader)
videoFrame = step(videoFReader);
step(videoFWriter, videoFrame);
end
release(videoFReader);
release(videoFWriter);
The .avi file now can be perfectly read in the correct format by VideoReader, and I cant choose which frames to process.

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by