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
| void __fastcall TForm1::Filtre3(int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int k)
{
w=Srce->Width-1;
h=Srce->Height;
P = (jRgb*)Srce->ScanLine[0];
L = (jRgb*)Srce->ScanLine[1];
for(int y = 2; y < h; y++)
{
N = (jRgb*)Srce->ScanLine[y];
T = (jRgb*)Dest->ScanLine[y-1];
for(int x = 1; x < w; x++)
{
b = ( p0*P[x-1].Blue + p1*P[x].Blue + p2*P[x+1].Blue +
p3* L[x-1].Blue + p4*L[x].Blue + p5*L[x+1].Blue +
p6* N[x-1].Blue +p7* N[x].Blue +p8* N[x+1].Blue) / k;
T[x].Blue = (Byte)b;
T[x].Green = (Byte)b;
T[x].Red = (Byte)b;
}
P = L;
L = N;
}
ImageOriginale->Repaint();
ImageOriginale->Visible=true;
return;
}
//Appel de la fonction Filtre3 avec le masque vertical de sobel
Filtre3(-1,0,1,-2,0,2,-1,0,1,4); |
Partager