comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: registering images, shift(/nowrap)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: registering images, shift(/nowrap) [message #32775] Mon, 11 November 2002 06:25
David Fanning is currently offline  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 Go to previous message
David Fanning is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Labels on upper x-axis
Next Topic: Convolution, IDL & Numerical Recipes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Mon Apr 13 09:31:49 PDT 2026

Total time taken to generate the page: 0.00418 seconds