What is GPU..?
Already as you known it's a video card. A graphics processing unit (GPU), also occasionally called visual processing unit (VPU), is a specialized electronic circuit designed to rapidly manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display.
Why GPU..?
This process is usually slow, so to boost performance, I'm using GPU acceleration via CUDA, NVIDIA’s general C-like programming language. In practice, you can expect a real-time performance
Introduction to the Project
If we consider a video or a movie, some of them have problems such as low brightness, low contrast and not suitable colors. So that factors must be improve to get a better video.
Improving the quality of a video is called video enhancement. Enhancement can be with respect to different properties such as brightness, contrast and color. Histogram equalization is a widely used technique in image processing to do automatic contrast adjustment of an image. Images which are too darker, lighter or flat are having a low contrast.
Histogram equalization increases the contrast automatically to make the quality of the image better. The same process can be used to enhance videos because a video is simply a sequence of still images. The process mostly involves pixel wise operations and for a high resolution image a lot of computations has to be done.
If we consider CPU it has Small number of computation threads being undertaken at high speed, but GPU has a large number of simple computation threads undertaken at a lower speed. In video enhancement the number of computations for a video is significantly high and hence the video rendering on CPU would require long waiting time.
A Graphics Processing Unit that consists of hundreds of cores are ideal in problems like this which involves large number of independent parallel operations. Therefore a GPU implementation is expected to give a massive speedup. Using Compute Unified Device Architecture (CUDA), NVIDIA graphics cards can be easily programmed to be used for such
calculations.
In this project, we implemented a software that runs on a GPU to enhance a given color video using histogram equalization technique.
Designing the project
• Accept a H.264/MP4 video file specified by the user as an input
We basically use open CV to process the video file. open CV is a basic image processing library which is used to read video file as a 3D matrix.
• Convert RGB values of the frames to HSI
There are so many techniques to enhance videos but in our case we used histogram equalization to enhance the video. So we firstly read RGB values from the frame by frame in the video and converted in to HSI values. Then using that HSI values we processed the histogram equalization algoritham.
• Do the histogram equalization
In histogram equalization first we consider a frame. We read its pixel values as a matrix. Then we got the frequency of each pixel value. Then we use histogram equation to get the equalized pixel values and replaced them with original values. We did this process frame by frame.
{formulas for histogram equalization : h(v)= [cdf - cdf(min)/M x N - cdf(min) ] x (L-1) }
• Do the CUDA implementation
First we analyzed the parallizable parts in the code. Then we make kernels for those parallizable parts. After that we using Cuda ocupancy calculator we get optimize block sizes and thread numbers and use them in the code.
• Optimization and output the enhanced video as the same file format and initial resolution
We increased the work done by each kernel. Also number of times that the kernels are used is reduced. We allocated memory once at the beginning of an application and then reuse that memory in each kernel invocation. We used row wise matrix operations.
If we consider a video or a movie, some of them have problems such as low brightness, low contrast and not suitable colors. So that factors must be improve to get a better video.
Improving the quality of a video is called video enhancement. Enhancement can be with respect to different properties such as brightness, contrast and color. Histogram equalization is a widely used technique in image processing to do automatic contrast adjustment of an image. Images which are too darker, lighter or flat are having a low contrast.
Histogram equalization increases the contrast automatically to make the quality of the image better. The same process can be used to enhance videos because a video is simply a sequence of still images. The process mostly involves pixel wise operations and for a high resolution image a lot of computations has to be done.
If we consider CPU it has Small number of computation threads being undertaken at high speed, but GPU has a large number of simple computation threads undertaken at a lower speed. In video enhancement the number of computations for a video is significantly high and hence the video rendering on CPU would require long waiting time.
A Graphics Processing Unit that consists of hundreds of cores are ideal in problems like this which involves large number of independent parallel operations. Therefore a GPU implementation is expected to give a massive speedup. Using Compute Unified Device Architecture (CUDA), NVIDIA graphics cards can be easily programmed to be used for such
calculations.
In this project, we implemented a software that runs on a GPU to enhance a given color video using histogram equalization technique.
Designing the project
• Accept a H.264/MP4 video file specified by the user as an input
We basically use open CV to process the video file. open CV is a basic image processing library which is used to read video file as a 3D matrix.
• Convert RGB values of the frames to HSI
There are so many techniques to enhance videos but in our case we used histogram equalization to enhance the video. So we firstly read RGB values from the frame by frame in the video and converted in to HSI values. Then using that HSI values we processed the histogram equalization algoritham.
• Do the histogram equalization
In histogram equalization first we consider a frame. We read its pixel values as a matrix. Then we got the frequency of each pixel value. Then we use histogram equation to get the equalized pixel values and replaced them with original values. We did this process frame by frame.
{formulas for histogram equalization : h(v)= [cdf - cdf(min)/M x N - cdf(min) ] x (L-1) }
• Do the CUDA implementation
First we analyzed the parallizable parts in the code. Then we make kernels for those parallizable parts. After that we using Cuda ocupancy calculator we get optimize block sizes and thread numbers and use them in the code.
• Optimization and output the enhanced video as the same file format and initial resolution
We increased the work done by each kernel. Also number of times that the kernels are used is reduced. We allocated memory once at the beginning of an application and then reuse that memory in each kernel invocation. We used row wise matrix operations.
First of all you need
https://github.com/Anjeldethwings/GPU-accelerated-video-enhancement-application
you can find the code using above link.
No comments:
Post a Comment