diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-09-11 10:13:59 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-09-11 10:13:59 -0500 |
commit | 630e3018f16c1ba61c3ddbe34290e11260ee101b (patch) | |
tree | 40b3a73c049515de08921da1ddac369493058b96 /worksheets/a1_textrain.md | |
parent | Add .vscode to gitignore (diff) | |
download | csci4611-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 |
Do WS1submission-w1.0
Diffstat (limited to 'worksheets/a1_textrain.md')
-rw-r--r-- | worksheets/a1_textrain.md | 12 |
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); + } } ``` |