Skip to main content

Posts

Hidden Surface Removal

Look at the scratch code " RotatingSolidCube.cpp " and s tudy it carefully #include #include #include #include typedef struct{float x;float y;}Point2D; float dx = 200, dy = 200, dz = 200; GLfloat n[6][3]; /* Normals for the 6 faces of a cube. */ /* Vertex indices for the 6 faces of a cube. */ GLint faces[6][4] = { //traversed in counterclockwise direction as seen from outside {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4}, {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} }; GLfloat v[8][3]; /* Will be filled in with X,Y,Z vertexes. */ void init(void) { /* Setup cube vertex data. */         v[0][0] =100; v[0][1] = 100; v[0][2] = 300;           v[1][0] =300; v[1][1] = 100; v[1][2] = 300;         v[2][0] =300; v[2][1] = 300; v[2][2] = 300;         v[3][0] =100; v[3][1] = 300; v[3][2] = 300;         v[4][0] =100; v[4][1] = 100; v[4][2] = 100;         v[5][0] =300; v[5][1] = 100; v[5][2] = 100;         v[6][0] =300; v[6][1] = 300; v[6][2] = 100;         v[7][0] =10

3D transformation & Projection

Clearly understand the given scratch code for the standard perspective projection. scratch code :  Pres_Proj.cpp Complete the code to  project the cube on the XY plane with the COP is at (0,0,-200) Use 2D translation to shift the projected cube so that the origin (0,0) moves to the centre of the screen [i.e., move the system to (WinWidth/2, WinHeight/2)] Use 3D translation to project the cube with COP is at (100,100,-200) The following file contain the answer for the above questions. While the file runs you can see the answer for 1. If you press your left-mouse button you will see the answer for 2. And by pressing right-mouse button you can view the answer for 3. PerspectiveProjection.cpp Enjoy.. #TRASHCODERS

Some more for your Hunger - I suppose

Now let's do some more. On my last post I've given a program to control contrast, Let's do Auto-Contrast now. autocontrast.m So, I think what is meant by Auto-contrast by doing some changes in the above program. Let's try Modified-Auto-Contrast. modautocontrast.m The last for this post will  be Alpha-blending.. alphablend.m

Point Operations

Okay, Now we have some basic idea of an Image, Let's do some Basic Point Operations on some images. Always remember to test these with low resolution images. Because, Larger images takes more time to process the image. For, Starters do with 512x512 is appropriate. Basic Point Operations Brightness - Increasing and reducing the image's Brightness brightness.m Contrast - Controlling the Contrast of an image contrast.m Threshold - Doing threshold operation with a specific Threshold value threshold.m Inverting - Inverting an image invert.m Do some changes in these and try it yourself for more understanding #TRASHCODERS

Finding the histogram of an image

Okay, on the last post I've said what is an histogram. Now let's do a simple example on MATLAB to understand the concept. We will be using some well known Images for our exercises. "Lena", "Barbara", "Baboon" are some. For finding the histogram I'm providing two programs. One returns the histogram as output. histogram.m One returns three graphs of three different images to look the difference. histrogram3.m #TRASHCODERS

Image Processing

Okay, Now let's start doing Image Processing exercises on MATLAB. Before diving in let's start knowing what are the terms "Histograms", "Cumulative Histograms" and "Histogram Equalization" of an image. Let's see what are those, Histogram An image histogram is a type of histogram that acts as a graphical representation of the tonal distribution in a digital image. It plots the number of pixels for each tonal value. By looking at the histogram for a specific image a viewer will be able to judge the entire tonal distribution at a glance. Cumulative Histogram A cumulative histogram is a mapping that counts the cumulative number of observations in all of the bins up to the specified bin. That is, the cumulative histogram M i of a histogram m j is defined as:  Histogram Equalization Histogram equalization is a method in image processing of contrast adjustment using the image's histogram. for more definitions visit wik