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.
Requirements:
-
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.
-
Be able to toggle between the Magic Lens being a rectangle and being a circle.
-
Draw a quadrilateral and
map an image to it using a 2D Texture.
-
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.
-
(uSc,uTc) are the (s,t) coordinates of the center of the
Magic Lens rectangle or circle.
-
(uDs,uDt) are the width and height of the Magic Lens rectangle.
-
uRad is the radius of the Magic Lens circle.
Hints
-
Inside the fragment shader, you need to see if the current fragment is inside the Magic Lens rectangle or circle.
If it is not, do a texture lookup as normal.
-
If it is, you need to be sure that the scaling and rotation you do to this (s,t) is
with respect to the center (uSc,uTc) 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:
s' = s*cos(theta) - t*sin(theta)
t' = s*sin(theta) + t*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 sharpening is not done with respect to the center of the Magic Lense.
-
The order should be something like:
- Translate by - (the center of the ML)
- Magnify
- Rotate
- Translate by + (the center of the ML)
- Sharpen
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:
-
Your turnin will be done at
http://teach.engr.oregonstate.edu
and will consist of:
- All source files (.cpp, .glib, .vert, .frag).
You can zip this all together if you want.
- 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.
- Be sure your video's protection is set to unlisted.
- Do not put your PDF into your zip file.
Leave it out separately so my collect-all-the-PDFs script can find it.
-
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
|
Grading:
Feature | Points
|
---|
Something different happens in a rectangle | 10
|
The rectangle can be sized and moved | 15
|
The circle can be sized and moved | 15
|
Magnification works | 20
|
Rotation works | 20
|
Sharpening works | 20
|
Extra Credit: edge detection | 5
|
Potential Total | 105
|
---|