Multithreading Image Processing In Single-core And Multi .

2y ago
17 Views
2 Downloads
289.80 KB
5 Pages
Last View : 11d ago
Last Download : 3m ago
Upload by : Mika Lloyd
Transcription

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 4, No. 9, 2013Multithreading Image Processing in Single-core andMulti-core CPU using JavaAlda KikaSilvana GrecaDepartment of InformaticsFaculty of Natural Sciences, University of TiranaTirana, AlbaniaDepartment of InformaticsFaculty of Natural Sciences, University of TiranaTirana, AlbaniaAbstract—Multithreading has been shown to be a powerfulapproach for boosting a system performance. One of the goodexamples of applications that benefits from multithreading isimage processing. Image processing requires many resources andprocessing run time because the calculations are often done on amatrix of pixels. The programming language Java supports themultithreading programming as part of the language itselfinstead of treating threads through the operating system. In thispaper we explore the performance of Java image processingapplications designed with multithreading approach. In order totest how the multithreading influences on the performance of theprogram, we tested several image processing algorithmsimplemented with Java language using the sequential one threadand multithreading approach on single and multi-core CPU. Theexperiments were based not only on different platforms andalgorithms that differ from each other from the level ofcomplexity, but also on changing the sizes of the images and thenumber of threads when multithreading approach is applied.Performance is increased on single core and multiple core CPU indifferent ways in relation with image size, complexity of thealgorithm and the platform.Keywords—multithreading; image processing; multi-core; JavaI.INTRODUCTIONIn recent years, Java language has become a popular choicefor development of multithreaded applications due to thelanguage multithreading support. Multithreaded programmingallows simple identification of the sections of code that can beexecuted concurrently to exploit parallelism. The programsmust be able to exploit this kind of parallelism in order to getperformance gains in computing. There are two different waysto implement concurrent applications. The first approach isthrough the creation of processes, with all the communicationmade through messages, which are responsible for keeping allthe necessary information for the programs, including registercontent and memory space [1]. The second approach usesthread, which are also known as light processes [2]. A thread isa point of execution within a process and they represent a keyconcurrency model supported by modern computers,programming languages, and operating systems. The threadsexchange information only through shared memory and can beup to 20 times faster in their creation time when compared toprocesses [3].A multi-threaded process has multiple points of concurrentexecution within the process [4]. The use of multiple threadsallows an application to distribute long running tasks so thatthey can be executed in parallel. This is also possible withsignificant advances of multi-core systems. Today, multi-coreprocessors are widely deployed in both server and desktopsystems. The performance of multi-threaded applications couldbe improved on multi-core based systems because theworkload of threads could be dispatched to cores, which workin parallel [5].One of the good examples of applications that benefit frommultithreading in a multi-core processor is image processing.Image processing “refers to the manipulation and analysis ofpictorial information” [6]. The main idea of parallel imageprocessing is to divide the problem into simple tasks and solvethem concurrently, in such a way the total time can be dividedbetween the total tasks (in the best case) [7]. The general ideabehind image processing involves examining image pixels andmanipulating them. Image processing can be a time consumingtask based on the matrix structure of the image leading thisprocess towards a multithreading algorithm.Many authors have addressed the multithreading topic injava on multi-core systems. The java as a suitableprogramming language for parallel software and the power ofmulti-core processing is studied by Peter Bertels and DirkStroobandtin [8]. In [9], authors studied and implementedparallel multi-threaded implementations of two popularclustering algorithms: k-means and mean-shift. Theexperimental results show that good parallel implementationsof those algorithms are able to achieve nearly linear speedupson multicore processors. In [10] Mahmood has implementedthe imaging filter on multi-core processors for win32 platform.He shows that for large images, the parallel implementationapproaches Amdahl’s ideal curve. In [4] authors observed thatmultithreading leads to tune the application performanceconsiderably. The performance and scalability issues ofmultithreaded Java applications on multicore systems arestudied in [11]. This interesting topic has solicited manyscientific works so far.In our work we studied how the algorithm performancechanged when multithreading approach is applied on differentsingle core and multi-core platforms. We also studied howcomplexity of the algorithm and the image size of the imagesinfluence the performance.In order to exploit how multithreading can improve theperformance of the algorithm, we have done some experimentswith several image processing algorithms such as brightness,contrast and steganography executed on either single-core CPUor multi-core CPU using single-thread and multithreading165 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 4, No. 9, 2013approaches in Java. The algorithms that we have taken inconsideration differ from each other from the level ofcomplexity. As the image size increases, the number ofcalculations increases too. For this reason we haveexperimented with different sizes of images. The difference inthe algorithms and image size would influence on a furtherchange of the level of complexity.We measured the algorithms processing time on differentplatforms and image sizes that we took in consideration.In this paper, we have provided insight into Javamultithreading approach performance on single and multi-coreCPU platforms and hardware suggesting the combinationcomplexity and image size that gives the best performance.Section I gives a brief introduction and related work. Therest of the paper is organized as follows. Section II presents anoverview of multithreading programming and the algorithmsimplemented with this approach. Section III outlines theexperimental setup including test programs and specificationsof the experimental platforms. Section IV presents the resultsand section V gives a brief analysis of the results. The paper isconcluded in Section VI and VII by presenting the conclusionsand further work.II. MULTITHREADING PROGRAMMINGFirst, in creating a multithreaded algorithm, there are threebasic considerations. The first step is to identify theparallelism. This may mean simply decomposing the problemdomain of a conventional algorithm into several sections. Thesecond step is to control the access to shared data items. Thethird step is to optimize the algorithm [4].The application running in the operating system is eithersingle-threaded or multi-threaded. Single threaded applicationsrequire one thread to run on the CPU. Whereas a multithreadedprogram contains two or more parts that can run concurrently.We have implemented three image processing algorithmsusing Java. Java has become a leading programming languagesoon after its release and it is an emerging option for HighPerformance Computing [12]. Java supports multithreading andwe can construct single-thread as well as multi-threadapplication with it. A multi-threaded program in java has manyentry and exit points, which are run concurrently with themain() method. The three constructed algorithms have beenimplemented using single thread approach and multithreadingapproach. In the multithreading approach the shared memory inwhich the threads operate is the matrix of the image pixels. Wehave used the Java packages to grab the pixel matrix of theimage that has to be processed. Then different threadsmanipulate different parts of the matrix depending on thealgorithm. The work task and the part of the matrix that eachthread has to manipulate are determined by the main thread.The time that is necessary to manipulate all the matrix either bya single thread or by all the threads is registered.III.core and multiple-core platforms. The first and the secondalgorithms change brightness and contrast of the chosen imageand display the changing image. Brightness and contrast arevery important features of an image. Brightness refers to theoverall lightness or darkness, whereas contrast is the differencein brightness between objects or regions. For the algorithm ofthe brightness we have used the formula :Arithmetic mean model (r g b) / 3 (1)After finding the mean from the formula 1 we use a valueinput from the user to change the brightness of the imagefollowing these steps: Subtract the overall mean from every color value ofevery image pixel. Add the mean value multiplied by the brightness valueto every color value.In the Figure 1 a view from the brightness application ispresented.Fig. 1. A screenshot from the brightness applicationThe contrast algorithm will multiply every color value by ascale factor determined by the user. It has a little lesscalculation than the brightness algorithm.The third algorithm is from the field of steganography.Steganography is the art of hiding the fact that communicationis taking place by hiding information in other information [13].In our implementation of steganography algorithm we hide amessage in an image in such a way that the modification of theimage is imperceptible. Since people perceive red and greencolor brighter than the blue color, the image would be darker inthe red and green pixels and brighter in the blue pixels. In orderto hide the original message in the image we have constructedan algorithm that change only the last bit of the blue color ofthe image pixels using the message and a private key as well[14]. The complexity of this algorithm is greater than the othertwo. A view from the application that implement the thirdalgorithm designed with multithreading approach is given inthe Fig. 2.EXPERIMENTAL SETUPA. Testing programsInitially, three image processing algorithms have beenchosen to test the multithreading approach on different single-Fig. 2. A screenshot from the steganography algorithm application166 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 4, No. 9, 2013B. Experimental platformsSince the first multicore processor was released over adecade ago, today’s processors implement up to a dozen coresand this number is expected to increase because of Moore’slaw [15]. Multi-core CPU-s support advanced capabilities, suchas multithreading and parallel processing. The advantage of amulti-core processor is increased speed. They are widely usedacross many application domains including embedded,network, graphics etc. The experiments were conducted on theWindows Operating Systems (Windows XP and Windows 7),single-core and multiple-core CPU-s platforms.In Table 1 is given a brief description of the four usedexperimental platforms.TABLE I.PlatformPlatform1Platform2Platform3Platform4THE DESCRIPTION OF EXPERIMENTAL PLATFORMSProcessorAMD Athlon ,1.11GHzIntel Pentium 4, 3.2 GhzIntel CoreTM2 DuoProcessors, 2.2 GHzIntel Core i5-4570RProcessor, 2.7 GHZOperatingSystemNumberof CoresWindows XP1Windows XP1Windows 72Windows 74We redesigned the same algorithms with multithreadingapproach. Then we varied the number of threads from 1 to 10and then the multiples of 5 thus 15, 20, 25, 30 100.The results from the experiments showed that on theplatform with single core (platform 1 and platform2) theprocessing time of the algorithms decreases in a considerablyrates when multithreading approach is applied. However whenthe number of threads increases over 10 threads the processingtime does not decrease, but remains almost constant with atendency to increase more than in the case when the singlethread approach is applied. Generally when the number ofthreads increased from 1 to 10 the average processing time hasthe tendency to remain constant and when the number ofthreads increases more than 10 the processing time increasesand it becomes bigger than the executing time in single threadapproach.Table 3 shows the result for the first platform. The resultrefers to the average executing processing time for the 10 firstthreads for the small, medium and large images.TABLE III.We used the first and second platform to test the algorithmsaccording to the single thread and multithreading approach insingle core, and we used the third and fourth platform to testthe algorithms in the multi-core CPU.C. Input DataNot only the platforms but also the size of the input imagesinfluence on the execution time of the algorithms. We performthe experiments using three image sizes: 371*281, 500*500and 1024*768. We refer to the dimension of the images in theexperiments as S(Small), M(Medium) and L(Large). Theresults of these experiments are presented in the next section.IV. EXPERIMENTAL RESULTSEvery algorithm was repeated 10 times and the average ofall the results was recorded.ImageSizeSmallMediumLargePlatformImage L)TABLE .569824.3AVERAGE RESULTS OF THE FIRST 10 THREADS FOR THESECOND PLATFORMImageSizeSmallMediumLargeTABLE V.TABLE aphy1548.415.510029.9271.8AVERAGE RESULTS OF THE FIRST 10 THREADS FOR THETHIRD PLATFORMImageSizeSmallMediumLargeSINGLE -THREAD APPROACH RESULTSAlgorithms 016311721014321116471826109Contrast1841109The tables 4,5,6 display the average executing processingtime for the 10 first threads in case of small, medium and largeimages for the second, third and fourth platform.From the implementation of the tests of the single threadapproach algorithms on the single-core and multiple-coreplatforms we recorded the results shown in Table 2:TABLE II.AVERAGE RESULTS OF THE FIRST 10 THREADS FOR THEFIRST anography1131.315.459.646.9162.3AVERAGE RESULTS OF THE FIRST 10 THREADS FOR THEFOURTH .723.2101V. PERFORMANCE ANALYSISAs we expected when single thread approach of thealgorithms is applied, the processing time decrements if weincrease the speed and the number of the cores from oneplatform to the other (table 2). When multithreading is applied,167 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 4, No. 9, 2013the CPU without cores improves the processing time with agreater rate than when the number and cores of the processorincrease in the case when the size of the image is small ormedium and the complexity of algorithm is not big.The results showed that the multithreading approachimproves the performance processing time of algorithms eitherin single-core or multi-core CPU platforms but thisimprovement is different.In the first and second platform where the number of coresis 1, the increase rate of processing time is more than 48.27 %when the size is small and the algorithms are brightness andcontrast. In the other cases this rate varies from 15.9 to 44.82.The results do not fall in this interval when the size of theimage is large and the algorithm is contrast (first platform 0.9and the second 2) and when the algorithm is steganography(first platform 5.5 and the second 8.1).In single core the best results is given by the combination ofsmall image size and less complex algorithm whereas in multicore CPU the combination of small image size and morecomplex algorithm improves the performance. Multithreadingprogramming can improve the performance on multi-core CPUwhen complex image processing algorithms is applied.The third and the fourth platform give different results. Theresult of performance increase rates can be even negativewhich means that the processing time of the single threadapproaches are better than multithreading approach. The resultfor the third and fourth platform is displayed in the tables 7 and8.TABLE VII.PERFORMANCE INCREASE RATE FOR THE THIRD PLATFORMImageSizeSmallMediumLargePerformance increase 18,728,514,3-218,7-51,65,8VII. FUTURE WORKOthers studies are needed to be done to understand thecauses of these behaviors. Future work includes developing aC# environment with image processing algorithms in order tocompare it with Java applications in different platforms. Theinfluence that parallel implementation of these multithreadingapproach algorithms will be another interesting task for thefuture. We assume that we can improve the processing time asit was shown for Wu-Lee Steganography Algorithm [17].[1][2][3]TABLE VIII.PERFORMANCE INCREASE RATE FOR THE FOURTH PLATFORMImageSizeSmallMediumLargePerformance increase -63,606,3-72,211,57,3[4][5]The third platform gives the best result when the size of theimage is small for all the algorithms as shown in the table 7.When the size of the image is large it gives the worst result.When the complexity of the algorithm is bigger the processingtime tends to be less.In the fourth platform the image size seems to have noinfluence as much as in third platform in the processing time.But the complexity of the algorithm influence the processingtime by reducing it.From both platforms with multi core CPU the combinationsmall image size and complex algorithm gives the best results,improving the processing time when multithreading occurs.VI. CONCLUSIONSJava language is very suitable to develop image processingapplications due to its features and the free packages that itoffers for this purpose. New open source java image processingpackages is often added [16].It is very important to understand how to improve theperformance of this kind of applications using managedlanguages like Java. Through some experiments with the imageprocessing algorithms the impact that multithreading approachhas on performance is analyzed in single-core and FERENCESJ. F. CORSINI, L. G. FREITAS, and F. D. ROSSI, “ComparandoProcessos entre Unix e Windows". Revista INFOCAMP. March, 2006.SCHEFFER, R. “Uma visao Geralsobre Threads". Revista CampoDigit@l. Volume 2.N umero 1.Paginas: 7-12, 2007.B. BARNEY, “POSIX Threads Programing". Lawrence LivermoreNationalLaboratory.2011. https://computing.llnl.gov/tutorials/pthreads .M.Shanthi, A.Anthony Irudhayaraj. Multithreading, “An EfficientTechnique for Enhancing Application Performance”, InternationalJournal of Recent Trends in Engineering, Vol 2, No. 4, November 2009,pp. 165-167.Kuo-Yi Chen, Fuh-Gwo Chen, “The Smart Energy Management ofMultithreaded Java Applications on Multi-Core Processors”,International Journal of Networked and Distributed Computing, Vol. 1,No. 1, January 2013, pp.53-60.Gregory A. Baxes, Digital Image Processing: Principles andApplications. John Wiley and Sons, Inc, New York, NY, 1994.S. Saxena, N. Sharma, Sh. Sharma, “Image Processing Tasks usingParallel Computing in Multi core Architecture and its Applications inMedical Imaging”, International Journal of Advanced Research inComputer and Communication Engineering Vol. 2, Issue 4, April 2013Peter Bertels, Dirk Stroobandt, “Java and the Power of Multi-CoreProcessing”. The Second International Conference on Complex,Intelligent and Software Intensive Systems, CISIS 2008, pp. 627 – 631Honggang Wang, Jide Zhao, Hongguang Li, Jianguo Wang. “ParallelClustering Algorithms for Image Processing on MultiCore CPUs”.International Conference on Computer Science and SoftwareEngineering, 2008.Faran Mahmood, “Parallel Implementation of Imaging Filters on MultiCore Processors for Win32 Platform”. Proceedings of the 4thInternational Conference on Open-Source Systems and Technologies,ICOSST, 2011.Kuo-Yi Chen,, J. Morris Chang, Ting-Wei Hou. :Multithreading in Java:Performance and Scalability on Multicore Systems:, IEEE Transactionson Computers 2011 (vol. 60 no. 11), pp. 1521-1534G.L. Taboada, J. Touriño, R. Doallo, “Java for high performancecomputing: assessment of current research and practice:, in: Proc. 7thIntl. Conference on the Principles and Practice of Programming in Java,PPPJ’09, Calgary, Alberta, Canada, 2009, pp. 30–39.Obaida Mohammad Awad Al-Hazaimeh, “Hiding Data in Images UsingNew Random Technique”, IJCSI International Journal of ComputerScience Issues, Vol. 9, Issue 4, No 2, July 2012, pp 49-53.168 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 4, No. 9, 2013[14] S. Greca, A. Kika, O. Qirici, ”A new steganography method for hidingthe message in the image”, Buletin of the Natural Sciences Faculty, No.14, 2012, pp. 211-220.[15] G. E. Moore. “Readings in computer architecture. Chapter Crammingmore components onto integrated circuits”, Morgan KaufmannPublishers Inc., San Francisco, CA, USA, 2000, pp 56–59.[16] Tobias Pietzsch, Stephan Preibisch, Pavel Tomanc and Stephan Saalfeld,“ImgLib2 generic image processing in Java”, BioInformatics, Vol. 28no. 22 2012, pp. 3009–3011.[17] S. Greca, E.Martiri, “Wu-Lee Steganographic Algorithm on BinaryImages Processed in Parallel”, International Journal of Video & ImageProcessing and Network Security IJVIPNS-IJENS Vol: 12 No: 03,2012,pp 1-4.169 P a g ewww.ijacsa.thesai.org

behind image processing involves examining image pixels and manipulating them. Image processing can be a time consuming task based on the matrix structure of the image leading this process towards a multithreading algorithm. Many authors have addressed the multithreading topic in -core systems. The java as a suitable

Related Documents:

PDF of this presentation Lecture 12: Multithreading Design Patterns and Thread-Safe Data . Multithreading Design Patterns 13. Question period on mutexes, condition variables, and sempahores 14. Suppose we want to use some standard data structures in our multithreaded progr am Th

The input for image processing is an image, such as a photograph or frame of video. The output can be an image or a set of characteristics or parameters related to the image. Most of the image processing techniques treat the image as a two-dimensional signal and applies the standard signal processing techniques to it. Image processing usually .

L2: x 0, image of L3: y 2, image of L4: y 3, image of L5: y x, image of L6: y x 1 b. image of L1: x 0, image of L2: x 0, image of L3: (0, 2), image of L4: (0, 3), image of L5: x 0, image of L6: x 0 c. image of L1– 6: y x 4. a. Q1 3, 1R b. ( 10, 0) c. (8, 6) 5. a x y b] a 21 50 ba x b a 2 1 b 4 2 O 46 2 4 2 2 4 y x A 1X2 A 1X1 A 1X 3 X1 X2 X3

Digital image processing is the use of computer algorithms to perform image processing on digital images. As a . Digital cameras generally include dedicated digital image processing chips to convert the raw data from the image sensor into a color-corrected image in a standard image file format. I

What is Digital Image Processing? Digital image processing focuses on two major tasks -Improvement of pictorial information for human interpretation -Processing of image data for storage, transmission and representation for autonomous machine perception Some argument about where image processing ends and fields such as image

Digital image processing is the use of computer algorithms to perform image processing on digital images. As a subfield of digital signal processing, digital image processing has many advantages over analog image processing; it allows a much wider range of algorithms to be applied to the in

Corrections, Image Restoration, etc. the image processing world to restore images [25]. Fig 1. Image Processing Technique II. TECHNIQUES AND METHODS A. Image Restoration Image Restoration is the process of obtaining the original image from the degraded image given the knowledge of the degrading factors. Digital image restoration is a field of

validated awards is a matter of prime importance to the OU. The OU will take any action it considers necessary under its Royal Charter to protect the quality of validated programmes of study and the standard of its validated awards. A1.6 Quality assurance As a UK University, the OU is subject to the requirements and expectations of UK higher education, as represented by the Quality Assurance .