Energy Consumption and Quality of Approximate Image Transformation

The paper analyses a problem of effective image processing in mobile devices with limited resources. We analyse various approximate calculation methods for improving energy characteristics of components of image processing algorithms that are especially energy and CPU resource greedy. We research an image transformation applying the Twirl effect using data specialization (caching in look-up tables) and approximate computation of the trigonometric functions using Taylor series, Padé rational fractions and Chebyshev polynomials. Quality of transformed images is evaluated using standard image quality metrics. Based on the experimental results, the recommendations for mobile application developers are formulated. Ill. 8, bibl. 12, tabl. 1 (in English; abstracts in English and Lithuanian)


Introduction
When developing software for mobile devices (such as laptops, tablets, PDAs, smart phones, etc.) it is very important to take the amount of actually available hardware resources into account.The resources (CPU speed, RAM size, battery capacity) are usually very constrained.Therefore, it is important to look for the methods allowing to save on the consumption of resources required for the provision of a service at the expense of other characteristics such as service quality [1,2].
One of the aspects of services provided by a mobile device is the quality of images, videos or graphical user interfaces (GUIs) rendered on the screen of a mobile device [3].Due to the smaller screen size, the user is often satisfied with poorer image quality.Therefore, when developing GUIs and rendering images (e.g., in mobile photo editing applications), software solutions are required for the implementation of resource-aware algorithms that produce the required result at acceptable quality loss (we do not analyze the hardware-based solutions to the problem here).
This paper analyses the implementation of image transformation algorithm in a mobile environment using the approximate computation methods.Energy consumption vs. image quality trade-offs are analyzed using image quality metrics.Finally, recommendations for mobile application developers are formulated.

Data specialization and approximate computation
We consider two methods for improving efficiency of resource-greedy calculations: 1) data specialization (using caching in look-up tables); and 2) approximate computation (using function approximation).
Data specialization [4] involves separation of early and late computations, where early computations are performed in advance and the results are stored in look-up tables.
Such look-up tables can be generated on demand by metaprograms using the meta-programming methods [5].

Image transformation using approximately calculated trigonometric functions
To demonstrate image transformation using the approximate computation methods, we have selected the Twirl effect (see Fig. 1).The Twirl effect distorts an image by rotating a layer around its centre.This effect is often provided by image editing software.The algorithm for implementing the Twirl effect is given in Fig. 2. Using data specialization, we calculate the sine and cosine values, and the difference of adjacent values at a meta-program (i.e., program generator) level and store values in a data array.Also the function for angle reduction and linear interpolation between function argument values is generated (Fig. 3).

Evaluation of image quality
Evaluation of image quality is often a subjective process, which requires experience and expert knowledge.However, quantitative image quality metrics [7,8] also can be used such as: 1) Normalized Absolute Error (NAE) here   is the color value of the original image at is the color value of the transformed image; and m , n are maximal indices of row and column pixels.
2) Peak Signal-to-Noise Ratio (PSNR), measured in decibels (dB) here MSE is Mean Square Error and If the PSNR value is higher than 30 dB, image quality is excellent; PSNR between 25 dB and 30 dB means good quality; PSNR less than 20 dB means poor quality.
3) Laplacian Mean Square Error (LMSE) The larger LMSE value means poorer image quality.

Research method
The research was performed on a laptop computer with Windows XP Professional OS, Intel Core 2 Duo E6420 2.13 GHz CPU, 2 GB RAM, Li-ion battery pack SQU-503 10.8 V, 4800mAh.Windows XP is still installed on a majority of world computers (May, 2011 data).Battery drain was measured using the Intel Application Energy Command Line Tool (a part of the Intel Application Energy Toolkit, available from http://software.intel.com/en-us/articles/application-energy-toolkit/), which provides total and net energy consumption of an application running on a battery-operated system.
Selected greyscale images (Lena, Mandrill and Peppers) from the USC-SIPI Image Database (available at http://sipi.usc.edu/database/database.php) were transformed by the Twirl effect with different rotation angle values using standard library trigonometric functions and approximate computation functions.Execution time and energy consumption of standard and approximate twirling functions during image generation were measured (image rendering on the screen was not included in the experiment).The obtained images were compared using image quality metrics.Each experiment was repeated 5 times and average values were calculated.
For approximation of sine and cosine functions, metaprograms were developed, which generate Java (a popular language for developing mobile applications) code for a required polynomial order of the Taylor series and the look-up table size.
As a comparison, a chebyfit function from the Python library mpmath is used to generate the near-optimal Chebyshev polynomials in the defined interval, and the pade function is used to calculate the Padé rational approxi-mants of a required order of polynomials in the numerator and denominator of a rational fraction.

Research results and evaluation
The research results are presented in Fig. 4-Fig.7. The markings used in the charts are explained in Table 1.Energy savings using the approximately computed trigonometric functions as compared to the standard librarybased implementations are summarized in Fig. 4. Fig. 4. Energy savings using approximate functions (function no. on x-axis, see in Table 1) as compared to standard Java Math library functions Evaluation of image quality loss calculated using the NAE (Eq.4), PSNR (Eq.5) and LMSE (Eq.7) metrics is given in Figs.5-7.
After evaluating the energy consumption measurements and the results of the image quality metrics, we claim that the best ratio of image quality vs. energy consumption can be achieved using the 4-term and 6-term Chebyshev polynomials.Other approximate computation methods also can be used, however using less accurate methods may lead to various image rendering artefacts, which cannot be attributed to the image transformation algorithm itself.Moreover it should be noted that quality loss when rendering images on small-sized screens of mobile devices in most cases is almost unnoticeable by the human eye (see Fig. 8).

Related work
Related research is performed on the hardware level, e.g. using domain-specific accelerators of energy-aware graphics operations [9], and on the software level using the energy-optimal combination of parameter values of image compression and resize operations [10].Data specialization methods are also applied for improving characteristics of various Java programs, including in image processing algorithms [11].The energy efficiency of the applicationspecific graphical operations performed on a mobile device is addressed in [12].

Conclusions and future work
The approximate computation methods can be applied in the image processing algorithms with user-acceptable loss of image quality.This is especially relevant in mobile devices, where system factors (e.g., smaller screen size) and external factors (e.g., high sunlight) prevent a user from enjoying images at a highest quality.The designer of mobile applications can evaluate the quality of pictures and interfaces rendered on screen using image quality metrics (such as NAE, PSNR and LMSE) and select approximate calculation methods that produce the required result without noticeable loss of quality while at the same time allow saving energy consumed by a mobile device.
Using the approximate calculation methods allow to save up to 6% of energy in a mobile environment when transforming the greyscale images using the Twirl effect.The best results can be achieved using 4-term and 6-term Chebyshev approximations of the trigonometric functions used in image transformation algorithms instead of standard library-based implementations.
Future work will involve experimental research of wide range of image processing operations.

Fig. 1 .
Original Peppers image (a) and image processed with the Twirl effect (b)

Fig. 5 .
Fig. 5. Image quality according to the NAE metric vs. energy savings for 12 approximate computation functions from Table 1

Fig. 6 .
Fig.6.Image quality according to the PSNR metric vs. energy saving for 12 approximate computation functions from Table1

Fig. 7 .Fig. 8 .
Fig. 7. Image quality according to the LMSE metric vs. energy saving for 12 approximate computation functions from Table 1