algorytm.org

Implementacja w Delphi/Pascal

Baza Wiedzy
wersja offline serwisu przeznaczona na urządzenia z systemem Android
Darowizny
darowiznaWspomóż rozwój serwisu
Nagłówki RSS
Artykuły
Implementacje
Komentarze
Forum
Bookmarki






Sonda
Implementacji w jakim języku programowania poszukujesz?

Filtrowanie obrazów - Implementacja w Delphi/Pascal
Ocena użytkownikóww: *****  / 3
SłabyŚwietny
Nadesłany przez Tomasz Lubiński, 15 sierpnia 2007 01:00
Kod przedstawiony poniżej przedstawia główną część rozwiązania problemu.
Pobierz pełne rozwiązanie.

Jeżeli nie odpowiada Ci sposób formatowania kodu przez autora skorzystaj z pretty printer'a i dostosuj go automatycznie do siebie.

Filtracja - Delphi/Unit1.pas:
//Filtracja obrazów
//(c) 2006 Tomasz Lubinski
//www.algorytm.org

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, ComCtrls, Grids, Filters;

type

  TForm1 = class(TForm)
    Button1: TButton;
    ObrazKolorowy: TImage;
    ObrazMono: TImage;
    WynikKolorowy: TImage;
    WynikMono: TImage;
    ComboBox1: TComboBox;
    StringGrid1: TStringGrid;
    Label1: TLabel;
    procedure LinearFiltr(Sender: TObject);
    procedure MinFiltr(Sender: TObject);
    procedure MedFiltr(Sender: TObject);    
    procedure MaxFiltr(Sender: TObject);
    procedure KuwaharaFiltr(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    Filtr: array of array of Integer;
    red: array of array of Byte;
    green: array of array of Byte;
    blue: array of array of Byte;
    gray: array of array of Byte;
    Norm: Integer;
    Size: Integer;
    procedure UpdateFilter(NewFiltr: Array of Integer);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation

{$R *.DFM}

procedure TForm1.LinearFiltr(Sender: TObject);
var
    i, j, k, l, margin: Integer;
    rsume, gsume, bsume, graysume: Integer;
begin
margin := Round((size-1)/2);

//filtr dla obrazu kolorowego
for i := margin to ObrazKolorowy.Width-margin-1 do
    for j := margin to ObrazKolorowy.Height-margin-1 do
        begin
            rsume := 0;
            gsume := 0;
            bsume := 0;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        rsume := rsume + Filtr[k,l]*red[i+k-margin,j+l-margin];
                        gsume := gsume + Filtr[k,l]*green[i+k-margin,j+l-margin];
                        bsume := bsume + Filtr[k,l]*blue[i+k-margin,j+l-margin];
                    end;
            rsume := rsume div norm;
            gsume := gsume div norm;
            bsume := bsume div norm;

            if (rsume > 255) then rsume := 255
            else if (rsume < 0) then rsume := 0;
            if (gsume > 255) then gsume := 255
            else if (gsume < 0) then gsume := 0;
            if (bsume > 255) then bsume := 255
            else if (bsume < 0) then bsume := 0;

            WynikKolorowy.Canvas.Pixels[i,j] := rsume + (gsume shl 8) + (bsume shl 16);
        end;

//filtr dla obrazu monochromatycznego
for i := margin to ObrazMono.Width-margin-1 do
    for j := margin to ObrazMono.Height-margin-1 do
        begin
            graysume := 0;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        graysume := graysume + Filtr[k,l]*gray[i+k-margin,j+l-margin];
                    end;
            graysume := graysume div norm;
            if (graysume > 255) then graysume := 255
            else if (graysume < 0) then graysume := 0;

            WynikMono.Canvas.Pixels[i,j] := graysume + (graysume shl 8) + (graysume shl 16);
        end;
end;

procedure TForm1.MinFiltr(Sender: TObject);
var
    i, j, k, l, margin: Integer;
    rmin, gmin, bmin, graymin: Integer;
begin
size := 3;
margin := Round((size-1)/2);

//filtr dla obrazu kolorowego
for i := margin to ObrazKolorowy.Width-margin-1 do
    for j := margin to ObrazKolorowy.Height-margin-1 do
        begin
            rmin := 255;
            gmin := 255;
            bmin := 255;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        if rmin > (red[i+k-margin,j+l-margin]) then rmin := red[i+k-margin,j+l-margin];
                        if gmin > (green[i+k-margin,j+l-margin]) then gmin := green[i+k-margin,j+l-margin];
                        if bmin > (blue[i+k-margin,j+l-margin]) then bmin := blue[i+k-margin,j+l-margin];
                    end;
            WynikKolorowy.Canvas.Pixels[i,j] := rmin + (gmin shl 8) + (bmin shl 16);
        end;

//filtr dla obrazu monochromatycznego
for i := margin to ObrazMono.Width-margin-1 do
    for j := margin to ObrazMono.Height-margin-1 do
        begin
            graymin := 255;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        if graymin > (gray[i+k-margin,j+l-margin]) then graymin := (gray[i+k-margin,j+l-margin]);
                    end;
            WynikMono.Canvas.Pixels[i,j] := graymin + (graymin shl 8) + (graymin shl 16);
        end;
end;

//dla algorytmu Hoar'e - obliczanie mediany
function partition(var c: Array of Integer; a,b: Integer): Integer;
var
 e,tmp: Integer;
begin
a:=a;
b:=b;
e:=c[a];        //elemennt dzielacy
while a<b do
        begin
        while ((a<b) and (c[b]>=e)) do b:=b-1;
        while ((a<b) and (c[a]<e)) do a:=a+1;
        if (a<b) then
                begin
                tmp:=c[a];
                c[a]:=c[b];
                c[b]:=tmp;
                end;
        end;
partition:=a;
end;

//algorytmu Hoar'e - obliczanie mediany
function med(var c: Array of Integer): Integer;
var
        i, j, k, w : Integer;
begin
//algorytm Hoare'a
i:=0;
j:=length(c) - 1;
w:=j div 2;
while (i<>j) do
begin
        k:=partition(c,i,j);
        k:=k-i+1;
        if k>=w then
                j:=i+k-1;
        if k<w then
                begin
                w:=w-k;
                i:=i+k
                end;
end;
med := c[i];
end;

procedure TForm1.MedFiltr(Sender: TObject);
var
    i, j, k, l, m, margin: Integer;
    rval, gval, bval, grayval: Array [1..9] of Integer;
begin
size := 3;
margin := Round((size-1)/2);

//filtr dla obrazu kolorowego
for i := margin to ObrazKolorowy.Width-margin-1 do
    for j := margin to ObrazKolorowy.Height-margin-1 do
        begin
            m := 0;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        m := m + 1;
                        rval[m] := red[i+k-margin,j+l-margin];
                        gval[m] := green[i+k-margin,j+l-margin];
                        bval[m] := blue[i+k-margin,j+l-margin];
                    end;
            WynikKolorowy.Canvas.Pixels[i,j] := med(rval) + (med(gval) shl 8) + (med(bval) shl 16);
        end;

//filtr dla obrazu monochromatycznego
for i := margin to ObrazMono.Width-margin-1 do
    for j := margin to ObrazMono.Height-margin-1 do
        begin
            m := 0;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        m := m + 1;
                        grayval[m] := gray[i+k-margin,j+l-margin]
                    end;
            WynikMono.Canvas.Pixels[i,j] := med(grayval) + (med(grayval) shl 8) + (med(grayval) shl 16);
        end;
end;

procedure TForm1.MaxFiltr(Sender: TObject);
var
    i, j, k, l, margin: Integer;
    rmax, gmax, bmax, graymax: Integer;
begin
size := 3;
margin := Round((size-1)/2);

//filtr dla obrazu kolorowego
for i := margin to ObrazKolorowy.Width-margin-1 do
    for j := margin to ObrazKolorowy.Height-margin-1 do
        begin
            rmax := 0;
            gmax := 0;
            bmax := 0;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        if rmax < (red[i+k-margin,j+l-margin]) then rmax := red[i+k-margin,j+l-margin];
                        if gmax < (green[i+k-margin,j+l-margin]) then gmax := green[i+k-margin,j+l-margin];
                        if bmax < (blue[i+k-margin,j+l-margin]) then bmax := blue[i+k-margin,j+l-margin];
                    end;
            WynikKolorowy.Canvas.Pixels[i,j] := rmax + (gmax shl 8) + (bmax shl 16);
        end;

//filtr dla obrazu monochromatycznego
for i := margin to ObrazMono.Width-margin-1 do
    for j := margin to ObrazMono.Height-margin-1 do
        begin
            graymax := 0;
            for k := 0 to size-1 do
                for l := 0 to size-1 do
                    begin
                        if graymax < (gray[i+k-margin,j+l-margin]) then graymax := gray[i+k-margin,j+l-margin];
                    end;
            WynikMono.Canvas.Pixels[i,j] := graymax + (graymax shl 8) + (graymax shl 16);
        end;
end;

procedure TForm1.KuwaharaFiltr(Sender: TObject);
var
    i, j, k, l, margin, m, mr, mg, mb: Integer;
    rm, gm, bm, graym: Array [1..4] of Real;  //wartosci srednie
    rs, gs, bs, grays: Array [1..4] of Real;  //wariancje
begin
size := 5;
margin := Round((size-1)/2);

//filtr dla obrazu kolorowego
for i := margin to ObrazKolorowy.Width-margin-1 do
    for j := margin to ObrazKolorowy.Height-margin-1 do
        begin
            //oblicz wartosci srednie
            for k := 1 to 4 do
               begin
                  rm[k] := 0;
                  gm[k] := 0;
                  bm[k] := 0;
               end;

            for k := 0 to 2 do
                for l := 0 to 2 do
                    begin
                       rm[1] := rm[1] + red[i+k-margin][j+l-margin] / 9.0;
                       rm[2] := rm[2] + red[i+k][j+l-margin] / 9.0;
                       rm[3] := rm[3] + red[i+k-margin][j+l] / 9.0;
                       rm[4] := rm[4] + red[i+k][j+l] / 9.0;

                       gm[1] := gm[1] + green[i+k-margin][j+l-margin] / 9.0;
                       gm[2] := gm[2] + green[i+k][j+l-margin] / 9.0;
                       gm[3] := gm[3] + green[i+k-margin][j+l] / 9.0;
                       gm[4] := gm[4] + green[i+k][j+l] / 9.0;

                       bm[1] := bm[1] + blue[i+k-margin][j+l-margin] / 9.0;
                       bm[2] := bm[2] + blue[i+k][j+l-margin] / 9.0;
                       bm[3] := bm[3] + blue[i+k-margin][j+l] / 9.0;
                       bm[4] := bm[4] + blue[i+k][j+l] / 9.0;
                    end;

            //oblicz wariancje
            for k := 1 to 4 do
               begin
                  rs[k] := 0;
                  gs[k] := 0;
                  bs[k] := 0;
               end;
            for k := 0 to 2 do
                for l := 0 to 2 do
                    begin
                       rs[1] := rs[1] + (red[i+k-margin][j+l-margin] - rm[1]) * (red[i+k-margin][j+l-margin] - rm[2]);
                       rs[2] := rs[2] + (red[i+k][j+l-margin] - rm[2]) * (red[i+k][j+l-margin] - rm[2]);
                       rs[3] := rs[3] + (red[i+k-margin][j+l] - rm[3]) * (red[i+k-margin][j+l] - rm[3]);
                       rs[4] := rs[4] + (red[i+k][j+l] - rm[4]) * (red[i+k][j+l] - rm[4]);

                       gs[1] := gs[1] + (green[i+k-margin][j+l-margin] - gm[1]) * (green[i+k-margin][j+l-margin] - gm[2]);
                       gs[2] := gs[2] + (green[i+k][j+l-margin] - gm[2]) * (green[i+k][j+l-margin] - gm[2]);
                       gs[3] := gs[3] + (green[i+k-margin][j+l] - gm[3]) * (green[i+k-margin][j+l] - gm[3]);
                       gs[4] := gs[4] + (green[i+k][j+l] - gm[4]) * (green[i+k][j+l] - gm[4]);

                       bs[1] := bs[1] + (blue[i+k-margin][j+l-margin] - bm[1]) * (blue[i+k-margin][j+l-margin] - bm[2]);
                       bs[2] := bs[2] + (blue[i+k][j+l-margin] - bm[2]) * (blue[i+k][j+l-margin] - bm[2]);
                       bs[3] := bs[3] + (blue[i+k-margin][j+l] - bm[3]) * (blue[i+k-margin][j+l] - bm[3]);
                       bs[4] := bs[4] + (blue[i+k][j+l] - bm[4]) * (blue[i+k][j+l] - bm[4]);
                    end;

         //znajdz najmniejsza wariancje
         mr:=1;
         for k:=2 to 4 do
            if (rs[k] < rs[mr]) then
               mr := k;

         mg:=1;
         for k:=2 to 4 do
            if (gs[k] < gs[mg]) then
               mg := k;

         mb:=1;
         for k:=2 to 4 do
            if (bs[k] < bs[mb]) then
               mb := k;

            WynikKolorowy.Canvas.Pixels[i,j] := Round(rm[mr]) + (Round(gm[mg]) shl 8) + (Round(bm[mb]) shl 16);

        end;

//filtr dla obrazu monochromatycznego
for i := margin to ObrazMono.Width-margin-1 do
    for j := margin to ObrazMono.Height-margin-1 do
        begin
            //oblicz wartosci srednie
            for k := 1 to 4 do
               graym[k] := 0;
            for k := 0 to 2 do
                for l := 0 to 2 do
                    begin
                       graym[1] := graym[1] + gray[i+k-margin][j+l-margin] / 9.0;
                       graym[2] := graym[2] + gray[i+k][j+l-margin] / 9.0;
                       graym[3] := graym[3] + gray[i+k-margin][j+l] / 9.0;
                       graym[4] := graym[4] + gray[i+k][j+l] / 9.0;
                    end;

            //oblicz wariancje
            for k := 1 to 4 do
               grays[k] := 0;
            for k := 0 to 2 do
                for l := 0 to 2 do
                    begin
                       grays[1] := grays[1] + (gray[i+k-margin][j+l-margin] - graym[1]) * (gray[i+k-margin][j+l-margin] - graym[2]);
                       grays[2] := grays[2] + (gray[i+k][j+l-margin] - graym[2]) * (gray[i+k][j+l-margin] - graym[2]);
                       grays[3] := grays[3] + (gray[i+k-margin][j+l] - graym[3]) * (gray[i+k-margin][j+l] - graym[3]);
                       grays[4] := grays[4] + (gray[i+k][j+l] - graym[4]) * (gray[i+k][j+l] - graym[4]);
                    end;

         //znajdz najmniejsza wariancje
         m:=1;
         for k:=2 to 4 do
            if (grays[k] < grays[m]) then
               m := k;

            WynikMono.Canvas.Pixels[i,j] := Round(graym[m]) + (Round(graym[m]) shl 8) + (Round(graym[m]) shl 16);
        end;
end;

//wybór filtru
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
    case ComboBox1.ItemIndex of
        0:  UpdateFilter(USREDNIAJACY);
        1:  UpdateFilter(KWADRATOWY);
        2:  UpdateFilter(KOLOWY);
        3:  UpdateFilter(LP1);
        4:  UpdateFilter(LP2);
        5:  UpdateFilter(LP3);
        6:  UpdateFilter(PIRAMIDALNY);
        7:  UpdateFilter(STOZKOWY);
        8:  UpdateFilter(GAUSS1);
        9:  UpdateFilter(GAUSS2);
        10: UpdateFilter(GAUSS3);
        11: UpdateFilter(GAUSS4);
        12: UpdateFilter(GAUSS5);
        13: UpdateFilter(USUN_SREDNIA);
        14: UpdateFilter(HP1);
        15: UpdateFilter(HP2);
        16: UpdateFilter(HP3);
        17: UpdateFilter(POZIOMY);
        18: UpdateFilter(PIONOWY);
        19: UpdateFilter(UKOSNY1);
        20: UpdateFilter(UKOSNY2);
        21: UpdateFilter(GRADIENT_E);
        22: UpdateFilter(GRADIENT_SE);
        23: UpdateFilter(GRADIENT_S);
        24: UpdateFilter(GRADIENT_SW);
        25: UpdateFilter(GRADIENT_W);
        26: UpdateFilter(GRADIENT_NW);
        27: UpdateFilter(GRADIENT_N);
        28: UpdateFilter(GRADIENT_NE);
        29: UpdateFilter(UWYPUKLAJACY_E);
        30: UpdateFilter(UWYPUKLAJACY_SE);
        31: UpdateFilter(UWYPUKLAJACY_S);
        32: UpdateFilter(UWYPUKLAJACY_SW);
        33: UpdateFilter(UWYPUKLAJACY_W);
        34: UpdateFilter(UWYPUKLAJACY_NW);
        35: UpdateFilter(UWYPUKLAJACY_N);
        36: UpdateFilter(UWYPUKLAJACY_NE);
        37: UpdateFilter(LAPL1);
        38: UpdateFilter(LAPL2);
        39: UpdateFilter(LAPL3);
        40: UpdateFilter(LAPL_SKOSNY);
        41: UpdateFilter(LAPL_POZIOMY);
        42: UpdateFilter(LAPL_PIONOWY);
        43: UpdateFilter(SOBEL_POZIOMY);
        44: UpdateFilter(SOBEL_PIONOWY);
        45: UpdateFilter(PREWITT_POZIOMY);
        46: UpdateFilter(PREWITT_PIONOWY);
        47: begin
            Button1.OnClick := MedFiltr;
            Label1.Visible := False;
            StringGrid1.Visible := False;
            end;
        48: begin
            Button1.OnClick := MinFiltr;
            Label1.Visible := False;
            StringGrid1.Visible := False;
            end;
        49: begin
            Button1.OnClick := MaxFiltr;
            Label1.Visible := False;
            StringGrid1.Visible := False;
            end;
        50: begin
            Button1.OnClick := KuwaharaFiltr;
            Label1.Visible := False;
            StringGrid1.Visible := False;
            end;
    end;
end;

//zaladowanie wybranego filtru
procedure TForm1.UpdateFilter(NewFiltr: Array of Integer);
var
    length, i, j: Integer;
begin
length := High(NewFiltr) + 1;
size := Round(Sqrt(length));
StringGrid1.RowCount := size;
StringGrid1.ColCount := size;
SetLength(Filtr, size);
for i := 0 to size-1 do
    SetLength(Filtr[i], size);
for i := 0 to size-1 do
    for j := 0 to size-1 do
        begin
            Filtr[i,j] := NewFiltr[i*size + j];
            StringGrid1.Cells[i,j] := FloatToStr(Filtr[i,j]);
        end;
Norm := 0;
for i := 0 to size-1 do
    for j := 0 to size-1 do
        Norm := Norm + Filtr[i,j];
if Norm = 0 then Norm := 1;
Label1.Caption := '1/' + FloatToStr(Norm) + ' *';
Label1.Visible := True;
StringGrid1.Visible := True;
Button1.OnClick := LinearFiltr;
end;

//wczytaj kolory piksli z obrazow do tablic
procedure TForm1.FormCreate(Sender: TObject);
var
        i, j: Integer;
        color: TColor;
begin
SetLength(red, ObrazKolorowy.Width);
SetLength(green, ObrazKolorowy.Width);
SetLength(blue, ObrazKolorowy.Width);
for i := 0 to ObrazKolorowy.Width-1 do
    begin
       SetLength(red[i], ObrazKolorowy.Height);
       SetLength(green[i], ObrazKolorowy.Height);
       SetLength(blue[i], ObrazKolorowy.Height);
       for j := 0 to ObrazKolorowy.Height-1 do
          begin
             color := ObrazKolorowy.Canvas.Pixels[i,j];
             red[i,j] := (color and $FF);
             green[i,j] := ((color shr 8) and $FF);
             blue[i,j] := ((color shr 16) and $FF);
          end
    end;
SetLength(gray, ObrazMono.Width);
for i := 0 to ObrazMono.Width-1 do
    begin
       SetLength(gray[i], ObrazMono.Height);
       for j := 0 to ObrazMono.Height-1 do
          begin
             color := ObrazMono.Canvas.Pixels[i,j];
             gray[i,j] := (color and $FF);
          end
    end;
end;

end.

Filtracja - Delphi/Filters.pas:
unit Filters;

interface

const

    USREDNIAJACY: array [0..8] of Integer = (1, 1, 1,
                                            1, 1, 1,
                                            1, 1, 1);

    KWADRATOWY: array [0..24] of Integer = (1, 1, 1, 1, 1,
                                           1, 1, 1, 1, 1,
                                           1, 1, 1, 1, 1,
                                           1, 1, 1, 1, 1,
                                           1, 1, 1, 1, 1);

    KOLOWY: array [0..24] of Integer = (0, 1, 1, 1, 0,
                                       1, 1, 1, 1, 1,
                                       1, 1, 1, 1, 1,
                                       1, 1, 1, 1, 1,
                                       0, 1, 1, 1, 0);

    LP1: array [0..8] of Integer = (1, 1, 1,
                                   1, 2, 1,
                                   1, 1, 1);

    LP2: array [0..8] of Integer = (1, 1, 1,
                                   1, 4, 1,
                                   1, 1, 1);

    LP3: array [0..8] of Integer = (1, 1, 1,
                                   1, 12,1,
                                   1, 1, 1);

    PIRAMIDALNY: array [0..24] of Integer = (1, 2, 3, 2, 1,
                                            2, 4, 6, 4, 2,
                                            3, 6, 9, 6, 3,
                                            2, 4, 6, 4, 2,
                                            1, 2, 3, 2, 1);

    STOZKOWY: array [0..24] of Integer = (0, 0, 1, 0, 0,
                                         0, 2, 2, 2, 0,
                                         1, 2, 5, 2, 1,
                                         0, 2, 2, 2, 0,
                                         0, 0, 1, 0, 0);

    GAUSS1: array [0..8] of Integer = (1, 2, 1,
                                      2, 4, 2,
                                      1, 2, 1);

    GAUSS2: array [0..24] of Integer = (1, 1, 2, 1, 1,
                                       1, 2, 4, 2, 1,
                                       2, 4, 8, 4, 2,
                                       1, 2, 4, 2, 1,
                                       1, 1, 2, 1, 1);

    GAUSS3: array [0..24] of Integer = (0, 1, 2, 1, 0,
                                       1, 4, 8, 4, 1,
                                       2, 8, 16,8, 2,
                                       1, 4, 8, 4, 1,
                                       0, 1, 2, 1, 0);

    GAUSS4: array [0..24] of Integer = (1, 4, 7, 4, 1,
                                       4,16,26,16, 4,
                                       7,26,41,26, 7,
                                       4,26,16,26, 4,
                                       1, 4, 7, 4, 1);

    GAUSS5: array [0..48] of Integer = (1, 1, 2, 2, 2, 1, 1,
                                       1, 2, 2, 4, 2, 2, 1,
                                       2, 2, 4, 8, 4, 2, 2,
                                       2, 4, 8,16, 8, 4, 2,
                                       2, 2, 4, 8, 4, 2, 2,
                                       1, 2, 2, 4, 2, 2, 1,
                                       1, 1, 2, 2, 2, 1, 1);

    USUN_SREDNIA: array [0..8] of Integer = (-1, -1, -1,
                                            -1,  9, -1,
                                            -1, -1, -1);

    HP1: array [0..8] of Integer = ( 0, -1,  0,
                                   -1,  5, -1,
                                    0, -1,  0);

    HP2: array [0..8] of Integer = ( 1, -2,  1,
                                   -2,  5, -2,
                                    1, -2,  1);

    HP3: array [0..8] of Integer = ( 0, -1,  0,
                                   -1,  20, -1,
                                    0, -1,  0);

    POZIOMY: array [0..8] of Integer = ( 0,  0,  0,
                                       -1,  1,  0,
                                        0,  0,  0);
                                                                            
    PIONOWY: array [0..8] of Integer = ( 0, -1,  0,
                                        0,  1,  0,
                                        0,  0,  0);

    UKOSNY1: array [0..8] of Integer = (-1,  0,  0,
                                        0,  1,  0,
                                        0,  0,  0);

    UKOSNY2: array [0..8] of Integer = ( 0,  0, -1,
                                        0,  1,  0,
                                        0,  0,  0);

    GRADIENT_E: array [0..8] of Integer = (-1,  1,  1,
                                          -1, -2,  1,
                                          -1,  1,  1);

    GRADIENT_SE: array [0..8] of Integer = (-1, -1,  1,
                                           -1, -2,  1,
                                            1,  1,  1);

    GRADIENT_S: array [0..8] of Integer = (-1, -1, -1,
                                           1, -2,  1,
                                           1,  1,  1);

    GRADIENT_SW: array [0..8] of Integer = ( 1, -1, -1,
                                            1, -2, -1,
                                            1,  1,  1);

    GRADIENT_W: array [0..8] of Integer = ( 1,  1, -1,
                                           1, -2, -1,
                                           1,  1, -1);

    GRADIENT_NW: array [0..8] of Integer = ( 1,  1,  1,
                                            1, -2, -1,
                                            1, -1, -1);

    GRADIENT_N: array [0..8] of Integer = ( 1,  1,  1,
                                           1, -2,  1,
                                          -1, -1, -1);

    GRADIENT_NE: array [0..8] of Integer = ( 1,  1,  1,
                                           -1, -2,  1,
                                           -1, -1,  1);

    UWYPUKLAJACY_E: array [0..8] of Integer = (-1,  0,  1,
                                              -1,  1,  1,
                                              -1,  0,  1);

    UWYPUKLAJACY_SE: array [0..8] of Integer = (-1, -1,  0,
                                               -1,  1,  1,
                                                0,  1,  1);

    UWYPUKLAJACY_S: array [0..8] of Integer = (-1, -1, -1,
                                               0,  1,  0,
                                               1,  1,  1);

    UWYPUKLAJACY_SW: array [0..8] of Integer = ( 0, -1, -1,
                                                1,  1, -1,
                                                1,  1,  0);

    UWYPUKLAJACY_W: array [0..8] of Integer = ( 1,  0, -1,
                                               1,  1, -1,
                                               1,  0, -1);

    UWYPUKLAJACY_NW: array [0..8] of Integer = ( 1,  1,  0,
                                                1,  1, -1,
                                                0, -1, -1);

    UWYPUKLAJACY_N: array [0..8] of Integer = ( 1,  1,  1,
                                               0,  1,  0,
                                              -1, -1, -1);

    UWYPUKLAJACY_NE: array [0..8] of Integer = ( 0,  1,  1,
                                               -1,  1,  1,
                                               -1, -1,  0);

    LAPL1: array [0..8] of Integer = ( 0, -1,  0,
                                     -1,  4, -1,
                                      0, -1,  0);

    LAPL2: array [0..8] of Integer = (-1, -1, -1,
                                     -1,  8, -1,
                                     -1, -1, -1);

    LAPL3: array [0..8] of Integer = ( 1, -2,  1,
                                     -2,  4, -2,
                                      1, -2,  1);

    LAPL_SKOSNY: array [0..8] of Integer = (-1,  0, -1,
                                            0,  4,  0,
                                           -1,  0, -1);

    LAPL_PIONOWY: array [0..8] of Integer = ( 0, -1,  0,
                                             0,  2,  0,
                                             0, -1,  0);

    LAPL_POZIOMY: array [0..8] of Integer = ( 0,  0,  0,
                                            -1,  2, -1,
                                             0,  0,  0);

    SOBEL_POZIOMY: array [0..8] of Integer = ( 1,  2,  1,
                                              0,  0,  0,
                                             -1, -2, -1);

    SOBEL_PIONOWY: array [0..8] of Integer = ( 1,  0, -1,
                                              2,  0, -2,
                                              1,  0, -1);

    PREWITT_POZIOMY: array [0..8] of Integer = (-1, -1, -1,
                                                0,  0,  0,
                                                1,  1,  1);

    PREWITT_PIONOWY: array [0..8] of Integer = ( 1,  0, -1,
                                                1,  0, -1,
                                                1,  0, -1);

implementation

end.

Dodaj komentarz