RGB image displaying black or random noise

1 view (last 30 days)
gasper321
gasper321 on 3 Aug 2018
Commented: gasper321 on 3 Aug 2018
Hello everyone.
I'm using MATLAB R2018a and ubuntu 18.04LTS. I'm trying to process some video into frames (DEAP dataset). The video is encoded in H.264. I installed ffmpeg and gstreamer0.10-ffmpeg plugin to get the VideoReader to work. Then I ran the following code to get frames:
video_path = 'dataset_DEAP/videos/s01/s01_trial01.avi';
%video_path = 'dataset_cohface/1/0/data.avi';
image_path = 'dataset_DEAP/images/';
videoObject = VideoReader(video_path);
% Prints and outputs (9 = ASCII for TAB)
disp(['Processed video: ' video_path]);
disp([' Fs:' 9 9 num2str(videoObject.FrameRate)]);
disp([' Height:' 9 num2str(videoObject.Height) ' px']);
disp([' Width:' 9 num2str(videoObject.Width) ' px']);
disp([' Length:' 9 num2str(videoObject.Duration) ' sec']);
nr_of_frames = ceil(videoObject.FrameRate * videoObject.Duration);
% Get individual frames
for i=1:nr_of_frames
currentFrame = readFrame(videoObject);
image(currentFrame);
%imwrite(currentFrame, strcat(image_path,num2str(i),'.jpg'),'jpg');
break
end
The metadata of the video are ok and as expected, however, the frame is always showing/saving as only black image. If I flatten the currentFrame variable (originally 576x786x3 uint), I can see that not all values are 0. Instead, I have values in 0-255 range, as expected for RGB.
So everything looks as expected, it works with other video (from another dataset) and this same code seems to work in Windows 10. It seems the issue is in the ubuntu-matlab combination, not showing/saving the frame as an image correctly.
Any help is much appreciated.
EDIT: After checking the R, G and B matrices individually, i notice that i have majority of rows 0 and some rows with 255 only. There are only a few rows with random values in range 0-255. It almost feels as the output is not deterministic, since now I got some random noise in an image, as attached.
  4 Comments
Stephen23
Stephen23 on 3 Aug 2018
@gasper321: please upload one frame in a .mat file by clicking the paperclip button.

Sign in to comment.

Answers (0)

Categories

Find more on Display Image in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!