Bicubic Interpoloation을 사용하여 이미지를 업 샘플링하려고합니다. opencv의 cvResize() 함수와 일치하는 정확한 값이 필요하지만 다음 코드의 결과와 일치하지 않습니다. cvResize()의 결과, 버그를 수정하고 해결할 수 있습니까? 다음 cpp에서 잘못된 점 이미지 크기 조정을위한 부 큐빅 보간 코드
Image *Image::resize_using_Bicubic(int w, int h) {
float dx,dy;
float x,y;
float tx, ty;
float i,j,m,n;
Image *result=new Image(w, h);
tx = (float)this->m_width/(float)w;
ty = (float)this->m_height/(float)h;
for(i=0; i< w; i++)
{
for(j=0; j< h; j++)
{
x = i*tx;
y = j*ty;
dx = float(i-x)-(int)(i-x);
dy = float(j-y)-(int)(j-y);
float temp=0.0;
for(m=-1;m<=2;m++)
{
for(n=-1;n<=2;n++)
{
int HIndex,WIndex;
HIndex=(y+n);
WIndex=(x+m);
if (HIndex<0) {
HIndex=0;
}
else if(HIndex>this->getHeight())
{
HIndex=this->getHeight()-1;
}
if (WIndex<0) {
WIndex=0;
}
else if(WIndex>this->getWidth())
{
WIndex=this->getWidth()-1;
}
temp+=this->getPixel(HIndex,WIndex)*R(m-dx)*R(dy-n);
}
}
result->setPixel(j, i, temp);
}
}
return result;
}
코드의 그 라인을 변경하지만 당신은 아마 코드에 더 많은 버그를 가지고 – pradeepa
:-(차이가 없지만, 적어도이 두 가지 버그가 수정된다. 또한 내가했습니다 두 개 더 버그 수정을 참조하십시오 –