April 5, 2008
WikiClass 5 Notes
Class 5 Notes
We are going to talk about geometrical transformations today. Before that we are checking out projects and how they are shaping before next week. Leif’s slit scanning is pretty interesting. Dan’s comment about this. It is not about what you are doing, it is more about how you are doing. ” I like the fact that it builds up over time. ” -> Nick’s project which grabs video snapshots and display those snapshots according to the RGB values. flickering is sometimes annoying. Repetition too. Jeremy’s project, an array of 1000 pixels. And then thresholding of the RGB values, and then displaying on the screen like lines which their thickness is decided how they are popular.
Geometric manipulations: All the things we have done using getPixel(X,Y,R,G,B), what we want to do today move chunks of images around, spin them zoom them etc. We won’t be RGB values but we are going to be manipulating X,Y. What kind of geometrical manipulations do we have? *Scaling. *Rotation. *Translation. *Warping. Includes the other three.
Rumours are that some low level machines only do warp. It is quite intensive calculations.
Translation
Take a rectangle and move it in a different location. We would take the x and if we want to move them 100 pixels in horizontal value, just move x +100. Easiest image transformation.
Scale
You multiply in scale. just like in translation we add, we multipy when we scale things. Two dangerous when we scale. So if we say we start to multiply by x, we start to create holes, iff you take a source pixel map and trying to calculate each position in pixels you will end up with holes. Integer masks fail you. In order to fix that, if we increment not by full pixel, but calculate a pixel 0.5 instead of 1. we can do it maybe. it is wasteful though. The better way could be, quite simple and elegant. Instead of doing a push we do a pull, what we normallyt do is we have a repeat loop with x,y what happens to reverse the traverse and target the source. So we loop through target image, we take the math and we turn it around so same pixels are coming from the same source. It creates jaggines, it is called nearest neighbor. Bicubic does it better. Getting a sample of 4 pixels and creating RGB values according to that and apassing that value to the target.
The other danger is when you are zooming in and you will get your rectangle out of your pixel map and create a compile time error.
Rotation
So we have a problem because we will have diamond shape pixels.
Warp
Expecting four points as source and then expect 4 pixels in the target, it is quite useful for doing fake 3d stuff. We created a struct you give it two things name of it at the bottom. and you give variables with names.
Fancy Rotate, what it is doing is taking a portion and doing a circle and rotating it left by one degree and takign another small circle and reversing the rotation etc. going like that. Actually maybe using shiffman’s pixel manipulation example could be handy in this. Try to see the effect with a sloppy code and try to dedicate your time with making that code better, and if you just don;t like the effect just dump it!
RoateVideo is the same as rotation but instead of roating the image butter it is changing the video buffer. it is not capturing 640X480 it is capturing small and then scaling it big. Another good thing we have we can write text on the window, timeit function. Draw String draws to the active screen, so it draws to the buffer and it is copied then.
Moving pixels around and creating something out of it.
Continue Reading
Back to Archive