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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposte (2)

Walter Roberson
Walter Roberson il 16 Mag 2016
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 Commenti
Mona
Mona il 21 Mag 2016
Thanks a lot again. You've been so helpful.

Accedi per commentare.


Mona
Mona il 6 Giu 2016
Modificato: Mona il 6 Giu 2016
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.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by