Python Image Algorithm Project

Assignment Description

Create a program that uses an algorithm to modify any image.

Requirements

  • Receive any image file* as input and make a set of changes to it.
  • Output the modified image to a file or return a new image object in memory.
  • Work in partners using the Driver – Navigator system, and switch roles often enough to make sure both partners are keeping up.
  • Demonstrate the ability to create an algorithm. This means multiple steps or processes happen to modify your image.
  • Include the required comments in your code:
    • Programmer names and date last modified in line
    • Purpose of the program in the next line
    • Comment other lines of code to explain how it works
    • No grade will be given if you don’t include those comments.

*Notes on image formats:

  • Your program should be able to handle typical color image formats (JPG, PNG, BMP, etc) of any size and aspect ratio.
  • Remember that images have different modes such as “RGB” and  “RGBA” and “L” – you can use .convert() to change them all to the same mode in your code.
  • Some images’ pixel color data is stored as a decimal from 0 to 1 instead of as an integer from 0 to 255; these images will behave badly in our code unless you write a function to convert them. Feel free to do so if you want to use a particular image with this format, but otherwise stick to images that use our typical RGB format. 
  • Turn your code and example image files into the PowerSchool Learning LMS assignment

Example Image Modification Ideas:
Draw shapes on the image
Add text
Change pixel colors (make it grayscale, make it more red, etc)
Paste other image(s) onto original (e.g. a watermark)
Resize it to a certain standard size (i.e. an account avatar picture)
Crop it to a square shape (crop equal amounts from the sides or top/bottom)
Add a border of some sort

A good algorithm should make multiple changes, and the order of those changes should be chosen thoughtfully.

The individual changes should be written in a way that makes them work on any object size. For example, use the image’s size[0] (width) and size[1] (height) attributes in your code instead of hard coding in those numbers.

Grading (Algorithms Standard)

Level 1:

Completed enough level 2 requirements to receive a marginally passing grade; at least one Level 2 requirement missing.

Level 2: 

  • Uses an algorithm to make multiple changes to an image in a repeatable way
  • Program works properly on images with different sizes and aspect ratios (width: height ratios)
  • Includes the required #comments in the code.
  • Python code is turned into the LMS
  • One set of example images (before and after) turned into the LMS

Level 3: 

  • Program is organized into functions
  • Uses function input (argument / parameter) and output (return value): take a file name or PIL image object as your function’s input and for the output either save a new file or return a new PIL image object.
  • Algorithm demonstrates proficiency and creativity with Python Image  Library (PIL) functions: multiple functions used, loops used to modify pixels, and functions are combined in ways that show the ability to use them in creative ways rather than copying the algorithm ideas from examples

Level 4:

  • The code is modular: multiple functions are defined that each make their own modifications to an image. These separate functions can be mixed and matched in any order to modify an image in many different ways.
  • A central function calls your smaller functions to make the individual changes in the order you choose. This function receives an input (argument / parameter) and returns a new PIL image or saves a new file.
  • Image modifications show a high level of creativity to make a high quality final product, OR, the image modifications could be genuinely useful to somebody who has to process many images in a certain way.