summaryrefslogtreecommitdiffstats
path: root/worksheets/a1_textrain.md
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2021-09-11 10:13:59 -0500
committerMatt Strapp <matt@mattstrapp.net>2021-09-11 10:13:59 -0500
commit630e3018f16c1ba61c3ddbe34290e11260ee101b (patch)
tree40b3a73c049515de08921da1ddac369493058b96 /worksheets/a1_textrain.md
parentAdd .vscode to gitignore (diff)
downloadcsci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.tar
csci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.tar.gz
csci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.tar.bz2
csci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.tar.lz
csci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.tar.xz
csci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.tar.zst
csci4611-630e3018f16c1ba61c3ddbe34290e11260ee101b.zip
Diffstat (limited to 'worksheets/a1_textrain.md')
-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);
+ }
}
```