Fast Generalized Fourier Descriptor for object ...

5 downloads 7818 Views 842KB Size Report
The difference between this transform and the previous that, with summing is for ... The API (Application Programming Interface) of CUDA allows communication ...
Fast Generalized Fourier Descriptor for object recognition of image using CUDA Bahri Haythem Laboratory of EμE Faculty of Sciences Monastir 5000, TUNISIA [email protected]

Hallek Mohamed Laboratory of EμE Faculty of Sciences Monastir 5000, TUNISIA [email protected]

Chouchene Marwa Laboratory of EμE Faculty of Sciences Monastir 5000, TUNISIA [email protected]

Sayadi Fatma Laboratory of EμE Faculty of Sciences Monastir 5000, TUNISIA [email protected]

Atri Mohamed Laboratory of EμE Faculty of Sciences Monastir 5000, TUNISIA [email protected]

Abstract — In recent later years, we can notice a tremendous increase in computer vision research of the recognition forms domain, such as color object recognition. In this framework, we chose the Fourier Descriptor as a method to compute the feature vector of color image. We took as a tool of recognition and classification the Generalized Fourier Descriptor given by F. Smach and al. [1]. The heaviest part of computing time of Fourier Descriptor is the Fast Fourier Transform. In order to accelerate the compute of Fourier Descriptor vector, we proposed a GPU technology of computing. In fact, the aim of this paper is to bring out the computing rapidity of 2D FFT on GPU for each size of image. This approach returns to accelerate the computation of Fourier Descriptor vector under GPU. To showcase this performance, we compared this study with another traditional implement of FFT and Fourier Descriptor on CPU.

We are interesting in the forms descriptor model as an application domain. In this order, we studied the Fourier Descriptor for recognition and classification of images. Complex Fourier Transform or Fast Fourier Transform (FFT) is the tool that used to extract different features of object in image. Those features were representing in a coefficients vector that will be used as an input of classifier to identify their class. Therefore, we quote a model of Generalized Fourier Descriptor for a color image like a tool to compute the FD.

Keywords- Fast Fourier Transformation; Generilazed Fourier descriptor; GPU; CUDA; Fourier Descriptors; CUFFT.

This transform is an important image processing tool which is used to decompose an image into its sine and cosine components [2]. The input image is the spatial domain, while the output of the Fourier transformation represents the image in the Fourier or frequency domain equivalent.

I.

INTRODUCTION

For any image we can extract different fate of attributes using some mathematic tools. We can enunciate the descriptor as a representative tool when its coefficients vector can represents all information. In this paper we are interesting in descriptor of forms and precisely the Fourier Descriptor. It is used for recognition and classification of images. In this domain, it is usually to extract on real time some information concerning images. Our paper proposes a new implementation based on GPU technology for a special model of recognition that is Generalized Fourier Descriptor. Our paper is divided in three parts: the first part defines and represents the 1FD model that’s Generalized Fourier Descriptor. The second part is devoted in CUFFT the main application of CUDA which is a programming language under GPU. The third part explains each pattern of implement of 2 GFD and a case study of implementation on CPU and GPU. II.

FD: Fourier Descriptor GFD: Generalized Fourier Descriptor 3 FT: Fourier transform operator for a bi-dimensional function. 2

In the Fourier domain image, each point represents a particular frequency contained in the spatial domain image. Fourier transform is used in a wide range of applications, such as image analysis, image filtering, image reconstruction and image compression. 1) Fourier Transform and its inverse: The fourier transform of f(x) is written as follows: 1

Where v: Frequency variable, x: spatial variable, i =√(-1) and F(v) is the 3FT function of f(x), its inverse transform is written: 2

FOURIER DESCRIPTORS

Fourier Descriptors can be used as feature vector components in various applications, such as real time color object recognition or image retrieval. It gathers the full information of object in image. It conserves the invariance characters of geometric transform, noisy and lighting. Fourier Descriptor can be in global mode that represents all pixels of image or in a local mode, where it shows some region and interesting point. We can quote some models of descriptors such as colors descriptor (histogram…) and Textures descriptor (wavelet…). 1

A. Fourier transform Fourier transform is the analogous of theoretical of Fourier series for non-periodic functions. It is an operator that transforms an integral function to another function giving its frequency spectrum.

For some specialty of these equations that can be recovered without losing information. Else they can be written in two variables, u and v: ,

,

3

Where y, u: they spatial and frequency variable (as respectively of x, v). Its inverse function is written: ,

,

4

2) FFT in image processing: The first model treat digital image that DFT or Discrete Fourier Transform, which is the bases of the full frequency image processing. This transform and its inverse are given by: ∑



5

a same radius relative at center of image for each magnitude of FFT. Finally, we gathered these values to construct the FD vector where its components are Df (r) and we normalized all coefficients by Df (0). For example FDb(1) = Dfb (1) / Dfb (0), the following figure shows how we computed Df (r) for either color image:

The difference between this transform and the previous that, with summing is for a discrete function but with integrating is for a continuous function. The intensity of 2 digital image defined in an R function. Its digital treatment based on DFT in 2 dimensions: ,

,





,

6

The DFT is the sampled FT and therefore does not contain all frequencies forming an image, but only a set of samples which is large enough to fully describe the spatial domain image. The FFT is based on the complex DFT, a developed model of the real DFT. Even with these computational savings, the ordinary one dimensional DFT has N2 complexity but FFT can be reduced to N log2 N. There are various forms of FFT but most of them restrict the size of the input image that may be transformed. It is used to access for the geometric characteristics of a spatial domain image. In most implementations the Fourier image is shifted in such a way that the output image value F (0, 0) is displayed in the center. B. GFD: Generalized Fourier Descriptor These relations of DFT were defining in Cartesian coordinates but D.Zhang and G.Lu [3] have used them in 2 dimensions polar coordinates. ,

,

7

To use the object color information, one of classically method used to compute the descriptor of three color plans of image R, G and B. Afterwards they will be concatenate in one vector. This approach applied with success at the Generalized Fourier Descriptor of F. Smach and al. These last were defining some invariants of GFD for all digital color images. These invariants had noted by this following relation: ,

8

In discrete domain, an integral replaced by a finite sum produced the Fourier Descriptor vector. It will use as an input of classifier. The compute of GFD is done by applying the Fast Fourier Transform algorithm (FFT) for a color image. Therefore these descriptors are the sum of a square module of FFT located on the circle which r her radius. In fact we summarized the compute of descriptors in four main steps. Firstly, we decomposed a color image into 3 separate channels images (red, blue and green). We computed the FFT of each image and its square module. Also we summed its pixels have

1

u=1…M and v=1…N.

Figure 1.

III.

Compute of Generalized Fourier Descriptor

PARALLELISM APPROACH OF CUDA

FFT is used in image transform domain, video compression, speech and audio. For each field, it makes its specific signification. Because, it has a compute intensive and big volume of data, we proposed the Graphics Processing Units (GPU) based FFT algorithm which can be the cost effective solution [4]. The GPU can execute the FFT application in parallel using the mode of SIMD (Single Instruction Multiple Data). GPU has becoming a hot research topic that works in image processing. For this reason, it is chosen to develop the compute and to reduce the FFT calculation time [5]. To execute this transform on GPU, we used a specific architecture that’s CUDA. A. What’s CUDA? CUDA (Compute Unified Device Architecture) is a programming language under GPU. It was introduced by the NVIDIA Corporation in November 2006. This architecture provides a complete solution for General Purpose Computing on Graphics Processing Unit, including new hardware, instruction sets, and programming models [6]. The API (Application Programming Interface) of CUDA allows communication between the CPU and Graphics Processing Unit, ultimately allowing the user to control the execution of code on GPU with the same degree of control as on CPU.

Figure 2. Canonical execution flow [7]

CUDA's API primarily allows the C programming language to be used as a high-level interface, although other languages are supported. It programs language accessible to use for programmers. Other important features are flexibility of data structures, explicit access on the different physical memory levels of the GPU, and a good framework for programmers including a compiler, CUDA Software Development Kit (CUDA SDK), a debugger, a profiler, and CUFFT and CUBLAS scientific libraries [8]. B. Programming with CUDA The CUDA computing engine virtualizes graphics hardware available to the programmer through the use of uniquely numbered threads that are organized into 1D, 2D, or 3D blocks of arbitrary size [9].

C. CUFFT library of CUDA For a new method of implementation on GPU, we used a specific library of programming language of CUDA that’s CUFFT [11]. The Fast Fourier Transform (FFT) is a divide and conquer algorithm for efficiently computing discrete FT of complex or real valued data sets. The FFT is one of the most important and widely used numerical algorithms. CUFFT is the CUDA FFT library that implement the FT algorithms, provides a simple interface for computing parallel FFT on an NVIDIA GPU. This allows users to leverage the floating point power and parallelism of the GPU without having to develop a custom, GPU based FFT implementation. The CUFFT library implements several FFT algorithms, each with different performances and accuracy. Applying of CUFFT can be resuming in 4 easy steps. Initially, we should be allocating space on GPU where the FFT functions compute its algorithm. Then, Create plan specifying transform configuration like the size and type (real, complex, 1D, 2D and so on) [12]. The next step is to execute the plan as many times as required, providing the pointer to the GPU data created in the first step. Finally, we destroy the space initially creating to release the GPU memory. IV.

PROCESSING A COLOR IMAGE WITH GFD

A. Processing of FFT on GFD For the experiment, NVIDIA’s GeForce GT 525M Graphics Card was used for CUDA. It belongs to the Fermi architecture and it support 96 CUDA cores, running at 1.2 GHz. Then, CUDA was connected with Intel® Core ™ i32350M based CPU with a clock speed 2.30 GHz built in x64 PC Main Board’s PCI Express. For smooth running the process of FFT based image recognition using GPU we have used different resolution of images to figure out the performance of FFT on CPU and GPU based implementation for GFD. Images are chosen with an odd resolution for some processing obligation. CPU performance results are obtained by computing FFT of images in C++ using OPENCV and measuring the execution time using the special profiler of Visual Studio. But GPU performance results are obtained by applying the CUFFT library for each image in CUDA and measuring the execution time using the special NVIDIA Compute Visual Profiler. TABLE I.

GPU Device Memory Hierarchy [10]

A thread can be thought of as a scalar arithmetic processor, whereas a block of threads is an abstract representation of a multiprocessor composed of multiple scalar processors and capable of performing operations in parallel. The threads are executed on the graphics device equipped with a GPU, hereafter referred to as the device, serving as a coprocessor that enhances the computational capabilities of the workstation, referred to as the host (CPU).

Processing time (ms) CPU (ms)

GPU(ms)

Speedup factor

15x15

1.01

0.02

45.90

31x31

1.51

0.081

18.64

Image size Figure 3.

EXECUTION TIME ON CPU AND GPU OF FFT ON GFD

63x63

6.35

0.089

71.34

127x127

28.73

0.23

122.77

255x255

112.11

0.78

142.81

511x511

395.02

3.28

120.24

1023x1023

1265.61

13.19

95.93

For FFT implement on GFD, table 1 above shows the comparison time between CPU and GPU in different sizes. s larger We were finding that the GPU speedup is significantly than CPU. The implementation showed an average speed up of GPU than CPU. From the Figure 4, we observedd that the boost in performance for FFT is gradually enhancing. This performance for both CPU and GPU is nearrly same for image size between 15x15 until 63x63.

B. Processing of GFD As we said later, the heeaviest part of GFD that the processing of 2D FFT of eachh channel for color image. For this reason, we showed the peerformance of GPU implement than CPU for FFT computingg. Which will consume the full time executed of GFD computiing. TABLE II.

1400

EXECUTION TIIME ON CPU AND GPU FOR GFD

Image size

1200

CPU U (ms)

GPU(ms)

FFT on CPU

15x15

400.43

39.44

FFT on GPU

31x31

822.51

81.08

63x63

3005.47

299.20

127x127

4223.47

395.28

255x255

6117.05

495.72

511x511

8117.05

425.31

1023x1023

22449.19

997.38

Time [ms]

1000

Proceessing time of GFD (ms)

800

600

400

200

0 15x15

31x31

63x63

127x127

255x255

5 511x511 1023x1023

Resolution [pixels]

Figure 4. FFT performance by resolutionn for GFD

Else we proved the speedup can achievee by GPU vs. CPU at 1.2 second in the term of time for the 1023x1023 image size. While the resolution increasing the perrformance of CPU instead of GPU it is nearly linear. Which absolutly a react for the speedup performance.

Table 2 showed the compaarison time of GFD on different sizes. For the GFD computation time, we were finding that the PU for each image size. GPU is most optimized than CP The implementation showeed an average of execution time between GPU vs. CPU. Unntil 127x127 image size, the processing time is nearly sam me but from 255x 255, GPU optimize than CPU gradually. 2500 GFD on CPU

2000

GFD on GPU

140

Time [ms]

160 1500

FFT

Speedup

120 100

1000

80 60

500

40 20

0

0 15x15

31x31

Figure 5.

63x63

127x127

255x255

511x511 1023x1023

l l Speedup factor of FFT onn GFD

In Figure 5, we showed the speedup factor of FFT on GFD, it acheive the maximum of performannce for image size 255x255. It can reach 142 x of ratio CPU vss. GPU. Either for this resolution, the speedup factor is outstannding for all image size. We can notice that 18x is the lower facctor of speedup of FFT.

Resolution [pixels] Figure 6. Performance of GFD on CPU and GPU

From the Figure 6, we observed that the performance of processing GFD on GPU is sppeed than CPU. The execution time can reach 1.2 second as an average time between GPU and CPU for 1023x1023 imagee size.

V.

CONCLUSION AND FUTURE WORK

The performance improvement of our work is impressive. Thus, our main purpose of this work was to speed up the processing of FFT which part of Generalized Fourier Descriptor as a solution to fast computing the vector of GFD. This last used to the following steps of recognition that does will be applied with SVM as a tool of classification. Also we can propose other processing application as a future works that the second pattern of recognition CGFD Clifford Generalized Fourier Descriptor. For this example, the same treatment will be applied whereas it optimizes the vector and the time. The rate of increase in performance of GPU’s is expected to outshine that of CPUs in the next few years, increasing the demand of the GPU as the processor of choice for image processing. REFERENCES [1]

F. Smach, C. Lemaitre, J. P. Gauthier, J. Miteran, and M. Atri,” Generalized fourier descriptors with applications to objects recognition in svm context “, Journal of Mathematical Imaging and Vision, vol. 30, no. 1, pp.43–71, 2008. [2] Image processing learning resources, Contents and Index, Image Transforms, Fourier Transform (2003), http://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm, Accessed in 25 Nov 2013. [3] D. Zhang, G. Lu,” shape-based image retrieval using generic fourier descriptor “, in Signal Processing: Image Communication, vol. 17, no. 10, pp. 825-848, 2002. [4] M. Nazmul Haque, M. Shorif Uddin,” Accelerating Fast Fourier Transformation for Image Processing using Graphics Processing Unit “, Journal of Emerging Trends in Computing and Information Sciences CIS journal, vol. 2, no.8, pp. 367-375, 2011. [5] M. Abdellah, S. Saleh, A. Eldeib, A. Shaarawi,” High Performance Multi-dimensional (2D/3D) FFT-Shift Implementation on Graphics Processing Units (GPUs) “, 6th Cairo International Biomedical Engineering Conference, Cairo, Egypt, 2012. [6] J. Balfour,” Introduction to CUDA CME343/ME339 “, NVIDIA Research, 2011. [7] CUDA Tutorial: The Golden Energy Computing Organization, [Online] http://geco.mines.edu/tesla/cuda_tutorial_mio/index.html, Accessed in 25 Nov 2013. [8] J. Kowalczuk, E. T. Psota, L. C. Pérez,” Real-Time Stereo Matching on CUDA Using an Iterative Refinement Method for Adaptive SupportWeight Correspondences “, IEEE transactions on circuits and systems for video technology, vol. 23, no. 1, pp. 94-104, 2013. [9] Best Practices in GPU-Based Video Processing, GPU technology conference, GTC 2012. [10] NVIDIA’s CUDA Programming Model Overview, NVIDIA Corporation, 2006. [11] C. Trujillo, J.G. Sucerquia,” Graphics processing units more than the pathway to realistic video games “, National University of Colombia, Dyna: general scientific publication of the area of technological sciences, vol. 78, no. 168, pp. 164-172, 2011. [12] CUFFT LIBRARY USER'S GUIDE, NVIDIA Corporation, 2012.