I'm an unable to get the correct transform of a simple sinusoid. The code was written in java and relevent portion is reproduced below:
new_img is the buffered image
for (int u=0;u<new_img.getWidth();u++)
{
for (int v=0;v<new_img.getHeight();v++)
{
NNN[u][v]=fxy[u][v] * (int)Math.pow(-1,(u+v));
//fxy[u][v],NNN[u][v] are pixel values
F[u][v][0]=0;
F[u][v][1]=0;
uu++;
}
}
int vv=0;
for (int u=0;u<new_img.getWidth();u++)
{
for (int a=0; a<new_img.getWidth();a++)
{
for(int b=0;b<new_img.getHeight();b++)
{
FX[u][0]=FX[u][0]+(NNN[a][b])* Math.cos(Math.PI/180*(6.28318*((u*a)/wd)));//real part of the row wise intermediate transform
FX[u][1] =FX[u][1]-((NNN[a][b])* Math.sin(Math.PI/180*(6.28318*((u*a)/wd))));// imag. part of the row wise transform
}
}
}
for (int u=0;u<new_img.getWidth();u++)
{
for(int v=0;v<new_img.getHeight();v++)
{
for(int b=0;b<new_img.getHeight();b++)
{
//real & Imag. part of the col.wise transform.
F[u][v][0]=F[u][v][0]+(FX[u][0])* Math.cos(Math.PI/180*(6.28318*((v*b)/ht)))+(FX[u][1])* Math.sin(Math.PI/180*(6.28318*((v*b)/ht)));
F[u][v][1] =F[u][v][1]+(FX[u][1])* Math.cos(Math.PI/180*(6.28318*((v*b)/ht)))-((FX[u][0])* Math.sin(Math.PI/180*(6.28318*((v*b)/ht))));
}
double sum11=F[u][v][0]*F[u][v][0];
double sum22=F[u][v][1]*F[u][v][1];
f_r[vv]=(sum11+sum22)/(wd*ht);//wd&ht are the width & height of new_img which are in power of 2.
vv++;
}
}
//the array f_r[] is set into the writable raster of a bufferedimage to obtain the image transform
rstr_f.setPixels(0,0,(new_img.getWidth()-1),(new_img.getHeight()-1),f_r);
I'm unable to get the result.