[ Team LiB ] |
![]() ![]() |
2.2 Thumbnail ClassIn our design, the image class is a container for image pixels and nothing else. Since the purpose of this application is to create thumbnail images, a thumbnail class is needed to handle file I/O and the thumbnail algorithm. The thumbnail class has the following properties:
The complete definition of the thumbnail class is shown in Section 2.3.2 on page 16. 2.2.1 Thumbnail AlgorithmEach pixel in the thumbnail image is found by averaging a number of pixels in the input image. The pixel value in the thumbnail image, T(x0,y0), is computed as shown in Figure 2.1, where factor is the desired reduction value. Figure 2.1. Computing the Thumbnail Pixel Value
A picture helps clarify this equation. Each pixel in the original image P is reduced, by averaging pixel values in image P, to a corresponding point in the thumbnail image T using the equation from Figure 2.1. In Figure 2.2, we show how a group of pixels in the original image is reduced to the group of pixels shown in the thumbnail image. Figure 2.2. Pictorial Representation of Thumbnail Computation
To further simplify our application, we ignore the condition created by integer arithmetic where the division by the reduction factor results in a fraction. For example, if the original image is 640x480 pixels in size, and the desired reduction factor is 6, the thumbnail image will be (640/6)x(480/6) pixels in size or 106.67x80. To avoid the fractional result, we ignore the last 4 pixels in each line, effectively making the thumbnail image (636/6)x(480/6) pixels in size or 106x80. |
[ Team LiB ] |
![]() ![]() |