algorytm.org

Implementacja w C/C++

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 C/C++
Ocena użytkownikóww: *****  / 11
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 - C++/Unit1.cpp:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

#include "Filters.h"
TForm1 *Form1;
int *Filter;
unsigned char **red, **green, **blue, **gray;
int Norm;
int Size;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm1::LinearFiltr(TObject *Sender)
{
int rsume, gsume, bsume, graysume;
int margin = ((Size-1)/2);

//filtr dla obrazu kolorowego
for (int i=margin; i<ObrazKolorowy->Width-margin; i++)
    for (int j=margin; j<ObrazKolorowy->Height-margin; j++)
        {
            rsume = 0;
            gsume = 0;
            bsume = 0;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    {
                        rsume += Filter[k*Size+l]*red[i+k-margin][j+l-margin];
                        gsume += Filter[k*Size+l]*green[i+k-margin][j+l-margin];
                        bsume += Filter[k*Size+l]*blue[i+k-margin][j+l-margin];
                    }
            rsume /= Norm;
            gsume /= Norm;
            bsume /= Norm;

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

            WynikKolorowy->Canvas->Pixels[i][j] = (TColor)rsume + (gsume << 8) + (bsume << 16);
        }

//filtr dla obrazu monochromatycznego
for (int i=margin; i<ObrazMono->Width-margin; i++)
    for (int j=margin; j<ObrazMono->Height-margin; j++)
        {
            graysume = 0;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    graysume += Filter[k*Size+l]*gray[i+k-margin][j+l-margin];
            graysume /= Norm;
            if (graysume > 255) graysume = 255;
            else if (graysume < 0) graysume = 0;

            WynikMono->Canvas->Pixels[i][j] = (TColor)graysume + (graysume << 8) + (graysume << 16);
        }
}

void __fastcall TForm1::MinFiltr(TObject *Sender)
{
int rmin, gmin, bmin, graymin;
Size = 3;
int margin = ((Size-1)/2);

//filtr dla obrazu kolorowego
for (int i=margin; i<ObrazKolorowy->Width-margin; i++)
    for (int j=margin; j<ObrazKolorowy->Height-margin; j++)
        {
            rmin = 255;
            gmin = 255;
            bmin = 255;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    {
                        if (rmin > red[i+k-margin][j+l-margin]) rmin = red[i+k-margin][j+l-margin];
                        if (gmin > green[i+k-margin][j+l-margin]) gmin = green[i+k-margin][j+l-margin];
                        if (bmin > blue[i+k-margin][j+l-margin]) bmin = blue[i+k-margin][j+l-margin];
                    }
            WynikKolorowy->Canvas->Pixels[i][j] = (TColor)rmin + (gmin << 8) + (bmin << 16);
        }

//filtr dla obrazu monochromatycznego
for (int i=margin; i<ObrazMono->Width-margin; i++)
    for (int j=margin; j<ObrazMono->Height-margin; j++)
        {
            graymin = 255;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    if (graymin > gray[i+k-margin][j+l-margin]) graymin = gray[i+k-margin][j+l-margin];
            WynikMono->Canvas->Pixels[i][j] = (TColor)graymin + (graymin << 8) + (graymin << 16);
        }
}

void __fastcall TForm1::MaxFiltr(TObject *Sender)
{
int rmax, gmax, bmax, graymax;
Size = 3;
int margin = ((Size-1)/2);

//filtr dla obrazu kolorowego
for (int i=margin; i<ObrazKolorowy->Width-margin; i++)
    for (int j=margin; j<ObrazKolorowy->Height-margin; j++)
        {
            rmax = 0;
            gmax = 0;
            bmax = 0;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    {
                        if (rmax < red[i+k-margin][j+l-margin]) rmax = red[i+k-margin][j+l-margin];
                        if (gmax < green[i+k-margin][j+l-margin]) gmax = green[i+k-margin][j+l-margin];
                        if (bmax < blue[i+k-margin][j+l-margin]) bmax = blue[i+k-margin][j+l-margin];
                    }
            WynikKolorowy->Canvas->Pixels[i][j] = (TColor)rmax + (gmax << 8) + (bmax << 16);
        }

//filtr dla obrazu monochromatycznego
for (int i=margin; i<ObrazMono->Width-margin; i++)
    for (int j=margin; j<ObrazMono->Height-margin; j++)
        {
            graymax = 0;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    if (graymax < gray[i+k-margin][j+l-margin]) graymax = gray[i+k-margin][j+l-margin];
            WynikMono->Canvas->Pixels[i][j] = (TColor)graymax + (graymax << 8) + (graymax << 16);
        }
}

//dla algorytmu Hoar'e - obliczanie mediany
int partition(int *c, int a, int b)
{
int e,tmp;
a=a;
b=b;
e=c[a];        //elemennt dzielacy
while (a<b)
        {
        while ((a<b) && (c[b]>=e)) b--;
        while ((a<b) && (c[a]<e)) a++;
        if (a<b)
                {
                tmp=c[a];
                c[a]=c[b];
                c[b]=tmp;
                }
        }
return a;
}

//algorytmu Hoar'e - obliczanie mediany
int med(int *c, int size)
{
//algorytm Hoare'a
int i = 0;
int j = size - 1;
int w = j / 2;
int k;
while (i!=j)
   {
        k=partition(c,i,j);
        k=k-i+1;
        if (k>=w)
                j=i+k-1;
        if (k<w)
           {
                w-=k;
                i+=k;
           }
   }
return c[i];
}

void __fastcall TForm1::MedFiltr(TObject *Sender)
{
int rval[9], gval[9], bval[9], grayval[9], m;
Size = 3;
int margin = ((Size-1)/2);

//filtr dla obrazu kolorowego
for (int i=margin; i<ObrazKolorowy->Width-margin; i++)
    for (int j=margin; j<ObrazKolorowy->Height-margin; j++)
        {
            m = 0;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    {
                        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];
                        m++;
                    }
            WynikKolorowy->Canvas->Pixels[i][j] = (TColor)med(rval,9) + (med(gval,9) << 8) + (med(bval,9) << 16);
        }

//filtr dla obrazu monochromatycznego
for (int i=margin; i<ObrazMono->Width-margin; i++)
    for (int j=margin; j<ObrazMono->Height-margin; j++)
        {
            m = 0;
            for (int k=0; k<Size; k++)
                for (int l=0; l<Size; l++)
                    {
                        grayval[m] = gray[i+k-margin][j+l-margin];
                        m++;
                    }
            WynikMono->Canvas->Pixels[i][j] = (TColor)med(grayval,9) + (med(grayval,9) << 8) + (med(grayval,9) << 16);
        }
}

void __fastcall TForm1::KuwaharaFiltr(TObject *Sender)
{
double rm[4], gm[4], bm[4], graym[4];  //wartosci srednie
double rs[4], gs[4], bs[4], grays[4];  //wariancje
int m, mr, mg, mb;
Size = 5;
int margin = ((Size-1)/2);

//filtr dla obrazu kolorowego
for (int i=margin; i<ObrazKolorowy->Width-margin; i++)
    for (int j=margin; j<ObrazKolorowy->Height-margin; j++)
    {
         //policz srednie
         for (int k=0; k<4; k++)
         {
            rm[k] = 0;
            gm[k] = 0;
            bm[k] = 0;
         }
         for (int k=0; k<3; k++)
             for (int l=0; l<3; l++)
             {
                  rm[0] += red[i+k-margin][j+l-margin] / 9.0;
                  rm[1] += red[i+k][j+l-margin] / 9.0;
                  rm[2] += red[i+k-margin][j+l] / 9.0;
                  rm[3] += red[i+k][j+l] / 9.0;

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

                  bm[0] += blue[i+k-margin][j+l-margin] / 9.0;
                  bm[1] += blue[i+k][j+l-margin] / 9.0;
                  bm[2] += blue[i+k-margin][j+l] / 9.0;
                  bm[3] += blue[i+k][j+l] / 9.0;
             }

         //policz wariancje
         for (int k=0; k<4; k++)
         {
            rs[k] = 0;
            gs[k] = 0;
            bs[k] = 0;
         }
         for (int k=0; k<3; k++)
             for (int l=0; l<3; l++)
             {
                  rs[0] += (red[i+k-margin][j+l-margin] - rm[0]) * (red[i+k-margin][j+l-margin] - rm[0]);
                  rs[1] += (red[i+k][j+l-margin] - rm[1]) * (red[i+k][j+l-margin] - rm[1]);
                  rs[2] += (red[i+k-margin][j+l] - rm[2]) * (red[i+k-margin][j+l] - rm[2]);
                  rs[3] += (red[i+k][j+l] - rm[3]) * (red[i+k][j+l] - rm[3]);

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

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

         //znajdz najmniejsza wariancje
         mr=0;
         for (int k=1; k<4; k++)
            if (rs[k] < rs[mr])
               mr = k;

         mg=0;
         for (int k=1; k<4; k++)
            if (gs[k] < gs[mg])
               mg = k;

         mb=0;
         for (int k=1; k<4; k++)
            if (bs[k] < bs[mb])
               mb = k;

         WynikKolorowy->Canvas->Pixels[i][j] = (TColor)(int)rm[mr] + ((int)gm[mg] << 8) + ((int)bm[mb] << 16);
   }

//filtr dla obrazu monochromatycznego
for (int i=margin; i<ObrazMono->Width-margin; i++)
    for (int j=margin; j<ObrazMono->Height-margin; j++)
    {
         //policz srednie
         graym[0] = 0;
         graym[1] = 0;
         graym[2] = 0;
         graym[3] = 0;
         for (int k=0; k<3; k++)
             for (int l=0; l<3; l++)
             {
                  graym[0] += gray[i+k-margin][j+l-margin] / 9.0;
                  graym[1] += gray[i+k][j+l-margin] / 9.0;
                  graym[2] += gray[i+k-margin][j+l] / 9.0;
                  graym[3] += gray[i+k][j+l] / 9.0;
             }

         //policz wariancje
         grays[0] = 0;
         grays[1] = 0;
         grays[2] = 0;
         grays[3] = 0;
         for (int k=0; k<3; k++)
             for (int l=0; l<3; l++)
             {
                  grays[0] += (gray[i+k-margin][j+l-margin] - graym[0]) * (gray[i+k-margin][j+l-margin] - graym[0]);
                  grays[1] += (gray[i+k][j+l-margin] - graym[1]) * (gray[i+k][j+l-margin] - graym[1]);
                  grays[2] += (gray[i+k-margin][j+l] - graym[2]) * (gray[i+k-margin][j+l] - graym[2]);
                  grays[3] += (gray[i+k][j+l] - graym[3]) * (gray[i+k][j+l] - graym[3]);
             }

         //znajdz najmniejsza wariancje
         m=0;
         for (int k=1; k<4; k++)
            if (grays[k] < grays[m])
               m = k;

         WynikMono->Canvas->Pixels[i][j] = (TColor)(int)graym[m] + ((int)graym[m] << 8) + ((int)graym[m] << 16);
     }
}

//zaladowanie wybranego filtru
void UpdateFilter(int *NewFilter, int size)
{
Form1->StringGrid1->RowCount = size;
Form1->StringGrid1->ColCount = size;
Filter = NewFilter;
for (int i=0; i<size; i++)
    for (int j=0; j<size; j++)
            Form1->StringGrid1->Cells[j][i] = IntToStr(Filter[i+size*j]);

Norm = 0;
for (int i=0; i<size; i++)
    for (int j=0; j<size; j++)
        Norm += Filter[i+size*j];
if (Norm == 0) Norm = 1;
Form1->Label1->Caption = "1/" + IntToStr(Norm) + " *";
Form1->Label1->Visible = TRUE;
Form1->StringGrid1->Visible = TRUE;
Form1->Button1->OnClick = Form1->LinearFiltr;
Size = size;
}

void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
    switch (ComboBox1->ItemIndex) {
        case 0:  UpdateFilter(USREDNIAJACY, USREDNIAJACY_SIZE); break;
        case 1:  UpdateFilter(KWADRATOWY, KWADRATOWY_SIZE); break;
        case 2:  UpdateFilter(KOLOWY, KOLOWY_SIZE); break;
        case 3:  UpdateFilter(LP1, LP1_SIZE); break;
        case 4:  UpdateFilter(LP2, LP2_SIZE); break;
        case 5:  UpdateFilter(LP3, LP3_SIZE); break;
        case 6:  UpdateFilter(PIRAMIDALNY, PIRAMIDALNY_SIZE); break;
        case 7:  UpdateFilter(STOZKOWY, STOZKOWY_SIZE); break;
        case 8:  UpdateFilter(GAUSS1, GAUSS1_SIZE); break;
        case 9:  UpdateFilter(GAUSS2, GAUSS2_SIZE); break;
        case 10: UpdateFilter(GAUSS3, GAUSS3_SIZE); break;
        case 11: UpdateFilter(GAUSS4, GAUSS4_SIZE); break;
        case 12: UpdateFilter(GAUSS5, GAUSS5_SIZE); break;
        case 13: UpdateFilter(USUN_SREDNIA, USUN_SREDNIA_SIZE); break;
        case 14: UpdateFilter(HP1, HP1_SIZE); break;
        case 15: UpdateFilter(HP2, HP2_SIZE); break;
        case 16: UpdateFilter(HP3, HP3_SIZE); break;
        case 17: UpdateFilter(POZIOMY, POZIOMY_SIZE); break;
        case 18: UpdateFilter(PIONOWY, PIONOWY_SIZE); break;
        case 19: UpdateFilter(UKOSNY1, UKOSNY1_SIZE); break;
        case 20: UpdateFilter(UKOSNY2, UKOSNY2_SIZE); break;
        case 21: UpdateFilter(GRADIENT_E, GRADIENT_E_SIZE); break;
        case 22: UpdateFilter(GRADIENT_SE, GRADIENT_SE_SIZE); break;
        case 23: UpdateFilter(GRADIENT_S, GRADIENT_S_SIZE); break;
        case 24: UpdateFilter(GRADIENT_SW, GRADIENT_SW_SIZE); break;
        case 25: UpdateFilter(GRADIENT_W, GRADIENT_W_SIZE); break;
        case 26: UpdateFilter(GRADIENT_NW, GRADIENT_NW_SIZE); break;
        case 27: UpdateFilter(GRADIENT_N, GRADIENT_N_SIZE); break;
        case 28: UpdateFilter(GRADIENT_NE, GRADIENT_NE_SIZE); break;
        case 29: UpdateFilter(UWYPUKLAJACY_E, UWYPUKLAJACY_E_SIZE); break;
        case 30: UpdateFilter(UWYPUKLAJACY_SE, UWYPUKLAJACY_SE_SIZE); break;
        case 31: UpdateFilter(UWYPUKLAJACY_S, UWYPUKLAJACY_S_SIZE); break;
        case 32: UpdateFilter(UWYPUKLAJACY_SW, UWYPUKLAJACY_SW_SIZE); break;
        case 33: UpdateFilter(UWYPUKLAJACY_W, UWYPUKLAJACY_W_SIZE); break;
        case 34: UpdateFilter(UWYPUKLAJACY_NW, UWYPUKLAJACY_NW_SIZE); break;
        case 35: UpdateFilter(UWYPUKLAJACY_N, UWYPUKLAJACY_N_SIZE); break;
        case 36: UpdateFilter(UWYPUKLAJACY_NE, UWYPUKLAJACY_NE_SIZE); break;
        case 37: UpdateFilter(LAPL1, LAPL1_SIZE); break;
        case 38: UpdateFilter(LAPL2, LAPL2_SIZE); break;
        case 39: UpdateFilter(LAPL3, LAPL3_SIZE); break;
        case 40: UpdateFilter(LAPL_SKOSNY, LAPL_SKOSNY_SIZE); break;
        case 41: UpdateFilter(LAPL_POZIOMY, LAPL_POZIOMY_SIZE); break;
        case 42: UpdateFilter(LAPL_PIONOWY, LAPL_PIONOWY_SIZE); break;
        case 43: UpdateFilter(SOBEL_POZIOMY, SOBEL_POZIOMY_SIZE); break;
        case 44: UpdateFilter(SOBEL_PIONOWY, SOBEL_PIONOWY_SIZE); break;
        case 45: UpdateFilter(PREWITT_POZIOMY, PREWITT_POZIOMY_SIZE); break;
        case 46: UpdateFilter(PREWITT_PIONOWY, PREWITT_PIONOWY_SIZE); break;
        case 47: Form1->Button1->OnClick = MedFiltr;
                 Form1->Label1->Visible = FALSE;
                 Form1->StringGrid1->Visible = FALSE;
                 break;
        case 48: Form1->Button1->OnClick = MinFiltr;
                 Form1->Label1->Visible = FALSE;
                 Form1->StringGrid1->Visible = FALSE;
                 break;
        case 49: Form1->Button1->OnClick = MaxFiltr;
                 Form1->Label1->Visible = FALSE;
                 Form1->StringGrid1->Visible = FALSE;
                 break;
        case 50: Form1->Button1->OnClick = KuwaharaFiltr;
                 Form1->Label1->Visible = FALSE;
                 Form1->StringGrid1->Visible = FALSE;
                 break;
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TColor color;
red = (unsigned char**)malloc(Form1->ObrazKolorowy->Width * sizeof(char*));
green = (unsigned char**)malloc(Form1->ObrazKolorowy->Width * sizeof(char*));
blue = (unsigned char**)malloc(Form1->ObrazKolorowy->Width * sizeof(char*));
for (int i=0; i<Form1->ObrazKolorowy->Width; i++)
    {
       red[i] = (unsigned char*)malloc(Form1->ObrazKolorowy->Height);
       green[i] = (unsigned char*)malloc(Form1->ObrazKolorowy->Height);
       blue[i] = (unsigned char*)malloc(Form1->ObrazKolorowy->Height);
       for (int j=0; j<Form1->ObrazKolorowy->Height; j++)
          {
             color = Form1->ObrazKolorowy->Canvas->Pixels[i][j];
             red[i][j] = (color & 0xFF);
             green[i][j] = ((color >> 8) & 0xFF);
             blue[i][j] = ((color >> 16) & 0xFF);
          }
    }
gray = (unsigned char**)malloc(Form1->ObrazMono->Width * sizeof(char*));
for (int i=0; i<Form1->ObrazMono->Width; i++)
    {
       gray[i] = (unsigned char*)malloc(Form1->ObrazMono->Height);
       for (int j=0; j<Form1->ObrazMono->Height; j++)
          {
             color = Form1->ObrazMono->Canvas->Pixels[i][j];
             gray[i][j] = (color & 0xFF);
          }
    }
}
//---------------------------------------------------------------------------




Filtracja - C++/Filters.h:

    int USREDNIAJACY_SIZE = 3;
    int USREDNIAJACY[9] = {1, 1, 1,
                           1, 1, 1,
                           1, 1, 1};

    int KWADRATOWY_SIZE = 5;
    int KWADRATOWY[25] = {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};

    int KOLOWY_SIZE = 5;
    int KOLOWY[25] = {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};

    int LP1_SIZE = 3;
    int LP1[9] = {1, 1, 1,
                  1, 2, 1,
                  1, 1, 1};

    int LP2_SIZE = 3;
    int LP2[9] = {1, 1, 1,
                  1, 4, 1,
                  1, 1, 1};

    int LP3_SIZE = 3;
    int LP3[9] = {1, 1, 1,
                  1, 12,1,
                  1, 1, 1};

    int PIRAMIDALNY_SIZE = 5;
    int PIRAMIDALNY[25] = {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};

    int STOZKOWY_SIZE = 5;
    int STOZKOWY[25] = {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};

    int GAUSS1_SIZE = 3;
    int GAUSS1[9] = {1, 2, 1,
                     2, 4, 2,
                     1, 2, 1};

    int GAUSS2_SIZE = 5;
    int GAUSS2[25] = {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};

    int GAUSS3_SIZE = 5;
    int GAUSS3[25] = {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};

    int GAUSS4_SIZE = 5;
    int GAUSS4[25] = {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};

    int GAUSS5_SIZE = 7;
    int GAUSS5[49] = {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};

    int USUN_SREDNIA_SIZE = 3;
    int USUN_SREDNIA[9] = {-1, -1, -1,
                           -1,  9, -1,
                           -1, -1, -1};

    int HP1_SIZE = 3;
    int HP1[9] = { 0, -1,  0,
                  -1,  5, -1,
                   0, -1,  0};

    int HP2_SIZE = 3;
    int HP2[9] = { 1, -2,  1,
                  -2,  5, -2,
                   1, -2,  1};

    int HP3_SIZE = 3;
    int HP3[9] = { 0, -1,  0,
                  -1,  20, -1,
                   0, -1,  0};

    int POZIOMY_SIZE = 3;
    int POZIOMY[9] = { 0,  0,  0,
                      -1,  1,  0,
                       0,  0,  0};

    int PIONOWY_SIZE = 3;
    int PIONOWY[9] = { 0, -1,  0,
                       0,  1,  0,
                       0,  0,  0};

    int UKOSNY1_SIZE = 3;
    int UKOSNY1[9] = {-1,  0,  0,
                       0,  1,  0,
                       0,  0,  0};

    int UKOSNY2_SIZE = 3;
    int UKOSNY2[9] = { 0,  0, -1,
                       0,  1,  0,
                       0,  0,  0};

    int GRADIENT_E_SIZE = 3;
    int GRADIENT_E[9] = {-1,  1,  1,
                         -1, -2,  1,
                         -1,  1,  1};

    int GRADIENT_SE_SIZE = 3;
    int GRADIENT_SE[9] = {-1, -1,  1,
                          -1, -2,  1,
                           1,  1,  1};

    int GRADIENT_S_SIZE = 3;
    int GRADIENT_S[9] = {-1, -1, -1,
                          1, -2,  1,
                          1,  1,  1};

    int GRADIENT_SW_SIZE = 3;
    int GRADIENT_SW[9] = { 1, -1, -1,
                           1, -2, -1,
                           1,  1,  1};

    int GRADIENT_W_SIZE = 3;
    int GRADIENT_W[9] = { 1,  1, -1,
                          1, -2, -1,
                          1,  1, -1};

    int GRADIENT_NW_SIZE = 3;
    int GRADIENT_NW[9] = { 1,  1,  1,
                           1, -2, -1,
                           1, -1, -1};

    int GRADIENT_N_SIZE = 3;
    int GRADIENT_N[9] = { 1,  1,  1,
                          1, -2,  1,
                         -1, -1, -1};

    int GRADIENT_NE_SIZE = 3;
    int GRADIENT_NE[9] = { 1,  1,  1,
                          -1, -2,  1,
                          -1, -1,  1};

    int UWYPUKLAJACY_E_SIZE = 3;
    int UWYPUKLAJACY_E[9] = {-1,  0,  1,
                             -1,  1,  1,
                             -1,  0,  1};

    int UWYPUKLAJACY_SE_SIZE = 3;
    int UWYPUKLAJACY_SE[9] = {-1, -1,  0,
                              -1,  1,  1,
                               0,  1,  1};

    int UWYPUKLAJACY_S_SIZE = 3;
    int UWYPUKLAJACY_S[9] = {-1, -1, -1,
                              0,  1,  0,
                              1,  1,  1};

    int UWYPUKLAJACY_SW_SIZE = 3;
    int UWYPUKLAJACY_SW[9] = { 0, -1, -1,
                               1,  1, -1,
                               1,  1,  0};

    int UWYPUKLAJACY_W_SIZE = 3;
    int UWYPUKLAJACY_W[9] = { 1,  0, -1,
                              1,  1, -1,
                              1,  0, -1};

    int UWYPUKLAJACY_NW_SIZE = 3;
    int UWYPUKLAJACY_NW[9] = { 1,  1,  0,
                               1,  1, -1,
                               0, -1, -1};

    int UWYPUKLAJACY_N_SIZE = 3;
    int UWYPUKLAJACY_N[9] = { 1,  1,  1,
                              0,  1,  0,
                             -1, -1, -1};

    int UWYPUKLAJACY_NE_SIZE = 3;
    int UWYPUKLAJACY_NE[9] = { 0,  1,  1,
                              -1,  1,  1,
                              -1, -1,  0};

    int LAPL1_SIZE = 3;
    int LAPL1[9] = { 0, -1,  0,
                    -1,  4, -1,
                     0, -1,  0};

    int LAPL2_SIZE = 3;
    int LAPL2[9] = {-1, -1, -1,
                    -1,  8, -1,
                    -1, -1, -1};

    int LAPL3_SIZE = 3;
    int LAPL3[9] = { 1, -2,  1,
                    -2,  4, -2,
                     1, -2,  1};

    int LAPL_SKOSNY_SIZE = 3;
    int LAPL_SKOSNY[9] = {-1,  0, -1,
                           0,  4,  0,
                          -1,  0, -1};

    int LAPL_PIONOWY_SIZE = 3;
    int LAPL_PIONOWY[9] = { 0, -1,  0,
                            0,  2,  0,
                            0, -1,  0};

    int LAPL_POZIOMY_SIZE = 3;
    int LAPL_POZIOMY[9] = { 0,  0,  0,
                           -1,  2, -1,
                            0,  0,  0};

    int SOBEL_POZIOMY_SIZE = 3;
    int SOBEL_POZIOMY[9] = { 1,  2,  1,
                             0,  0,  0,
                            -1, -2, -1};

    int SOBEL_PIONOWY_SIZE = 3;
    int SOBEL_PIONOWY[9] = { 1,  0, -1,
                             2,  0, -2,
                             1,  0, -1};

    int PREWITT_POZIOMY_SIZE = 3;
    int PREWITT_POZIOMY[9] = {-1, -1, -1,
                               0,  0,  0,
                               1,  1,  1};

    int PREWITT_PIONOWY_SIZE = 3;
    int PREWITT_PIONOWY[9] = { 1,  0, -1,
                               1,  0, -1,
                               1,  0, -1};
Dodaj komentarz