From 630e3018f16c1ba61c3ddbe34290e11260ee101b Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Sat, 11 Sep 2021 10:13:59 -0500 Subject: Do WS1 --- worksheets/a1_textrain.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'worksheets/a1_textrain.md') 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); + } } ``` -- cgit v1.2.3