Change colour of specific frames in a avi video
1 次查看(过去 30 天)
显示 更早的评论
Hi.
I have a .avi video with 37958 frames. I need to change the colour of some specific frames (more than 3000), for example to red or to a grayscale. Then, I have to play the movie again and watch the changed frames. I know how to process the video, but I don't know how to change the colour of specific frames. The index of the frames that I need to change are stored in the array k. Can anyone help me? This is my code:
close all;
clc
cd 'H:\Desktop\Poses_files'
%%Create a VideoReader object to read data
v = VideoReader('ines_output.avi');
vidWidth = v.Width;
vidHeight = v.Height;
%%Create a movie structure array
mov = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),...
'colormap',[]);
%%Read one frame at a time until the end of the video
j = 1;
while hasFrame(v)
mov(j).cdata = readFrame(v);
j = j+1;
end
%%Change frames with peaks
min_peaks= islocalmin(y1,'MinProminence',2);
k=find(min_peaks);
n=1;
while n<=length(k)
mov(k(n))= ;
n=n+1;
end
for frame = 1 : length(k)
% Extract the frame from the movie structure.
thisFrame = readframe(v, frame);
end
%%Play the movie
hf = figure;
set(hf,'position',[150 150 vidWidth vidHeight]);
movie(hf,mov,1,v.FrameRate);
Many thanks,
Ines
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!