DSPRelated.com
Forums

Interpolation with JAVA like MATLAB

Started by Walker May 20, 2006
Hello!

I'm programming an Applet in JAVA and I need a method/class/library that
makes Interpolation like function "interp" in MatLab.
My trouble is easy, I have a data vector with 320 samples and I must to
convert it in a data vector with 320*16 samples using Interpolation of the
originals samples.

Any Idea? Somebody know this method/class/library ?
Thanks to help me, i really need it.

Carlos Vargas
fositin@hotmail.com

I have an ingenious idea: look on Java's website!

>Hello! > >I'm programming an Applet in JAVA and I need a method/class/library that >makes Interpolation like function "interp" in MatLab. >My trouble is easy, I have a data vector with 320 samples and I must to >convert it in a data vector with 320*16 samples using Interpolation of
the
>originals samples. > >Any Idea? Somebody know this method/class/library ? >Thanks to help me, i really need it. >
Sometimes it might be faster to just write the code instead of searching the internet. Or at least just look for code written in any language and translate it. (if you know java I suppose you would be able to read C/C++ or pascal) In Numerical Recipes http://www.nr.com you find C++ code for different interpolation methods. gr. Anton
anton,

What you said is certainly correct. But in this case the 2 seconds it
takes to enter the search string "jave interpolation" into to google
will be much faster. The second hit:

http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/Interpolation.html.

Probably even better is to search the java API, in which one will find
many, many interpolation functions.

>What you said is certainly correct. But in this case the 2 seconds it >takes to enter the search string "jave interpolation" into to google >will be much faster. The second hit: > >http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/Interpolation.html. > >Probably even better is to search the java API, in which one will find >many, many interpolation functions.
Oops.. Ok, this java people have their class libraries for everything. Certainly the google query is also faster than waiting for suggestions from comp.dsp, so I somehow assumed he allready looked. ;-) gr. Anton
> >>What you said is certainly correct. But in this case the 2 seconds it >>takes to enter the search string "jave interpolation" into to google >>will be much faster. The second hit: >> >>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/Interpolation.html. >> >>Probably even better is to search the java API, in which one will find >>many, many interpolation functions.
I know it's too simple search into google, but I think we have asked too fast. These function don't implement the same like "interp" in MatLab. The people that write in that blog, oft they search in many webs before they write here...... Gary
Walker wrote:
> > > >>What you said is certainly correct. But in this case the 2 seconds it > >>takes to enter the search string "jave interpolation" into to google > >>will be much faster. The second hit: > >> > >>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/Interpolation.html. > >> > >>Probably even better is to search the java API, in which one will find > >>many, many interpolation functions. > > I know it's too simple search into google, but I think we have asked too > fast. These function don't implement the same like "interp" in MatLab. > > The people that write in that blog, oft they search in many webs before > they write here...... > > Gary
You're probably right. Here is the help header for MATLAB's function.
>> help interp
INTERP Resample data at a higher rate using lowpass interpolation. Y = INTERP(X,R) resamples the sequence in vector X at R times the original sample rate. The resulting resampled vector Y is R times longer, LENGTH(Y) = R*LENGTH(X). A symmetric filter, B, allows the original data to pass through unchanged and interpolates between so that the mean square error between them and their ideal values is minimized. Y = INTERP(X,R,L,CUTOFF) allows specification of arguments L and CUTOFF which otherwise default to 4 and .5 respectively. 2*L is the number of original sample values used to perform the interpolation. Ideally L should be less than or equal to 10. The length of B is 2*L*R+1. The signal is assumed to be band limited with cutoff frequency 0 < CUTOFF <= 1.0. [Y,B] = INTERP(X,R,L,CUTOFF) returns the coefficients of the interpolation filter B. See also DECIMATE, RESAMPLE, UPFIRDN. Reference page in Help browser doc interp So he is probably looking for a sampling rate converter rather than just an interpolator. It looks like MATLAB is just interleaving zeros and then filtering out the images in the spectrum. If that is what is wanted, the only challenging part will be the writing the filter design code. A quick search on google pointed me to the following Parks-Mclellan filter design code in java: http://www.dsptutor.freeuk.com/remez/RemezFIRFilterDesign.html That should let one implement a sampling rate converter rather easily. Hopefully that is more helpful.
>Walker wrote: >> > >> >>What you said is certainly correct. But in this case the 2 seconds
it
>> >>takes to enter the search string "jave interpolation" into to google >> >>will be much faster. The second hit: >> >> >> >>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/Interpolation.html. >> >> >> >>Probably even better is to search the java API, in which one will
find
>> >>many, many interpolation functions. >> >> I know it's too simple search into google, but I think we have asked
too
>> fast. These function don't implement the same like "interp" in MatLab. >> >> The people that write in that blog, oft they search in many webs
before
>> they write here...... >> >> Gary > >You're probably right. Here is the help header for MATLAB's function. > >>> help interp > INTERP Resample data at a higher rate using lowpass interpolation. > Y = INTERP(X,R) resamples the sequence in vector X at R times > the original sample rate. The resulting resampled vector Y is > R times longer, LENGTH(Y) = R*LENGTH(X). > > A symmetric filter, B, allows the original data to pass through > unchanged and interpolates between so that the mean square error > between them and their ideal values is minimized. > Y = INTERP(X,R,L,CUTOFF) allows specification of arguments > L and CUTOFF which otherwise default to 4 and .5 respectively. > 2*L is the number of original sample values used to perform the > interpolation. Ideally L should be less than or equal to 10. > The length of B is 2*L*R+1. The signal is assumed to be band > limited with cutoff frequency 0 < CUTOFF <= 1.0. > [Y,B] = INTERP(X,R,L,CUTOFF) returns the coefficients of the > interpolation filter B. > > See also DECIMATE, RESAMPLE, UPFIRDN. > > Reference page in Help browser > doc interp > >So he is probably looking for a sampling rate converter rather than >just an interpolator. It looks like MATLAB is just interleaving zeros >and then filtering out the images in the spectrum. If that is what is >wanted, the only challenging part will be the writing the filter design >code. A quick search on google pointed me to the following >Parks-Mclellan filter design code in java: > >http://www.dsptutor.freeuk.com/remez/RemezFIRFilterDesign.html > >That should let one implement a sampling rate converter rather easily. > >Hopefully that is more helpful. > >
Thaks you have understand what I would like :). It would be great if I find a rate converter like "interp" in Matlab...It's too compplicate to implement it :S. Carlos Vargas
>Walker wrote: >> > >> >>What you said is certainly correct. But in this case the 2 seconds
it
>> >>takes to enter the search string "jave interpolation" into to google >> >>will be much faster. The second hit: >> >> >> >>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/Interpolation.html. >> >> >> >>Probably even better is to search the java API, in which one will
find
>> >>many, many interpolation functions. >> >> I know it's too simple search into google, but I think we have asked
too
>> fast. These function don't implement the same like "interp" in MatLab. >> >> The people that write in that blog, oft they search in many webs
before
>> they write here...... >> >> Gary > >You're probably right. Here is the help header for MATLAB's function. > >>> help interp > INTERP Resample data at a higher rate using lowpass interpolation. > Y = INTERP(X,R) resamples the sequence in vector X at R times > the original sample rate. The resulting resampled vector Y is > R times longer, LENGTH(Y) = R*LENGTH(X). > > A symmetric filter, B, allows the original data to pass through > unchanged and interpolates between so that the mean square error > between them and their ideal values is minimized. > Y = INTERP(X,R,L,CUTOFF) allows specification of arguments > L and CUTOFF which otherwise default to 4 and .5 respectively. > 2*L is the number of original sample values used to perform the > interpolation. Ideally L should be less than or equal to 10. > The length of B is 2*L*R+1. The signal is assumed to be band > limited with cutoff frequency 0 < CUTOFF <= 1.0. > [Y,B] = INTERP(X,R,L,CUTOFF) returns the coefficients of the > interpolation filter B. > > See also DECIMATE, RESAMPLE, UPFIRDN. > > Reference page in Help browser > doc interp > >So he is probably looking for a sampling rate converter rather than >just an interpolator. It looks like MATLAB is just interleaving zeros >and then filtering out the images in the spectrum. If that is what is >wanted, the only challenging part will be the writing the filter design >code. A quick search on google pointed me to the following >Parks-Mclellan filter design code in java: > >http://www.dsptutor.freeuk.com/remez/RemezFIRFilterDesign.html > >That should let one implement a sampling rate converter rather easily. > >Hopefully that is more helpful. > >
Thaks you have understand what I would like :). It would be great if I find a rate converter like "interp" in Matlab...It's too compplicate to implement it :S. Carlos Vargas
> >Thaks you have understand what I would like :). It would be great if I >find a rate converter like "interp" in Matlab...It's too compplicate to >implement it :S. > >Carlos Vargas >
I have an implementation: 1. Interpoling signal with "rate-1" zeros: for example if rate = 3 Signal: 2 1 4 6 7 ... Signal zeros: 2 0 0 1 0 0 4 0 0 6 0 0 7 0 0 ... 2. Make a simetric sinc with 5-6 lobules at each side, and sample it with "rate"-samples at each lobule. (Principal Lobule "rate"-samples from 0 to 1 and "rate"-samples from -1 to 0). 3. Convolve Signal zeros with that sinc. Note: If you take more lobules (for example 35 at each side) the result will be better, but we will have a large transitory in the signal result. Can somebody make it better? It would be great, if somebody konw how to eliminate that transitori without cut it.