I have an image of size 1000×1000(Grayscale). I want to start with a white canvas and plot the pixel value one by one on that canvas and create a video out of it.
How can we achieve this?
I have an image of size 1000×1000(Grayscale). I want to start with a white canvas and plot the pixel value one by one on that canvas and create a video out of it.
How can we achieve this?
2
Answers
This is pseudocode, but might help:
There are many ways of doing this. I’ll just show 2 ways:
VideoWriter
, andffmpeg
externallyYou can use OpenCV and its
VideoWriter
like this:Or, if you prefer – or cannot install OpenCV – you can use PIL/Pillow and
ffmpeg
like this for the same result:Then you would pipe the output of this script into
ffmpeg
(with adjusted size parameters to match your video:Note that if you have an image of 1000×1000 pixels and you create a new frame of video for each and every pixel, you will get 1,000,000 frames of video. If you show 30 frames/second, which is pretty normal for video, your video will take 9 hours to complete… so I plotted every 100th frame: