- Load the video using 'VideoReader'
- Extract the frames from the video
- Using SSIM, compare the extracted frames with two reference frames, one from each scene
- Higher the scalar value, more similar the frames are
- Distinguish the frames into two separate scenes
- Recombine the frames belonging to each scene
Separate Video Frames Based on Similarity (SSIM)
10 次查看(过去 30 天)
显示 更早的评论
I have a video which was made by mixing short scenes from 2 different videos mixed into one. For example few seconds from 1st scene, then few seconds from 2nd scene and so on. There are only 2 scenes. I am trying to separate the video in to two videos. Can someone help me do this in matlab?
Someone told me to use SSIM of each frame and collect all frames with similar SSIM into one video and the rest in the other. But I have no idea how to even start.
0 个评论
回答(1 个)
Yash Ubale
2018-11-15
编辑:Yash Ubale
2018-11-15
Hello,
You can try the following steps to achieve it :
To load the video and extract all the frames :
obj = VideoReader('sample_video.mp4');
% total number of frames in the video
countFrames = 0;
while hasFrame(obj)
this_frame = readFrame(obj);
% compare the frames with reference frame from each scene
countFrames = countFrames + 1;
end
To compare the frames using SSIM
% higher the value of 'ssimval' higher the similarity, 'ref' is reference frame
[ssimval,ssimmap] = ssim(this_frame,ref);
1 个评论
Alex Van Der Ven
2020-10-16
Hi Yash! I have one question about the ssim() function: the instructions page specifies that the input images must be grayscale images. Not sure if I'm missunderstanding your suggestion, but should each frame be converted to grayscale prior to being input to the ssim() function?
Thanks for the help in advance!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!