3월, 2021의 게시물 표시

Image Processing #11 - Speed up image processing with numba

이미지
I have written several blogs related to watermarking.  Image Processing #4 - WaterMark without alpha channel Image Processing #5 - WaterMark using alpha channel The example Python code provided in these articles performs RGB operations on all or some pixels of an image. If it is a 2048 x 1152 size image, at least Width x Height x Channel = 7,077,888 calculations are required. And if the video is 30 frames per second, 212,336,640 operations per second are required. The Python language is easy to learn, and modules with numerous functions are provided, so high code productivity can be expected. However, if the number of repetitions of loop statements such as for and while increases, the performance decreases a lot. The reason is that because the Python language is interpreted, it reinterprets every sentence in every loop. Let's compare the performance by making the following simple example in C and Python. This simple example adds 1 to 10000000. #include <stdio.h> // for pri