## Dobivanje slike iz matrice

M:matrix([1,1,1,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1],
         [1,1,1,1,1,1,1,1,0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0],
         [1,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,0,1,1,0,0,0,1,0],
         [1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
         [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
         [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0],
         [1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0],
         [1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0],
         [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0,1,0],
         [1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1],
         [1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0],
         [1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0],
         [1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0],
         [1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0],
         [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,0,0,1,0,0],
         [1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0],
         [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0]);

Matrica M je tipa (27,27)

matrix_size(M);

Učitavanje paketa potrebnog za crtanje

load(draw)$

Kreiranje slike iz matrice M

slika:image(M,0,0,27,27)$

Jedinica u matrici predstavlja bijelu boju, a nula crnu boju.

wxdraw2d(palette=gray,slika);

ako želimo da se slika nacrta u novom prozoru

draw2d(palette=gray,slika);

Možemo prikazati sliku u boji. 
Bit će prisutne samo dvije boje jer u matrici M imamo samo dvije različite vrijednosti.

wxdraw2d(palette=color,slika);

Možemo birati svoje boje tako da u opciji palette stavimo tri broja koji definiraju način
pridruživanja crvene, zelene i plave boje. Brojevi mogu biti između -36 i 36.

wxdraw2d(palette=[1,23,8],slika);

## Učitavanje slika u xpm formatu

Ukoliko vaša slika nije u xpm formatu pomoću besplatnog programa za obradu slika GIMP
možete ju pretvoriti u xpm format. Slika mora biti u tekućem maxima direktoriju ili
morate napisati punu stazu do odgovarajuće slike.

slika2:read_xpm("gatos.xpm")$

wxdraw2d(image(slika2,0,0,8,5))$

slika3:rgb2level(slika2)$

wxdraw2d(image(slika3,0,0,8,5))$

wxdraw2d(palette=gray,image(slika3,0,0,8,5))$

budite strpljivi kod učitavanja i prikazivanja donje slike

proba:read_xpm("free.xpm")$

wxdraw2d(image(proba,0,0,5,5));