Re: Fractional SHIFT [message #28336] |
Tue, 04 December 2001 05:34 |
the_cacc
Messages: 104 Registered: October 2001
|
Senior Member |
|
|
Oops - should NOT be 9.5 ! As Dick Jackson pointed out to me, I am
constructing a weighted linear combination of surrounding values, so
it should be 4.5. I was trying to construct a simple example, and took
my mind off the numbers just long enough to press 'Post message - No
preview'.
Thanks for the suggestions everyone.
Ciao.
|
|
|
Re: Fractional SHIFT [message #28345 is a reply to message #28336] |
Mon, 03 December 2001 19:55  |
Mark Rivers
Messages: 49 Registered: February 2000
|
Member |
|
|
trouble <the_cacc@hotmail.com> wrote in message
news:5f9f0a23.0112030945.2df9d992@posting.google.com...
> Hi,
>
> Does anyone have a method for doing non-integer shifts ? Interpolate
> doesn't wrap in the way SHIFT does and my hack (based on MOD) is a bit
> dodgy.
> Does anyone know a robust way ?
I use the IDL POLY_2D function for shifting 2-D arrays by fractional pixels
in either direction. I think it will work for 1-D arrays also, but I have
not tested it.
Mark Rivers
|
|
|
Re: Fractional SHIFT [message #28348 is a reply to message #28345] |
Mon, 03 December 2001 13:34  |
tam
Messages: 48 Registered: February 2000
|
Member |
|
|
For 1-D you could try the interpol function rather than interpolate...
It seems to extrapolate beyond the grid which seems to be what you want.
You need to specify both x and y values. I.e., you'll
new = INTERPOL(xvals, yvals, xvalues_to_interpolate_at)
Personally I've always found the behavior of interpolate to be
more useful, but typically I'm worried about going over the edge
of an image....
Tom McGlynn
trouble wrote:
>
> Hi,
>
> Does anyone have a method for doing non-integer shifts ? Interpolate
> doesn't wrap in the way SHIFT does and my hack (based on MOD) is a bit
> dodgy.
>
> To shift orig by 1.5 pixels:
>
> orig = FINDGEN(10)
>
> index = FINDGEN(10)
> delta = 1.5
> index2 = (index+delta) MOD 10
>
> new = INTERPOLATE(orig,index2,/GRID)
>
> PRINT,new
>
> 1.50000 2.50000 3.50000 4.50000 5.50000
> 6.50000
> 7.50000 8.50000 9.00000 0.500000
>
> The 2nd last element of new is wrong (should be 9.5).
>
> Does anyone know a robust way ?
>
> Ciao.
|
|
|
Re: Fractional SHIFT [message #28352 is a reply to message #28348] |
Mon, 03 December 2001 13:10  |
Ralf Flicker
Messages: 19 Registered: October 2001
|
Junior Member |
|
|
trouble wrote:
>
> Hi,
>
> Does anyone have a method for doing non-integer shifts ? Interpolate
> doesn't wrap in the way SHIFT does and my hack (based on MOD) is a bit
> dodgy.
>
> To shift orig by 1.5 pixels:
>
> orig = FINDGEN(10)
>
> index = FINDGEN(10)
> delta = 1.5
> index2 = (index+delta) MOD 10
>
> new = INTERPOLATE(orig,index2,/GRID)
>
> PRINT,new
>
> 1.50000 2.50000 3.50000 4.50000 5.50000
> 6.50000
> 7.50000 8.50000 9.00000 0.500000
>
> The 2nd last element of new is wrong (should be 9.5).
>
> Does anyone know a robust way ?
If you had periodic arrays you could FFT, multiply by a complex
exponential, and FFT back. In your example above, I guess you
could make orig periodic by mirroring it across the origin. No
idea if this will work for you, but I sometimes use the FFT +
complex exponential rather than interpolating for shifting
arrays non-integer steps.
cheers
ralf
--
Ralf Flicker UIN : 65334076
Gemini Observatory http://www.gemini.edu/
670 N. A'Ohoku Pl. Tel : (808) 974-2569
Hilo 96720, HI, USA Fax : (808) 935-9235
|
|
|