|
@@ -39,7 +39,7 @@ Before coming to the laboratory session you should have:
|
39
|
39
|
|
40
|
40
|
## Image Editing
|
41
|
41
|
|
42
|
|
-In this laboratory experience, you will work with various concepts and basic skills of image editing. We have provided a simple graphical user interface that allows the user to load an image and invert it vertically and horizontally. Your task is to create and implement a function to convert the colored image into an image with gray tones, and another function that converts the colored image into a black and white image.
|
|
42
|
+In this laboratory experience, you will work with various concepts and basic skills of image editing. We have provided a simple graphical user interface that allows the user to load an image and invert it vertically and horizontally. Your task is to create and implement a function that converts a colored image into an image with gray tones, and another function that converts the colored image into a black and white image.
|
43
|
43
|
|
44
|
44
|
### Pixels
|
45
|
45
|
|
|
@@ -53,11 +53,12 @@ The smallest element in an image is called a *pixel*. This unit consists of a si
|
53
|
53
|
|
54
|
54
|
---
|
55
|
55
|
|
56
|
|
-`Qt` uses the `QRgb` type to represent `RGB` values. Using certain functions that are described below we can obtain the red, green and blue components of the `QRgb` value of the pixel and manipulate the images.
|
|
56
|
+`Qt` uses the `QRgb` type of data to represent `RGB` values. Using certain functions that are described below, we can obtain the red, green, and blue components of the `QRgb` value of the pixel and manipulate the images.
|
|
57
|
+
|
57
|
58
|
|
58
|
59
|
### Library
|
59
|
60
|
|
60
|
|
-In today's laboratory experience you will use the `QImage` class. This class allows access to the data in the pixels of an image to manipulate it. The documentation for the `QImage` class can be found in http://doc.qt.io/qt-4.8/qimage.html.
|
|
61
|
+In today's laboratory experience you will use the `QImage` class. This class allows access to the data in the pixels of an image in order to manipulate it. The documentation for the `QImage` class can be found in http://doc.qt.io/qt-4.8/qimage.html.
|
61
|
62
|
|
62
|
63
|
The code provided in this project contains the following objects of the `QImage` class:
|
63
|
64
|
|
|
@@ -186,13 +187,15 @@ In today's laboratory experience, you will design and implement simple image pro
|
186
|
187
|
|
187
|
188
|
### Exercise 2 - Convert a Colored Image to an Image with Gray Tones
|
188
|
189
|
|
189
|
|
-Image grayscale is an operation that is used to convert a colored image to an image with only tones of gray. To make this conversion the following formula is used in each pixel:
|
|
190
|
+Image grayscale is an operation that is used to convert a colored image to an image with tones of gray only. To make this conversion the following formula is used in each pixel:
|
|
191
|
+
|
190
|
192
|
`gray = (red * 11 + green * 16 + blue * 5)/32 ;` where `red`, `green` and `blue` are the values for the tones of the red, green and blue colors in the pixel of the original colored image, and `gray` will be the assigned color to the red, green, and blue colors in the pixel of the edited image. That is,
|
|
193
|
+
|
191
|
194
|
`editedImage.setPixel( i, j, qRgb(gray, gray, gray) )`.
|
192
|
195
|
|
193
|
196
|
#### Instructions
|
194
|
197
|
|
195
|
|
-1. Using pseudocode, express the algorithm to convert a colored image to an image with only gray tones. The appendix in this document contains some advice about good techniques for writing pseudocode.
|
|
198
|
+1. Using pseudocode, express the algorithm to convert a colored image to an image with gray tones only. The appendix in this document contains some advice about good techniques for writing pseudocode.
|
196
|
199
|
|
197
|
200
|
2. Complete the `GreyScale` function in the `filter.cpp` file to implement the grayscale algorithm. The function should produce a result similar to that in Figure 3, where the image on the left is the original image and the one on the right is the edited image.
|
198
|
201
|
|