Senin, 09 Februari 2009

Approximation with Lagrange Interpolation

Approximation is a method to know a function from a set of point that known. There are two kind of approximation. First is common approximation, well-known as interpolation, that the function must be through all point that known. Second is special approximation, that the function approaching the point that known.
One method that used in common approximation is Lagrange Interpolation. This methode produced a polinomial function. Give a set of point example (x1,y1), (x2,y2), (x3,y3)......(xn,yn). With Lagrange Interpolation we get polinomial P(x) below:Li(x) is Lagrange Function. This method implemented in Matlab so we get this script. x1, x2, x3...xn saved in bx. y1, y2, y3....yn saved in by. bx and by is array.

Senin, 12 Januari 2009

Matlab Script for Gauss Elimination

Gauss Elimination is one method to solve linear equation system. From linear equation system is made a matrix that consist a number of coeffisien unknown variable and their constant. This matrix is changed to upper/lower triangle matrix... and is changed one more to identity matrix. this process is shown above:

From this linear equation system we got matrix above:

This matrix must be a triangle matrix :
And must be an identity matrix :
I have ascript to make a diagonal matrix, that shown above:

And more script to make an identity matrix

Minggu, 16 November 2008

Image compression with Run Length Encoding (RLE) Algorithm

Before it, i made a script about image compression use quantization algorithm. This algorithm is lossy compression, it means we can't decompression our image file after compression.
With RLE algorithm we can save all information in our image.... so nothing to loss. How RLE algorithm work? I will use 6x6 pixel grayscale image (8 degree grayscale) below:
1 1 1 7 1 3
4 4 6 1 2 2

7 7 7 5 5 5
6 4 4 2 2 2
5 5 2 2 2 1

2 3 3 3 0 0

RLE code is a number that contains color intensity and frequency of color intensity coming. Here, we get RLE code below:
1 3 7 1 1 1 3 1 4 2 6 1 1 1 2 2 7 3 5 3 6 1 4 2 2 3 5 2 2 3 1 1 2 1 3 3 0 2

And here source code to make RLE code.... that made with Matlab.
g is grayscale image. And RLE code in rle array. So we can decompression with very easily, because we save all information about image.