Late last week we looked at how to remove red eye from a photo by selectively considering which pixels to modify. Some pixels were left the same, other pixels had their color modified. In this week's lab you will take that idea and use it in a couple of different activities.
In each of the activities in this lab I have provided you with an optional "base image" I know that these images can work. If you want to have a bit more fun you might find a photo of yourself or some other photo from the internet and try to produce the effect with that photo instead.
A couple of days ago a friend of mine changed her facebook status to say "Nancy is rolling in cilantro" For some reason I immediately had a mental image of Nancy's face on the cover of the movie "American Beauty" and a bunch of green petals (cilantro is a green herb) rather than red (rose) petals. I'm just geeky enough that I figured out how to make that photo and sent it to Nancy.
For this activity I would like you to do part of that process by turning "red" pixels to "green" pixels.
For example, you could take the following picture
and convert it to this:

Notice that the basic idea is very similar to that used in reducing red eye. That is, you look for pixels of a target color or of some specific attributes (that is, either close to a very specific shade of red OR a color whose R, G, and B values fall in certain ranges) and replace those pixels with a new color.
Write a method called turnToGreen(). This method takes a photo as a parameter and modifies that photo so that every pixel that is "sufficiently red" is converted instead to a pixel that is "sufficiently green" I think that the best way to do this is to simply swap the red and green channels of any pixel that is "sufficiently red"
You may feel free to do this to the photo above, but you may also use any photo that you like.
[SIG1] When you are comfortable with the results of turnToGreen() you should demo it for a TA.
Most of you have seen photos from portrait galleries that make a color photo nearly completely grayscale EXCEPT for one small feature like a red rose or a pink bow on a dress. For example, they might take the photo below:
and apply an effect to produce this:

Notice that this is sort of the opposite of reduce red eye. In this case you are looking for a target color and changing every pixel that is NOT that target color. The overall process is very similar, but you will need to think about how this works.
Write a method called partialGrayscale() that takes a picture as a parameter. The method should turn most of the pixels in the photo to grayscale except for those that meet some very specific requirements.
It is VERY likely that to get a nice effect you will need to fine tune this method for this specific photo, although it is possible to get nice results with a generalized method. Tuning for the specific photo involves defining the rough boundaries of the flower (like what we did with the red eye in class on Monday. HOWEVER, notice that you can't simply loop over that small region (as we did with red eye) since the vast majority of this photo is changed to grayscale. Instead, you need to use the concept of multiple conditions and the AND statement as we discussed in lecture.
Again, you may use the image I provided above OR you may start with a photo of your selection.
[SIG2] When you are comfortable with the results of partialGrayscale() you should demo it for a TA.
Write a method called makeMartian(). This method should use what you have learned to take an image of a person, and make several modifications:
You can do this to a photo of any person of your choosing. You can use yourself, a friend, Dr. Schafer (this photo is me after polishing off the 1 pound "Gunderburger"), or even president Allen (Hopefully he would have a sense of humor about this).
You may check this in as you add each piece, or you can check it in when you are all done.
[SIG3] When you are done creating green skin, show it to a TA for signatures.
[SIG4] When you are done creating red eyes, show it to a TA for signatures.
[SIG5] When you are done creating orange hair, show it to a TA for signatures.
Make some additional changes to the makeMartian() method from Activity C. This can make any changes you would like to play with. For example, you can change to different colors, you can use what you have learned about resizing and copying to create HUGE eyes or a small body. Be creative.
[BONUS SIG] Show this to me when you get done (I want to see what you come up with!)