aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--worksheets/a1_textrain.md12
1 files changed, 7 insertions, 5 deletions
diff --git a/worksheets/a1_textrain.md b/worksheets/a1_textrain.md
index 6ce1142..7849594 100644
--- a/worksheets/a1_textrain.md
+++ b/worksheets/a1_textrain.md
@@ -42,7 +42,7 @@ In the code block below, write the equation for obtaining the index in the 1D
array from a (row, column) in the 2D pixels array. Keep in mind you can use
information from `inputImg` to help you.
-```
+```java
PImage inputImg = loadImage("test.jpg");
// your code should work for any valid values for row and column, we've
@@ -51,7 +51,7 @@ int row = 2;
int column = 2;
// write your answer in terms of the row and column defined above
-int index1D = /* --- Fill this in --- */;
+int index1D = row * inputImg.width + column;
```
@@ -73,8 +73,10 @@ final int threshold = 128;
// Returns: thresholded color (black or white)
color thresholdPixel(color inputPixel) {
-
- /* --- Fill this in --- */
-
+ if blue(inputPixel) < threshold {
+ return color(0);
+ } else {
+ return color(255);
+ }
}
```