1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| try
{
mat=new int *[height];
for(int i=0;i<=height;i++) {mat[i]=new int [width];}
}
catch(...)
{
ShowMessage("L'allocation dynamique n'a pas pue etre réalisé");
return false;
}
for(int i=0;i<height;i++)
{
for(int j=0;j<width;j++)
{
TColor col=bmp->Canvas->Pixels[i][j];
int R=GetRValue(col);
int G=GetRValue(col);
int B=GetRValue(col);
int NG=(0.299* R) + (0.587*G)+ (0.114* B);
mat[i][j]=NG;
}
}
//Appel de la fonction Remplir Matrice-----------------------------------------------------
for(int i=1;i<height-1;i++)
{
for(int j=1;j<width-1;j++)
{
a= mat[i][j];
b= mat[i+1][j];
RemplirMatrice(1,a,b);
b= mat[i+1][j+1];
RemplirMatrice(2,a,b);
b= mat[i][j+1];
RemplirMatrice(3,a,b);
b= mat[i-1][j+1];
RemplirMatrice(4,a,b);
}}
delete mat;
return true; |