WARNING: This pages is using the global variables.php file. All 240 course websites after Fall 2018 should use a relative path to a variables.php file in the semester's root directory instead!

CS 240 - Fall 2018

TA Tips for Image Editor - Fall 2018

These are some common things that we have noticed that will help you with this lab.

  1. Input: When reading in the image, use a regex delimiter (if using a Scanner) to ignore any comments in the image. We recommend using the regex "((#[^\\n]*\\n)|(\\s+))+" to ignore any comments accurately.
  2. Output: When outputing your transformed image, do not make multiple write calls to your file (pseudocode: for(eachpixel) { write(pixel) } .) This will run very slowly. Instead, use StringBuilder to generate your output and write a single string to your output file (pseudocode: for(eachpixel) { appendToStringBuilder(pixel) } write(builderOutput) .)
  3. Emboss: The specifications state to find the maximum difference (positive or negative.) This means you'll use the absolute value when comparing. However, when actually using the maximum difference, make sure you're not using the absolute value then. For example, if I'm comparing -5 and 3, I will choose -5. I will then add 128 to -5, not to 5.
  4. Emboss: You don't want to overwrite the image you're using for reference. Otherwise, the "upper left" pixel will always be some manner of gray. The easiest way to avoid that problem is to have two copies of the image (the original for reference and a working copy for output.) Or you can just start at the bottom right corner of the image and work your way backwards so that the top left pixel will always be in its original state (unaltered) when you need to reference them.
  5. Emboss: The furthest left column and top row of pixels do not have a "top left" pixel. In this case just set it to 128.
  6. MotionBlur: When you get to the right edge of the image, make sure you average what is remaining of the image rather than trying to divide by n.