Analysis of the Image Postprocessing Requirements
To access the new features, we need to first define some new GUI elements. For this reason the analysis starts with the photo_editor requirement key. |
8.2.1 The photo_editor Requirement
Figure 8.1 shows the changes to the photo editor GUI. The functionalities implemented in this chapter are advanced image-processing operations and are not related to the already implemented features. Therefore, a new tab is added to the existing tab control. This new tab will hold the new controls used for the functionalities implemented in this iteration. The layout is shown in the lower part of Figure 8.1. The contrast, brightness, and color functionalities are implemented using TrackBar controls. Because of their appearance, the TrackBar controls are sometimes referred to as sliders.
Figure 8.1. The Photo Editor GUI
Some image-processing algorithms that are applied to the whole image can take a long time. By "long," we mean not at interactive speed; the user must wait for the result of the calculation for multiple seconds. Therefore, we will provide an image preview pane. This preview pane shows a thumbnail image of the loaded picture. If the user changes a control setting, the preview image will immediately show the result. In this way, the user can interactively check and adjust the requested image operations before applying these changes to the image, something that will take some time.
If the user decides that the image operation shown in the preview is as expected, then the operation can be applied to the whole image by using the provided Apply button.
If the applied changes turn out to be not as expected or if the Apply button was pressed by mistake, the user can revert to the originally loaded image by selecting the Reset button.
In addition, we will provide a button for the red eye removal tool. If the red eye removal tool is selected and the mouse is moved within the image area, then a red rectangle with a width and height of 10 pixels is shown at the current mouse position. If the user then clicks on the image, the area within the shown rectangle will be taken to apply the red eye removal functionality. The rest of the image, outside the shown rectangle, stays untouched.
The plugins (or components) can be written in any language supported by Visual Studio.NET.
8.2.2 The image_brightness Requirement
The brightness of the image can be adjusted according to the selected value of the contrast track bar. The brightness of the image is calculated by taking the color values of the pixels and adding the value of the brightness control. The colors are distributed according to the following formula:
value*0.299 = red, value*0.587 = green, value*0.114 = blue
The range of the slider is 300 to 300. To make the application more responsive, all changes are shown in the preview window first. If the user wants to make the changes permanent, then the Apply button must be pressed. This results in recalculating the whole image. If the changes are not satisfactory, users can press the Reset button, which resets the image to the originally loaded image. If the plugin component cannot be found in the application directory, an exception is thrown.
8.2.3 The image_contrast_and_color Requirement
The contrast is adjusted using histogram calculation and an equalization technique. The formula for histogram equalization is provided by the customer. The user can provide a correction factor using a TrackBar control. The range of the control is 100 to 100, and the color values are distributed according to the following formula:
value*0.299 = red, value*0.587 = green, value*0.114 = blue
In addition to the contrast adjustments, users can change the color values of all pixels in the image by using TrackBar controls. Each of the RGB color components is adjustable via its own control in the range of 100 to 100. The value of the slider is added to the corresponding color component of each pixel in the image.
To make the application more responsive, all changes are shown in the preview window. If the user wants to make the changes permanent, the Apply button must be pressed. This will result in recalculation of the entire image. If the changes were not to the satisfaction of the user, a Reset button is provided that resets the image to the originally loaded image.
If the dynamically loadable component cannot be found in the application directory, an exception is thrown.
8.2.4 The image_special_effects Requirement
The special effect provided is a red eye removal tool. The tool can be selected by clicking the provided button on the GUI. If the tool is selected and the mouse is within the area of the image, then a red rectangle is shown to indicate the area where the red eye removal will take effect. The rectangle will be 10 pixels wide and 10 pixels high. The rectangle is drawn in red, and its origin is the current position of the mouse. On a mouse click, the calculation is applied to the part of the image that is enclosed in the square. The red eye reduction is calculated by reducing the red component of the pixels in the selected area to 80 percent of its original value; the other color values are untouched.
If the dynamically loadable component cannot be found in the application directory, an exception is thrown.