CS 457/557 -- Winter Quarter 2023

Project #5

Image Manipulation in a "Magic Lens"

100 Points

Due: February 21

This page was last updated: February 20, 2023

NEW! An Extra Credit opportunity has been added.


  1. In computer graphics (and especially in visualization), there is a technique called a Magic Lens. A Magic Lens is some shape, usually a rectangle or circle, in which a different version of the display is drawn. Your job is to create a Magic Lens for an image display. Inside the Magic Lens, the image needs to be able to be magnified, rotated, and sharpened.

  2. Be able to toggle between the Magic Lens being a rectangle and being a circle.

  3. Draw a quadrilateral and map an image to it using a 2D Texture.

  4. If you are using glman, your glib file could look something like this:
    ##OpenGL GLIB
    Ortho -5. 5.   -5. 5.
    LookAt 0 0 2  0 0 0  0 1 0
    Texture2D 5 image.bmp
    Vertex   magic.vert
    Fragment magic.frag
    Program  Magic						\
    	uSc	 <0. .5 1.>				\
    	uTc	 <0. .5 1.>				\
    	uDs      <0.01 ?? ??>				\
    	uDt      <0.01 ?? ??>				\
    	uRad     <0.01 ?? ??>				\
    	uMagFactor <.1 ?? ??>				\
    	uRotAngle <-3.14159 0. 3.14159>			\
    	uSharpFactor <0. 1. 5.>				\
    	uImageUnit  5
    QuadXY .2 5.

  5. (uSc,uTc) are the (s,t) coordinates of the center of the Magic Lens rectangle or circle.

  6. (uDs,uDt) are the width and height of the Magic Lens rectangle.

  7. uRad is the radius of the Magic Lens circle.


Extra Credit +5 Points:

Along with the magnifying, rotation, and sharpening, add edge detection using the Sobel filter approach. Note: this needs to take place in absolute space, not relative-to-the-center-of-the-magic-lens space.

It is OK if the Sharpening and the Extra Credit Edge Detection are mutally exclusive. Just show each of them independently. However, the Edge Detection should work with the Magnification and the Rotation!

The Turn-In Process:

  1. Your turnin will be done at http://teach.engr.oregonstate.edu and will consist of:
    1. All source files (.cpp, .glib, .vert, .frag). You can zip this all together if you want.
    2. A PDF report with a title, your name, your email address, nice screen shots from your program, and the link to the video demonstrating that your project does what the requirements ask for. Narrate your video so that you can tell us what it is doing.
    3. Be sure your video's protection is set to unlisted.
    4. Do not put your PDF into your zip file. Leave it out separately so my collect-all-the-PDFs script can find it.

  2. Use an image of your own as your report example. (Note: if you use glman or the bmptotexture.cpp code, the image needs to be a 24-bit uncompressed BMP.)

Be sure that your PDF file is turned-in separately (not part of a .zip file).

Rectangle Circle


Something different happens in a rectangle10
The rectangle can be sized and moved15
The circle can be sized and moved15
Magnification works20
Rotation works20
Sharpening works20
Extra Credit: edge detection5
Potential Total105