Image Processing Reference
In-Depth Information
FIGURE 14 The visual representation of Highlight image filter's algorithm.
4 Description of the optimized implementation of
smart contrast and highlight Using “Byte Buffer”
Techniques
The byte buffer stores byte representation of the image, namely, Blue, Green, Red, and Alpha
components in this order for each pixel as in Figure 15 . An additional buffer is required for
filters. such as Sharpen or Blur to avoid altering the original pixels, since the new value of the
current pixel depends on its neighboring pixels for these filters.
FIGURE 15 Image representation storage in the byte buffer that keeps each pixel's four com-
ponents.
First step in the optimization algorithm is to obtain an object of type BitmapData (more
details about this predefined class and the next ones can be found from Refs. [ 4 , 5 ] Web site)
using LockBits method of Bitmap C# class. In next step, Scan0 property is accessed on the
obtained object in order to get the address of the first pixel in the image. Once we have this
address, all the image data from it are copied to the byte buffer using the overloaded Copy
method of Marshal C# class. The third step is different from a filter to another and represents
the calculations done on the byte buffer in order to filter the image. Finally, the byte buffer
will contain the byte representation of the filtered image. By using the buffer, we avoid call-
ing SetPixel method on a Bitmap object each time the pixels needs to be set to the filtered
value, which would be time consuming since the Bitmap object is accessed as many times
as the number of pixels in the image. The next step is to copy the filtered buffer back to the
address of the first pixel of the image using the overloaded Copy method. The last step is to
unlock the Bitmap object, using UnlockBits method.
This optimization can be applied to any filter since it focuses on reducing the execution time
related to image processing, not to the filter's action. The average speedup using this optim-
ization technique is 22 times considering filters such as Smart Contrast, Highlight, Sharpen,
Blur, Invert and Color.
 
 
Search WWH ::




Custom Search