Week 8 CST 205 : FINISHED!

A huge thanks to my team, Team SCSI Logic for being so supportive these past eight weeks. We all have quite busy lives, but we pulled through and created many projects we all should feel proud of. Our final project, The Crypts of Chelon, came out really well for a game created in JES. I look forward to seeing what our team can do with more robust resources.

You can view the trailer and demo for The Crypts of Chelon below:

Week 7: Web Scraping and HTML Creation

This week’s emphasis has been on scraping websites and creating HTML with Python. During the individual lab, we had to build off of a previous lab (Lab 14), in which we created a frequency dictionary of all the unique words in a modified version of Dr. Seuss’ Green Eggs and Ham.

This time, however, instead of merely printing out the words and their counts, we had to display each word in an HTML file, altering the size and color of the text based on the frequency the word occurs in the story. My first approach was to use the frequency count as the font size. However, many words had a frequency of 1 or 2, which made them quite hard to see since their font size was being set to 1 or 2 pixels. Therefore, I decided to add 10 to font sizes, so that the minimum font size would be 10. I was also able to use the frequency to influence the greenness of the font of each word. To do this, I had to convert frequencies (integers) to hexadecimal and insure that each hexadecimal number was two digits to represent the green in the RGB hex code. I wound up scaling the frequencies so that the most frequent word would get the max amount of greenness (255 or FF in hexadecimal).

 

We also worked on our final project! Here’s a screen cap:

Week 6: Text Manipulation

This week emphasized Python lists and dictionaries. Interestingly enough, our team utilized both of these structures in our text adventure game last week. This turned out to be an advantage since one of this week’s assignments was to refactor our text adventure game to implement these data structures in some way. We were ahead of the game in that respect. Great job, team!

Other assignments we were tasked with included creating a word frequency analysis program to identify all unique words in a modified version of Dr. Seuss’ Green Eggs and Ham, developing a news headline scraper, and implementing a MadLibs program that would revise a short news story.

You can play with my MadLibs program below:

Week 5: CST 205: Text Adventure Game

This week, our team worked together to design and implement a text adventure game. Because we all have varying skill levels in programming and programming with Python in particular, pair programming was essential to the development process. We also heavily relied on GitHub for collaboration and version control.

It was easy to see how feature creep could quickly become problematic, as we continuously were juggling different ideas for this seemingly simple text adventure game.  However, the creation process and collaboration was fun and invaluable and I truly enjoyed this assignment.

Try our game below!

You can find the source code to our game on GitHub!

CST 205: Week 4 Audio Manipulation

This week we started learning about audio manipulation with JES. I learned that audio is recorded using different sample rates (samples per second) and with different bit depths (bits per sample). The bit depth of an audio file determines how many unique values a single sample can have. A sample’s value corresponds to amplitude (how quiet or loud it is). It is the change in a sample’s value over discrete time steps that determines a sound wave’s frequency (how high or low the pitch).

Ultimately, we applied what we learned about sound manipulation to create our own unique sound collages. I was selected to create a demo video on my approach and it can be seen below:

I decided I wanted to blend two of my samples together, so that I could have background music throughout my sound collage. It was not part of the assignment, but it was fun figuring it out.

After our brief section on audio manipulation, we were tasked to create a hangman game with a partner. It was fun figuring out all the error handling to redirect a player who may have entered unexpected input. It was satisfying creating a working copy of this simple game and I am excited to work with my team on our upcoming text-based adventure game!

Last, out midterm project was due this week. We had to create two filters: a CSUMB-themed filter, which we created last week, and one of our choice. Cody (my team partner) and I decided to create an effect that would make a photo appear like a bad VHS recording. While we didn’t get to include all the features we originally had hoped for (pixel shifting and color bleeding), I’m pretty satisfied with the results:

Unaltered Paramount logo

Paramount logo with our VHS effect applied

CST 205 Week 3 Midterm Update

We’re already planning a midterm project! This week, we worked on Lab 7 with a pair programming partner to create a design for a Thanksgiving card. I had the idea to create a scene with face cut-outs. After utilizing a similar algorithm to our chromakey procedure to get the photos drawn in the right place, we added functions that would scale the face photos up or down to fit the face cut-outs. After slapping on some text to wish our audience a happy Thanksgiving, it was done!

Thanksgiving card

I had a lot of fun with this project because we got to utilize everything we have learned about image manipulation until now. I also spent a fair amount of time refactoring the code to make it more readable and generalizable. It was a lot of fun.

We are doing peer and self evaluations right now as well. Peer evaluations will involve code checks, where we go through and analyze one another’s code in terms of naming conventions (functions and variables are well named), functionality (everything compiles and executes in the expected manner), and use of abstraction (breaking down complex problems into smaller easier to understand problems). It should be a great learning experience.

I am excited about the midterm project because we get to create our own filters. I have already completed the CSUMB filter. I found out how to programmatically create a gradient of two colors and to blend the colors of two source photos together (you take the average of reds, greens, blues, and use those averages to create a new color). I also added on a pixelated version of CSUMB’s mascot, an otter!

Gradient of CSUMB’s school colors

A photo of me CSUMB-ified

Week 2 of CST 205: Manipulating Pixels

Lab Reflection

This week we used loops and control statements to manipulate images.

Lab 4

In this independent lab, we created a variety of mirroring functions by iterating through the pixels of part of an image and copying the colors of those pixels to another part of an image. Here are some examples:

Original image of Mui, my whitefaced cockatiel.

Vertical mirror, left to right

Vertical mirror, right to left

Horizontal mirror, top to bottom

Horizontal mirror, bottom to top

Quadruple mirroring, using right to left and top to bottom mirroring

Lab 5

This was another independent lab. In this lab, we learned how to create a blank Picture object and to copy pixels from other pictures on to it. This enabled us to copy multiple pictures on to a large empty canvas, creating a collage. My approach was to iterate through a list of pictures and to apply random effects to each picture before it got copied on to the blank canvas. I also added my name to the bottom using the addTextWithStyle JES function. Here is one of the results:

LAB 6

In this pair programming lab, my teammates and I developed functions to manipulate pictures based on the color values of pixels. In the warmup problem, we had to implement red eye correction. Essentially, we had to detect pixels that were within some range of red (using a distance function) and to change those pixels’ color values to something that looked more natural (we chose black). Below is the before and after:

Photo before redeye correction

Photo after redeye correction

 

We then developed a function that created a sepia effect. This was done by first converting the photo to grayscale (when each value of red, green, and blue are essentially equivalent or close to being equivalent). Then, based on each pixel’s red amplitude, we modified the amount of red and blue. This created the sepia effect:

Original photo of salmon roe rice bowl

Sepia effect

 

We also created a function that created a fun posterizing, cartoony effect. This was a lot like the sepia function, in that the amount by which we changed the color of a pixel depended on the original color value. However in this case, we modified each color (red, green, and blue) based on the previous values of red, green, and blue. Here is the effect:

Original photo of bike

“Artified” version of bike

Last, we developed a chroma key function to add a background on to a green screen photo. Essentially, we had to detect the degree to which each pixel’s color matched the green color we expect the green screen to be. If it matched within a reasonable range, we copied the colors of the background photo (the volcano picture in the example) on to the green pixels of the green screen photo (the photo of Shia LeBeouf in this example):

Shia LaBeouf in front of a green screen

Volcano

Shia defeating the volcano

 

Week 1: Getting Started with JES and Digital Imaging

This week, we got started using JES, a Jython/Python IDE for students to learn how to process and transform digital images. It has been a while since I have coded anything in Python, aside from a few leisure electronics projects that use CircuitPython. It was a little bit like coming home since Python is the first programming language I understood, as I had to learn it for my computational linguistics courses. There’s a bit of nostalgia attached to Python.

I learned how to use several of the built-in functions in JES, such as makeImage to create a Picture object out of specific image file, given its path. A Picture object is an abstraction of an image file. It represents data related to the image such as:

  • a list of all of the image’s pixels (retrievable with the accessor function getPixels)
  • the image’s height (accessed by getHeight)
  • the image’s width (accessed by getWidth)

There are mutator functions that can modify the state of a Picture object such as:

  • repaint, updates/redraws an opened Picture object to reflect changes to its state
  • addText, which takes five parameters–reference of the Picture object, the x and y positions of where to start adding text, the string of text itself, and the Color the text should be.

Each pixel of an image is also represented as a Pixel object

We used the getColor accessor to get the RGB values of a particular pixel and the setColor mutator to change the RGB values of a pixel. These functions were instrumental in building our own functions that would produce different effects, such as the ones illustrated below:

Original photo (CSUMB landscape)

Grayscale version produced by betterBnW() function

Negative version produced by makeNegative() function

No struggles or difficulties this week!

Week 0: CST 205

I am excited about this course because, while I have previous experience with Python through my graduate studies in computational linguistics, that experience was largely based on text processing using Natural Language Toolkit (NLTK).

As a wordy linguist, I have limited knowledge of image processing, so it is thrilling to be able to learn something new. I am looking forward to being able to create some multimedia projects using Python and working together with my great team.

The only challenge I (continuously) face is juggling my full-time teaching job with coursework. Because I am well-organized and a responsible worker, I know I can continue to overcome this challenge and produce some great work. It helps when the work you do (both in career and in academia) is something you value and love.