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 47 48 49 50 51 52 53 54
|
int tri[1000];
H=Image1->Picture->Bitmap->Height;
W=Image1->Picture->Bitmap->Width;
for(int x=0;x<W;x++)
for(int y=0;y<H;y++)
{
a=Image1->Picture->Bitmap->Canvas->Pixels[x][y];
b=a%256;
g=(a/256)%256;
r=(a/(256*256))%256;
Image[x][y]=(int)(r*0.299+g*0.587+b*0.114);
}
int px, py;
double d;
int max;
for(int x = 0; x < W; x++)
for(int y = 0; y < H; y++)
{
int k=1;
for (int i = -50; i <= +50; i++)
{
px = x + i;
for(int j = -50; j <= +50; j++)
{
py = y + j;
if((px >= 0) && (px < W) && (py >= 0) && (py < W))
{
//d = hypot(px,py);
d=sqrt(pow(x-px,2)+pow(y-py,2));
if (d <= 50.0)
{
tri[k]=Image[px][py];
k=k+1;
}
}
}
}
max=tri[1];
for (int l=2;l<=k;l++) {
if (max<tri[l])max=tri[l];
}
image[x][y]=max;
}
for(int x=0;x<W;x++)
for(int y=0;y<H;y++)
{
Image1->Canvas->Pixels[x][y]=(TColor)((int)(image[x][y]+256*image[x][y]+256*256*image[x][y]));
}
} |