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

5 vues (au cours des 30 derniers jours)
Mona
Mona le 16 Mai 2016
Modifié(e) : Mona le 6 Juin 2016
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.

Réponses (2)

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

Connectez-vous pour commenter.


Mona
Mona le 6 Juin 2016
Modifié(e) : Mona le 6 Juin 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.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by