Interpolation filter in video

4 次查看(过去 30 天)
Hello,
I've been looking at the documentation on the 'interp' function, which is the function that I think I should use.
My problem is as follows: I have two types of images, alpha and negative alpha, which is alpha * (-1). Imagine that my alpha image goes from 1 to -1 and the negative alpha goes from -1 to 1, what I want to achieve is to create a video of numbers of Frames 'N', where the interpolation values are parameterizable, that is the interpolation time and the number of samples to be used, thus achieving a 'temporary' filtering.
The result of this function should be a 'N' frames video where what we will see will be in frame1: alpha, ...... frame3: alpha negative, .... frame5: alpha, frame7: alpha negative .. ..
Frame 3 is an example since it will depend on interpolation.
In the following image I show you an example of what it should be, to see if you can guide me or give a help with this problem.
Thank you very much in advance, any sure answer will help me, regards!

采纳的回答

Ameer Hamza
Ameer Hamza 2020-3-9
I am not sure why you scaled the pixels from -1 to 1. The following code use pixel values from 0 to 1, and the inverse image have pixel values from 1 to 0.
im = im2double(imread('peacock.jpg'));
im_reverse = 1-im;
N = 10;
time = reshape(linspace(0, 1, N), 1, 1, 1, N);
frames = im_reverse.*time + im.*(1-time);
v = VideoWriter('video_file', 'MPEG-4');
v.FrameRate = 10;
open(v);
for i = 1:5 % how many times to repeat pattern
% im to im_reverse
for j=1:N
frame = frames(:,:,:,j);
writeVideo(v, frame);
end
% im_reverse to im
for j=N:-1:1
frame = frames(:,:,:,j);
writeVideo(v, frame);
end
end
close(v);
  4 个评论
Alber
Alber 2020-3-9
Thank you very much, so it is not necessary to use the interp function?
Ameer Hamza
Ameer Hamza 2020-3-9
It is possible with interp1, but the solution is a lot messier.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by