Try the all-new QuickBooks Online for FREE.  No credit card required.

Multithreaded Image Processing

Document Sample
Multithreaded Image Processing Powered By Docstoc
					                                                              (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                             Vol. 9, No. 9, September 2011

                          Multithreaded Image Processing

                    Jamil A. M. Saif                                                          Hamid S. S. Alraimi
              Computer Science Department                                             Computer Science Department
      Faculty of Computer Science and engineering                             Faculty of Computer Science and engineering
                   Hodeidah University                                                     Hodeidah University
                     Hodeidah, Yemen                                                        Hodeidah, Yemen
            e-mail:                                             e-mail:

Abstract— real time image processing applications require a             symbolic processing. An example of a high-level operation is
huge amount of processing power, computing ability and large            object recognition.
resources to perform the image processing applications. The
nature of processing in typical image processing algorithms                 There is a big challenge concerning image processing due
ranges from large arithmetic operations to fewer one.                   to time consuming computation, some researches address this
This paper presents an implementation of image processing               problem using parallel environments[2,5 ] such as PVM, MPI,
operations using simultaneous multithreading, the performance           others used distributed parallel processing using java RMI,
of multithreading is analyzed and discussed, for the varying            Sockets and Corba[4].
number of images.
                                                                            In image processing operations the existing approach to
   Keywords- multithreading; image processing; performance.
                                                                        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
                       I.    INTRODUCTION                               size. for this reason a multithreading approach is proposed.
    Recently digital image processing has a broad spectrum of
                                                                            The contents of this paper is organize as follows :in section
applications, such as multimedia systems, business systems,             2 image conversion is presented, in section 3 a multithreading
monitoring, inspection systems, and archiving systems. In spite         and its related concepts are defined, in section 4 the results
of digitization, storage, transmission, and display operations,         obtained from the experiments are described and discussed,
extra functions are considered. They are as follows: image data
                                                                        finally the summarized conclusion is given.
compression and representation, image enhancement and
reconstruction, image indexing, retrieval and matching, etc. and
they are executed on application oriented servers.
                                                                                            II. IMAGE CONVERSION
    Generally three levels of image processing are
distinguished to analyze and tackle the image processing                   In this paper a low level image processing is used that will
application[1]: low-level operations, intermediate-level                modify RGB colored image into grey scale one, the RGB
operations, and high-level operations.                                  image is transformed according to the following formula [6]:

    Low-level operations: Images are transformed into                       I  α1R  α 2 G  α 3 B.....................(1),
modified images. These operations Work on whole image                       where : α1  α 2  α 3  1, and I is grey scale value
structures and yield an image, a vector, or a single value. The
computations have a local nature; they work on single pixels in             For each pixel in RGB image the I grey scale value is
an image. Examples of Low-level operations are: smoothing,              calculated and this calculation is repeated by scanning the
convolution and histogram generation.                                   whole image starting from the upper left corner to the bottom
                                                                        right corner of the given image, and this calculation may be
    An intermediate-level operations: Images are transformed
                                                                        required for several images, these heavy computations need
into other data structures. These operations work on images and         some way to reduce the cost of computation.
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                III. MULTITHREADING AND ITS RELATED CONCEPTS
image. Examples of intermediate-level operations are: region                Multithreading is a technique that allows a program or a
labeling and motion analysis.                                           process to do many tasks concurrently at the same time [9,10].
     A high-level operations: Information derived from images           Multithreading allows a process to run tasks in parallel on a
is transformed into results or actions. These operations work on        symmetric multiprocessing (SMP) system or a chip
data structures (e.g. a list) and lead to decisions in the              multithreading [7,8] (CMT) system, allowing the process to
application. So high-level operations can be characterized as           scale linearly with the number of cores or processors, which
                                                                        improves performance, increases efficiency, and increases

                                                                                                       ISSN 1947-5500
                                                                  (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                 Vol. 9, No. 9, September 2011
    Running multiple processes concurrently is called                      2. A text editor can perform writing to a file and print a
multiprocess programming. A process is a heavyweight entity                document simultaneously with separate threads performing the
that lives inside the kernel. It consists of the address space,            writing               and           printing            actions.
registers, stack, data, memory maps, virtual memory, user IDs,             In the text editor, you can format text in a document and print
file descriptors, and kernel states. Where as a thread is a                the document at the same time. There are fewer overloads
lightweight entity that can live in the user space or the kernel           when the processor switches from one thread to another.
and consists of registers, stack, and data. Multiple threads share         Therefore, threads are called lightweight process. On the other
a process, that is, they share the address space, user IDs, virtual        hand, when the processor switches from one process to another
memory, file descriptors, and kernel states. The threads within            process              the          overload            increases.
a process share data, and they can see each other, to distinguish          Advantages of multithreading are: improved performance,
between a process and a thread see Fig. 1, where two threads               minimized system resource usage, simultaneous access to
within one process.                                                        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.
           Figure 1.   A process with two threads of execution.               Multiprocess programming is much more difficult than
                                                                           multithreaded programming, performance is slower, and
                                                                           management of resources is difficult. Also, synchronization
    Multithreading [8] is a way of achieving multitasking in a
                                                                           and shared memory use are more difficult with processes than
program. Multitasking is the ability to execute more than one
task at the same time see Fig. 2. Multitasking can be divided              with threads, because threads share memory at the process level
                                                                           and global memory access is easy with threads.
into Process-based multitasking and thread-based multitasking.
                                                                               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].

                                                                                                 IV.     EXPERIMENTS
                                                                               .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.
           Figure 2. a) with single task      b) with two tasks                The obtained results are shown in Figure 3.,demonstrate the
                                                                           efficiency of multithreading. As noticed every image took
    Process-based multitasking feature enables you to switch               around 2 [ms] of computation, and since for our experiments a
from one program to another so fast that it appears as if the              laptop with a dual core cpu of 3000 MHz was used, at least
programs      are    executing     at     the    same      time.           two threads are needed to fully utilize the two cores, so that is
Where as thread-based multitasking            context-switch is            illustrated in the Fig. 3, using two threads cause reducing
extremely fast and can be in user space or at the kernel central           execution time to about 50% , while for three threads and more
processing unit (CPU) level. A process is heavyweight, so it               some slight improvement is seen, and as the date size increase
costs more to context-switch than a thread.                                (number of images) the performance almost remains the same,
                                                                           this is due to the multithreading overhead in comparison with
    A single program can contain two or more threads and                   computation time.
therefore, perform two or more tasks simultaneously see Figure

                                                                                                       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.



              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


[1] K. J. Anil, "Fundamentals of digital image            processing", Prentice
    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,
[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,
[6] W. Malina, S. Ablameyko and W. Pawlak, "Fundamental Methods of
    Digital Image Processing. (In Polish), 2002.

                                                                                                                   ISSN 1947-5500

Shared By: