Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » Red Cup Replacement » High-Level Overview:

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

High-Level Overview:

Module by: Blake Miller, John Slack, Thomas Ladd. E-mail the authors

High-Level Overview:

The goal of our project was to write a function that allowed students to "fix" pictures before uploading them to Facebook. Due to the time constraints of the project, we decided to define "fix" as altering a picture so that if one casually glanced at it, they would not be able to tell that it had been changed. Below are two figures that demonstrate this casual glance test.

Figure 1:

one

Figure 2:

two

It is visually obvious that Figure 1 has been "fixed" to produce Figure 2. Looking closely at Figure 2 alone, it is also blatant that many of the "fixed" objects look slightly strange and out of place. This imperfection is intended. Our goal was not to make the "fixed" picture look perfect, but to make it look passable if viewed briefly when scrolling through countless Facebook pictures. This way, if a student’s relative or future employer finds their Facebook page, they will not find any suspect pictures while scanning over the thousands of tagged photographs. In addition to this casual glance limitation, we also decided to only remove red cups from pictures. There are simply too many suspect items that college students can be holding these days, and identifying them all would be absolutely impossible. Thus we decided to only identify red solo cups as a “proof of concept.” This decision was made because red cups are fairly easy to identify with their red base and white top.

The function we used to “fix” pictures can be broken down into two key processes: first we identify the red cups in the picture, and then we replace them with more appropriate items.

Identification:

We start the identification process using a process called template matching. First, we create a bank of template images that we wish to use to identify red solo cups. This image bank contains a variety of red solo cups with different backgrounds, angles, hands holding them, etc. The reason for such a broad range of templates will be explained later in this module. Then, one by one, we use each template image to identify red solo cups in the target image. This is done by shifting the template across the target image, and computing the sum of products at each position. This sum of products, otherwise known as the cross-correlation, between the template and the selected portion of the target image represents how closely the template and the selected portion match. This process is shown in Figure 3.

Figure 3:

three

If the calculated correlation is above a certain threshold, we save the location and size of the template and identify this position as a red solo cup. This process is shown is Figure 4. Once a template image has been shifted across all possible positions in the target image, the size of the target image is reduced and the shifting starts over. This re-scaling method is repeated until the template is the same size of the target image. The reason for re-sizing will be discussed later in this module.

Figure 4:

four

Collection Navigation

Content actions

Download:

Collection as:

EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks