Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-29-2008, 02:16 PM
Member
 
Join Date: May 2008
Posts: 1
smmustakim is on a distinguished road
fast fourier transform in java
Hi! Everybody. I'm unable to get the correct Fourier image of a simple sinusoid. appreciate help in correcting the followinhg code.

void freq_spect(){

double F[][][];
double FX[][];
double f_r[];
double f_r1[];
double NNN[][];
double Four[][];
int fxy[][];
int wd=new_img.getWidth();
int ht=new_img.getHeight();
F=new double[wd][ht][2];
Four=new double[wd][ht];
FX=new double[wd][2];
f_r=new double[wd*ht];
f_r1=new double[wd*ht];
NNN=new double[wd][ht]; img_fourier=newBufferedImage(new_img.getWidth(),ne w_img.getHeight(),BufferedImage.TYPE_BYTE_GRAY);
rstr_f=img_fourier.getRaster(); //writable raster

for (int u=0;u<new_img.getWidth();u++)
{
for (int v=0;v<new_img.getHeight();v++)
{
NNN[u][v]=rstr.getSample(u,v,0); //rstr is the writable raster of the image.
NNN[u][v]=NNN[u][v]* Math.pow(-1,(u+v));
F[u][v][0]=0;
F[u][v][1]=0;
}
}
int vv=0;
for (int u=0;u<new_img.getWidth();u++)
{

FX[u][0]=0; //real array
FX[u][1]=0; //imaginary array

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)));
FX[u][1] =FX[u][1]-((NNN[a][b])* Math.sin(Math.PI/180*( (6.28318*((u*a)/wd))));
}
}
}











vv=0;

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++)
{

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];
Four[u][v]=(sum11+sum22);
f_r[vv]=Four[u][v];
f_r[vv]=Math.sqrt(f_r[vv]); //power spectrum
vv++;
}
}
for (int a=0; a<new_img.getWidth();a++)
for(int b=0;b<new_img.getHeight();b++)
{
rstr_f.setSample(a,b,0,Four[a][b]);
}

repaint();


}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Girl from Sweden needs help fast!!! :):) charlotte New To Java 0 05-25-2008 04:51 PM
Fast Data Transfer 0.9.1 Java Tip Java Announcements 0 04-24-2008 07:41 PM
C++ programmer wants to learn java very fast... joe saunders New To Java 5 01-05-2008 01:26 AM
Fast Data Transfer 0.6.7 Jamie Java Announcements 0 06-14-2007 03:55 PM
Fast Data Transfer 0.6.4 levent Java Announcements 0 05-20-2007 09:55 AM


All times are GMT +3. The time now is 04:23 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org