You are on page 1of 3

(IJCSIS) International Journal of Computer Science and Information Security, Vol. 9, No.

9, September 2011

Multithreaded Image Processing


Jamil A. M. Saif
Computer Science Department Faculty of Computer Science and engineering Hodeidah University Hodeidah, Yemen e-mail: jamil_alabssi@yahoo.com

Hamid S. S. Alraimi
Computer Science Department Faculty of Computer Science and engineering Hodeidah University Hodeidah, Yemen e-mail: halraimi@gmail.com symbolic processing. An example of a high-level operation is object recognition. There is a big challenge concerning image processing due to time consuming computation, some researches address this problem using parallel environments[2,5 ] such as PVM, MPI, others used distributed parallel processing using java RMI, Sockets and Corba[4]. In image processing operations the existing approach to parallelism get constrained due to variant size of data and the required resources. Hence a system is required for the efficient controlling of image processing operation with variable data size. for this reason a multithreading approach is proposed. The contents of this paper is organize as follows :in section 2 image conversion is presented, in section 3 a multithreading and its related concepts are defined, in section 4 the results obtained from the experiments are described and discussed, finally the summarized conclusion is given.

Abstract real time image processing applications require a


huge amount of processing power, computing ability and large resources to perform the image processing applications. The nature of processing in typical image processing algorithms ranges from large arithmetic operations to fewer one. This paper presents an implementation of image processing operations using simultaneous multithreading, the performance of multithreading is analyzed and discussed, for the varying number of images. Keywords- multithreading; image processing; performance.

I. INTRODUCTION Recently digital image processing has a broad spectrum of applications, such as multimedia systems, business systems, monitoring, inspection systems, and archiving systems. In spite of digitization, storage, transmission, and display operations, extra functions are considered. They are as follows: image data compression and representation, image enhancement and reconstruction, image indexing, retrieval and matching, etc. and they are executed on application oriented servers. Generally three levels of image processing are distinguished to analyze and tackle the image processing application[1]: low-level operations, intermediate-level operations, and high-level operations. Low-level operations: Images are transformed into modified images. These operations Work on whole image structures and yield an image, a vector, or a single value. The computations have a local nature; they work on single pixels in an image. Examples of Low-level operations are: smoothing, convolution and histogram generation. An intermediate-level operations: Images are transformed into other data structures. These operations work on images and produce more compact data structures (e.g. a list). The computations usually do not work on a whole image but only on objects/segments (so called regions of interest ROI) in the image. Examples of intermediate-level operations are: region labeling and motion analysis. A high-level operations: Information derived from images is transformed into results or actions. These operations work on data structures (e.g. a list) and lead to decisions in the application. So high-level operations can be characterized as

II. IMAGE CONVERSION In this paper a low level image processing is used that will modify RGB colored image into grey scale one, the RGB image is transformed according to the following formula [6]:
I 1R 2 G 3 B.....................(1), where : 1 2 3 1, and I is grey scale value

For each pixel in RGB image the I grey scale value is calculated and this calculation is repeated by scanning the whole image starting from the upper left corner to the bottom right corner of the given image, and this calculation may be required for several images, these heavy computations need some way to reduce the cost of computation. III. MULTITHREADING AND ITS RELATED CONCEPTS Multithreading is a technique that allows a program or a process to do many tasks concurrently at the same time [9,10]. Multithreading allows a process to run tasks in parallel on a symmetric multiprocessing (SMP) system or a chip multithreading [7,8] (CMT) system, allowing the process to scale linearly with the number of cores or processors, which improves performance, increases efficiency, and increases throughput.

20

http://sites.google.com/site/ijcsis/ ISSN 1947-5500

(IJCSIS) International Journal of Computer Science and Information Security, Vol. 9, No. 9, September 2011

Running multiple processes concurrently is called multiprocess programming. A process is a heavyweight entity that lives inside the kernel. It consists of the address space, registers, stack, data, memory maps, virtual memory, user IDs, file descriptors, and kernel states. Where as a thread is a lightweight entity that can live in the user space or the kernel and consists of registers, stack, and data. Multiple threads share a process, that is, they share the address space, user IDs, virtual memory, file descriptors, and kernel states. The threads within a process share data, and they can see each other, to distinguish between a process and a thread see Fig. 1, where two threads within one process.

2. A text editor can perform writing to a file and print a document simultaneously with separate threads performing the writing and printing actions. In the text editor, you can format text in a document and print the document at the same time. There are fewer overloads when the processor switches from one thread to another. Therefore, threads are called lightweight process. On the other hand, when the processor switches from one process to another process the overload increases. Advantages of multithreading are: improved performance, minimized system resource usage, simultaneous access to multiple applications and program structure simplification. Improved performance provides improvement in the performance of the processor by simultaneous execution of computation and the I/O operation see Fig 2 . . Minimized system resource usage minimizes the use of system resources by using threads, which are the same address space and belong to the same process. Simultaneous access to multiple applications provides access to multiple applications at the same time because of quick context switching among threads. A thread is lightweight, so many threads can be created to use resources efficiently. The threads are all within a process see Figure 1, so they can share global data. A blocking request by one thread will not stop another thread from executing its task. Also, the process will not get context-switched because a thread is blocked. Multiprocess programming is much more difficult than multithreaded programming, performance is slower, and management of resources is difficult. Also, synchronization and shared memory use are more difficult with processes than with threads, because threads share memory at the process level and global memory access is easy with threads. The result of multithreading is increased performance, increased throughput, increased responsiveness, the ability to execute tasks repeatedly, increased efficiency, better management of resources, and lowered costs [3,7].

Figure 1.

A process with two threads of execution.

Multithreading [8] is a way of achieving multitasking in a program. Multitasking is the ability to execute more than one task at the same time see Fig. 2. Multitasking can be divided into Process-based multitasking and thread-based multitasking.

a)

IV.

EXPERIMENTS

b) Figure 2. a) with single task

.Net environments for implementing multithreading image conversion were used, testing the multithreading with variable number of RGB colored images (9, 15, 30 and 50) each of 600x400 pixels of size, converting images into grey scale according to the formula 1., that image conversion carried out using single thread as well as multithreading varies from 2 to 10 threads.
b) with two tasks

Process-based multitasking feature enables you to switch from one program to another so fast that it appears as if the programs are executing at the same time. Where as thread-based multitasking context-switch is extremely fast and can be in user space or at the kernel central processing unit (CPU) level. A process is heavyweight, so it costs more to context-switch than a thread. A single program can contain two or more threads and therefore, perform two or more tasks simultaneously see Figure

The obtained results are shown in Figure 3.,demonstrate the efficiency of multithreading. As noticed every image took around 2 [ms] of computation, and since for our experiments a laptop with a dual core cpu of 3000 MHz was used, at least two threads are needed to fully utilize the two cores, so that is illustrated in the Fig. 3, using two threads cause reducing execution time to about 50% , while for three threads and more some slight improvement is seen, and as the date size increase (number of images) the performance almost remains the same, this is due to the multithreading overhead in comparison with computation time.

21

http://sites.google.com/site/ijcsis/ ISSN 1947-5500

(IJCSIS) International Journal of Computer Science and Information Security, Vol. 9, No. 9, September 2011
[7] J. Manson and W. Pugh, "Semantics of Multithreaded Java", 2002. [8] N. Padua-Perez and B. Pugh, "multithreading in Java". [9] H. Schild, "C# The Complete Reference", Edition McGraw-Hill, 2002. [10] H. Shildt, "Java 2 The Complete Reference", Fifth Edition McGraw-Hill, 2002.

a)

b)

Figure 3. a) multithreading for 9 and 15 images b) multithreading for 30 and 50 images

V.

CONCLUSION AND

RECOMMENDATION

Image processing is a time consuming computation, for improving performance, multithreading was used. It is obvious from the Figure 3 the impact of date size and the contributing threads on the performance. It is recommended to use in future work heavier computation that needs significant time to enable showing the advantage of threads addition and utilize environment with more cores or processors to demonstrate the scalability of such systems.

REFERENCES
processing", Prentice [1] K. J. Anil, "Fundamentals of digital image Hall, april, 2004. [2] P. Czarnul, H. Krawczyk, "Dynamic Assignment with Process Migration in Distributed Environments. Recent Advances in PVM and MPI", Lecture Notes in Computer Science, Vol. 1697, 1999. [3] O. Edelstein, E. Farchi, Y. Nir, G. Ratsaby and S. Ur, "Multithreaded Java Program Test Generation", IBM SYSTEMS JOURNAL, VOL 41, NO 1, 2002. [4] R. Eggen and M. Eggen, "Efficiency of Distributed Parallel Processing Using Java RMI, Sockets and Corba, 2007. [5] A. Geist, A. Beguelin, J. Dongarra, W. Jiang, R. Manchek and V. Sunderam, "PVM Parallel Virtual Machine. A User Guide and Tutorial for Networked Parllel Computing.", Mit Presso, Cambridge, 1994,http://www.epm.ornl.gov/pvm. [6] W. Malina, S. Ablameyko and W. Pawlak, "Fundamental Methods of Digital Image Processing. (In Polish), 2002.

22

http://sites.google.com/site/ijcsis/ ISSN 1947-5500