|
@@ -1,22 +1,24 @@
|
1
|
|
-# Pesky Tourist: Sorting and Nested Loops
|
|
1
|
+# Sorting Algorithms - Pesky Tourist
|
2
|
2
|
|
3
|
3
|
![main1.png](images/main1.png)
|
4
|
4
|
![main2.png](images/main2-small.png)
|
5
|
5
|
![main3.png](images/main3-small.png)
|
6
|
6
|
|
|
7
|
+[Verano 2016 - Ive]
|
|
8
|
+
|
7
|
9
|
Two common tasks when working with arrays of data is to search for and sort the data in ascending or descending order. Two well known simple sorting algorithms are Selection Sort and Bubble Sort. Sorting algorithms make up part of many programs; for example, contact lists, search engines, etc. In this laboratory experience you will complete an application to process images and pratice the use of sorting algorithms. You will also learn about the `QImage` library from `Qt` and about the median filter used in image processing to remove noise, in this case a pesky tourist.
|
8
|
10
|
|
9
|
11
|
##Objectives
|
10
|
12
|
|
11
|
|
-1) Practice sorting arrays by selection and the bubble method.
|
|
13
|
+1. Practice sorting arrays by selection and the bubble method.
|
12
|
14
|
|
13
|
|
-2) Practice the use of decision and repetition structures.
|
|
15
|
+2. Practice the use of decision and repetition structures.
|
14
|
16
|
|
15
|
|
-3) Use methods from the `vector` C++ class.
|
|
17
|
+3. Use methods from the `vector` C++ class.
|
16
|
18
|
|
17
|
|
-4) Use the methods of the `QImage` class from `Qt` to manipulate an image’s pixels.
|
|
19
|
+4.Use the methods of the `QImage` class from `Qt` to manipulate an image’s pixels.
|
18
|
20
|
|
19
|
|
-5) Learn about the median filter for image processing.
|
|
21
|
+5. Learn about the median filter for image processing.
|
20
|
22
|
|
21
|
23
|
This laboratory experience is an adaptation of the nifty assignment presented by John Nicholson in [1].
|
22
|
24
|
|
|
@@ -24,15 +26,15 @@ This laboratory experience is an adaptation of the nifty assignment presented by
|
24
|
26
|
|
25
|
27
|
Before arriving at the laboratory you should have:
|
26
|
28
|
|
27
|
|
-1) Reviewed the selection sort and bubble sort algorithms.
|
|
29
|
+1. Reviewed the selection sort and bubble sort algorithms.
|
28
|
30
|
|
29
|
|
-2) Familiarized yourself with the `push_back()`, `at(i)`, `size()`, `clear()` methods in the C++ `vector` class.
|
|
31
|
+2. Familiarized yourself with the `push_back()`, `at(i)`, `size()`, `clear()` methods in the C++ `vector` class.
|
30
|
32
|
|
31
|
|
-3) Familiariezed yourself with the `width()`, `height()`, `pixel(i, j)`, `setPixel(i,j, pixel)` methods in the `QImage` class from `Qt`.
|
|
33
|
+3. Familiariezed yourself with the `width()`, `height()`, `pixel(i, j)`, `setPixel(i,j, pixel)` methods in the `QImage` class from `Qt`.
|
32
|
34
|
|
33
|
|
-4) Studied the concepts and instructions for the laboratory session.
|
|
35
|
+4. Studied the concepts and instructions for the laboratory session.
|
34
|
36
|
|
35
|
|
-5) Taken the Pre-Lab quiz that can be found on Moodle.
|
|
37
|
+5. Taken the Pre-Lab quiz, available in Moodle.
|
36
|
38
|
|
37
|
39
|
---
|
38
|
40
|
|
|
@@ -126,25 +128,25 @@ The objects of the `QImage` class have the following methods that will be useful
|
126
|
128
|
|
127
|
129
|
### Examples:
|
128
|
130
|
|
129
|
|
-1) `QRgb myRgb = qRgb(0xff, 0x00, 0xff);`: Assigns to `myRgb` the value `0xff00ff` that represents the color ![figure3.png](images/figure3.png)
|
|
131
|
+1. `QRgb myRgb = qRgb(0xff, 0x00, 0xff);`: Assigns to `myRgb` the value `0xff00ff` that represents the color ![figure3.png](images/figure3.png)
|
130
|
132
|
|
131
|
|
-Notice that the value of `0xff00ff` represents the values `0xff`, `0x00`, `0xff`, that correspond to the red, green and blue components of `myRgb`.
|
|
133
|
+ Notice that the value of `0xff00ff` represents the values `0xff`, `0x00`, `0xff`, that correspond to the red, green and blue components of `myRgb`.
|
132
|
134
|
|
133
|
|
-2) If the following `4 x 4` image of pixels represents the object `originalImage`,
|
|
135
|
+2. If the following `4 x 4` image of pixels represents the object `originalImage`,
|
134
|
136
|
|
135
|
|
-![main1.png](images/main1.png)
|
|
137
|
+ ![main1.png](images/main1.png)
|
136
|
138
|
|
137
|
|
-then `originalImage.pixel(2,1)` returns the `rgb` value that represents the color blue (`0x0000ff`).
|
|
139
|
+ then `originalImage.pixel(2,1)` returns the `rgb` value that represents the color blue (`0x0000ff`).
|
138
|
140
|
|
139
|
|
-3) The following instruction assigns the red color to the pixel in position `(2, 3)` in the edited image:
|
|
141
|
+3. The following instruction assigns the red color to the pixel in position `(2, 3)` in the edited image:
|
140
|
142
|
|
141
|
|
-`editedImage.setPixel(2,3,qRgb(0xff,0x00,0x00));`.
|
|
143
|
+ `editedImage.setPixel(2,3,qRgb(0xff,0x00,0x00));`.
|
142
|
144
|
|
143
|
|
-4) The following instruction assigns a `greenContent` the value of the green value contained in the pixel `(1, 1)` of the `originalImage`:
|
|
145
|
+4. The following instruction assigns a `greenContent` the value of the green value contained in the pixel `(1, 1)` of the `originalImage`:
|
144
|
146
|
|
145
|
|
-`int greenContent = qGreen(originalImage.pixel(1,1));`.
|
|
147
|
+ `int greenContent = qGreen(originalImage.pixel(1,1));`.
|
146
|
148
|
|
147
|
|
-5) The following code assigns to the red component of the pixel `(1, 1)` of `editedImage` the average of the values of the red tone that are in pixel `(1, 1)` of `originalImage1` and `originalImage2` and does the same to the green and blue components.
|
|
149
|
+5. The following code assigns to the red component of the pixel `(1, 1)` of `editedImage` the average of the values of the red tone that are in pixel `(1, 1)` of `originalImage1` and `originalImage2` and does the same to the green and blue components.
|
148
|
150
|
|
149
|
151
|
---
|
150
|
152
|
|
|
@@ -188,7 +190,7 @@ int main() {
|
188
|
190
|
|
189
|
191
|
The project `PeskyTourist` contains the skeleton for the application to remove the noise from an image. In today’s laboratory experience yu will complete the application to process images using the median filter to remove the noise of an image, in this case a pesky tourist. You will be working in the `Filter.cpp` file.
|
190
|
192
|
|
191
|
|
-#### General algorithm to remove the noise from an image
|
|
193
|
+#### General algorithm to remove noise from an image
|
192
|
194
|
|
193
|
195
|
```
|
194
|
196
|
|
|
@@ -262,7 +264,7 @@ When you complete the function, the `Remove Noise` button will execute your algo
|
262
|
264
|
|
263
|
265
|
##Deliverables
|
264
|
266
|
|
265
|
|
-Use "Deliverables" in Moodle to upload the `Filter.cpp` file that contains the functions you implemented in this laboratory experience. Remember to use good programming techniques, include the names of the programmers involved, and to document your program.
|
|
267
|
+Use "Deliverable" in Moodle to upload the `Filter.cpp` file that contains the functions you implemented in this laboratory experience. Remember to use good programming techniques, include the names of the programmers involved, and to document your program.
|
266
|
268
|
|
267
|
269
|
---
|
268
|
270
|
|