السلام عليكم اريد اكتشاف الخطأ في كودي هدا المتعلق بمعالجة الصور الرقمية وتحديدا التكبير باستخدام طريقة }Bilinear interpolation{ مع العلم اني استخدم C++ Buildre
طريقة العمل هي:
Bilinear interpolation
- إستعمال الجيرانِ الأقربِ الأربعة لنقطة.
(x', y') - نظراءُ المستوى الجديدِ، المستوى الجديد سَيَكُونُ
V(x',y')=a x'+by'+cx'y'+d
,b, A c وd معاملَ حَصلَ عليه بحَلّ الـ4 مِنْ المعادلةِ مِنْ 4 مجاهيل مِنْ نقاطِ الشاشة المجاورةِ الـ4.
int q,a0,a1,a2,a3,b0,b1,b2,b3,v,r=0,u=0,max,min;
Graphics::TBitmap *pBitmap1 = new Graphics::TBitmap();
q=StrToInt(Edit1->Text);
Edit1->Text=IntToStr(q); //(q)معامل التكبير
if((q<=0)||(q>10))
ShowMessage(AnsiString("Sorry scale is out of range") + Edit1->Text + ".");
else
{
OrgImage1=new unsigned char*[H*q];
for(i=0;i<H*q;i++)
OrgImage1=new unsigned char[W*q];
pBitmap1->LoadFromFile(OpenPictureDialog1->FileName);
max=OrgImage[0][0];
min=OrgImage[0][0];
for(x=1;x<H-2;x++)
{
for(y=1;y<W-2;y++)
{
l[0]=OrgImage[x+1][y-1];
a0=x+1;
b0=y-1;
l[1]=OrgImage[x-1][y+1];
a1=x-1;
b1=y+1;
l[2]=OrgImage[x+1][y+1];
a2=x+1;
b2=y+1;
l[3]=OrgImage[x-1][y-1];
a3=x-1;
b3=y-1;
g[0][0]=a0;
g[0][1]=b0;
g[0][2]=a0*b0;
g[0][3]=1;
g[1][0]=a1;
g[1][1]=b1;
g[1][2]=a1*b1;
g[1][3]=1;
g[2][0]=a2;
g[2][1]=b2;
g[2][2]=a2*b2;
g[2][3]=1;
g[3][0]=a3;
g[3][1]=b3;
g[3][2]=a3*b3;
g[3][3]=1;
//call jaws**************************
//[g:l]
for(i=0;i<4;i++)
g[4]=l;
//check row
for (i=0;i<3;i++)
for (j=i+1;j<4;j++)
{ if (abs(g[j])>abs(g))
for (k=0;k<5;k++)
{ t = g[k];
g[k] = g[j][k];
g[j][k] = t;
}
}
//proces***********************************
for(i=0;i<3;i++)
{
for(j=i+1;j<4;j++)
{
f[j]=g[j]/g;
for(k=0;k<5;k++)
g[j][k]=g[j][k]-f[j]*g[k];
}
}
// inversive abying
s[3]=g[3][4]/g[3][3];
for(i=2;i>=0;i--)
{
for(j=i+1;j<4;j++)
{
sum=sum+s[j]*g[j];
}
s=(g[4]-sum)/g;
}
//////////////////////////
OrgImage[x][y]=abs(int((s[0]*x)+(s[1]*y)+(s[2]*x*y)+s[3]));
if (OrgImage[x][y]>max)
max=OrgImage[x][y];
if (OrgImage[x][y]<min)
min=OrgImage[x][y];
}
}
for(x=0;x<H-1;x++)
{ u=0;
for(y=0;y<W-1;y++)
{
if(((x==0)&&(y<=W-1))||((y==0)&&(x<=H-1))||((x==H-1)&&(y<=W-1))||((y==W-1)&&(x<=H-1)))
{ //replication
for (int b=0;b<q;b++)
for (int h=0;h<q;h++)
{
OrgImage1[r+b][u+h]=OrgImage[x][y];
}
u+=q;
}//end if
else
{
v=255*OrgImage[x][y]/(max-min);
//replication
for (int b=0;b<q;b++)
for (int h=0;h<q;h++)
{
OrgImage1[r+b][u+h]=v;
}
u+=q;
}//end else
}
r+=q;
}
pBitmap1->Height=pBitmap1->Height*q;
pBitmap1->Width=pBitmap1->Width*q;
for(x=0;x<H*q;x++)
for(y=0;y<W*q;y++)
{
pBitmap1->Canvas->Pixels[y][x]=RGB(OrgImage1[x][y],OrgImage1[x][y],OrgImage1[x][y]);
}
Image3->Picture->Assign(pBitmap1);
}
والمشكلة هي الصورة تظهر تلفزيون مشوش للتشبيه