CS 457/557 -- Winter Quarter 2017
Image Manipulation in a "Magic Lens"
Due: February 27
This page was last updated: February 14, 2017
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.
Draw a QuadXY.
Map an image to it using a 2D Texture.
Your GLIB file could look something like this:
Ortho -5. 5. -5. 5.
LookAt 0 0 2 0 0 0 0 1 0
Texture2D 5 image.bmp
Program Mag \
uScenter <0. .5 1.> \
uTcenter <0. .5 1.> \
uDs <0.01 .1 .5> \
uDt <0.01 .1 .5> \
uMagFactor <.1 1. 25.> \
uRotAngle <-3.14159 0. 3.14159> \
uSharpFactor <0. 1. 5.> \
QuadXY .2 5.
(uScenter,uTcenter) are the (s,t) coordinates of the center of the
Magic Lens rectangle.
(uDs,uDt) are the sizes of the Magic Lens rectangle.
Inside the fragment shader, you need to see if the current fragment is inside the Magic Lens rectangle.
If it is not, do a texture lookup as normal.
If it is, you need to be sure that what you do to this (s,t) is with respect to the center of the Magic Lens.
When you want to do something to an image, you do the inverse of that to the (s,t) coordinates.
So, if you want to scale the image by uMagFactor, you do ????? to its (s,t) coordinates.
And, if you want to rotate an image, you would do:
x' = x*cos(theta) - y*sin(theta)
y' = x*sin(theta) + y*cos(theta)
So, you would need to do ????? with the image's (s,t).
The sharpening can be done with the code in the Image Manipulation notes.
The scaling and rotation equations assume that the origin
is at the center of the thing being scaled and rotated.
Sharpening does not have this restriction.
The order should be something like:
Extra Credit (+5 Points)
Make the Magic Lens a circle instead of the rectangle.
The center will still be given the same way,
will use a radius slider instead of two rectangle dimansion sliders.
The Turn-In Process:
Your turnin will be done at
and will consist of:
- All source files (.glib, .vert, .frag)
- The original image file you used.
- Your PDF report.
You can use the kec.bmp image for testing, but what you show in your report needs to be an image of your own.
(Remember, on some graphics systems, the dimensions of that image need to be even powers of two.
This is not true in the CGEL.)
Your PDF report will consist of:
- A cover page (name, Project #6)
- Source listings (.glib, .vert, .frag)
- A prose explanation of what you did.
- Four or more color images showing what your results were
(original, magnified, rotated, sharpened).
- If you did the Extra Credit, then also include at least one image exhibiting
your circular Magic Lens.
Be sure that your PDF file is turned-in separately (not part of a .zip file).
|Something different happens in a rectangle||20
|The rectangle can be sized and moved||20
|Circle Extra Credit||5