2015-12-21 LabN09 ImageManipulation

posted Dec 21, 2015, 6:22 AM by Samuel Konstantinovich   [ updated Dec 21, 2015, 6:22 AM ]
This is a multiple day lab + homework.

1. selector :  image-name
"kitten.png"
"googlelogo.png"
"rainbow.jpg"

This will let you choose several images. Get them from here:
http://marge.stuy.edu/~konstans/ 

2. Setup and reset buttons
Loading from a file is slow operation. Save time with an extra step so you can reset quickly! 
(Patches need to own : original-color )
-Setup will load from an image, and store pcolors into the original-color variable.
-Reset will copy the original-color back into the pcolor so you don't have to re-load from the file. 

3. Selector:  mode
"grayscale"
"blur"
"edgedetect"

4. Process is an observer context button that will run one of the image processing commands. 
Example:

to process
  if mode = "grayscale"
  [ grayscale]
  if mode = "blur"
  [ blur ]
  ask patches [ set pcolor next-color ]
end

Note that means that grayscale, blur, and all other image functions must:
  - be observer context
  - set the next-color of every patch

5. You already wrote grayscale, but may need to modify it to set the next color.
6. Blur: (works on grayscale images)
   set your next-color to:
      60% of your own color + 40% of the average of all of your neighbors colors.
7. Edge Detect:  (works on grayscale images)
    Make a slider from 0 to 1 called threshhold.

   calculate a sum of two differences:   
      abs (  north-neighbor-color - south-neighbor-color) +
      abs (  east-neighbor-color - west-neighbor-color) 
   In class we normalized this calculation by dividing by some number such that it always resulted in a number between 0 and 1.
    if the calculation > threshhold, set your next-color to black, otherwise set your next color to white. 

8. Extra cool effects:  (works on grayscale images, but since you stored the original color you can still use the color!)
Edge detection can be modified (make a copy of the function and modify it)
ColoredEdges - Make the edges the original color instead of black, you get colored edges.
CartoonEffect - Make the non-edges the original color instead of white, you get cartoon outlines on things.       
GrayEdges - Make the edges color depend on the calculation, so some edges are brighter than others. 

9. Other effects:
-Make an image red/blue/green-scale instead of grayscale. This is easy to figure out.
-Make an image darker by shifting all the ones digits closer to 0 by some %. (10% closer works well)
Comments