| Re: registering images, shift(/nowrap) [message #32775] |
Mon, 11 November 2002 06:25 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
> I should think something like this would work:
Well, *something* like that. More like this, I guess. :-(
FUNCTION ZEROSHIFT, image, n1, n2
if n_elements(image) eq 0 then image = dist(30)
s = size(image, /dimensions)
if n_elements(n1) eq 0 then n1 = s[0]/2
if n_elements(n2) eq 0 then n2 = 0
retvalue = shift(image, n1, n2)
retvalue[0:(0 > (n1-1) < (s[0]-1)), *] = 0
retvalue[*, 0:(0 > (n2-1) < (s[1]-1))] = 0
RETURN, retvalue
END
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
| Re: registering images, shift(/nowrap) [message #32776 is a reply to message #32775] |
Mon, 11 November 2002 06:18  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ronn Kling (ronn@rlkling.com) writes:
> I was wondering if anyone has a routine out there that allows you to shift
> an array without wrapping? The shift routine works great but anything that
> gets pushed off on one edge gets wrapped around to the other. I just want to
> throw this wrapped part away. A simple 1D example is
>
> in = [1,2,3,4,5]
> print, shift(in,2)
> IDL> 4,5,1,2,3
>
> what I want is
>
> print, shiftNoWrap(in,2)
> IDL> 0,0,1,2,3
>
> Of couse, it really needs to work on a 2D image....
I should think something like this would work:
FUNCTION ZEROSHIFT, image, n1, n2
if n_elements(image) eq 0 then image = dist(30)
s = size(image, /dimensions)
if n_elements(n1) eq 0 then n1 = s[0]/2
if n_elements(n2) eq 0 then n2 = s[0]/2
retvalue = shift(image, n1, n2)
retvalue[0:n1-1, *] = 0
retvalue[*, 0:n2-1] = 0
RETURN, retvalue
END
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|