Re: shifting individual pixels within an image [message #70733] |
Mon, 03 May 2010 06:44 |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On May 3, 3:56 am, barbis <tonimuusim...@gmail.com> wrote:
> Hello all,
>
> pleaseplease help me!
> Quite new on idl and just wondering is there a simple way to move
> individual pixels within an image?
>
> For example a function
>
> output = indishift(input, tx,ty)
>
> where input,tx and ty are same size arrays and e.g if in pixel
> location (30,30) tx has a value 5 and ty has a value 0, then output
> has the same value on (30,30) as the input image PLUS the pixel value
> from input image (35,30).
>
> So tx contains the shifts in x direction and ty in y direction.
>
> Thanks alot for any help!!!
Couldn't you just do something like:
s = size(input,/dimensions)
indx = rebin(indgen(s[0]),s[0],s[1],/sample)
indy = rebin(indgen(1,s[1]),s[0],s[1],/sample)
input2 = input + input[indx+tx,indy+ty]
|
|
|
Re: shifting individual pixels within an image [message #70734 is a reply to message #70733] |
Mon, 03 May 2010 06:41  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On May 3, 10:19 am, David Fanning <n...@dfanning.com> wrote:
> barbis writes:
>> SHIFT function returns the following:
>
>> % SHIFT: Expression must be a scalar or 1 element array in this
>> context: TX.
>
>> it does not accept 2 dim arrays as input.
>
> Not sure where you are getting this information,
> but you are being misinformed. :-)
I think that he means that the amount to shift cannot be an array.
What he seems to want is not what I would call a shift, which is
moving each dimension by a constant value, but to get, for each
position in the array, the value at some other position, given by an
offset, which is not the same for every pixel (or evey dimension).
Then add that to the original value.
It seems he wants something like:
sz=size(input,/dimensions)
;convert offsets (tx,ty) into indexes after offset (ix,iy)
ix=rebin(lindgen(sz[0]),sz[0],sz[1])+tx
iy=rebin(reform(lindgen(sz[1]),1,sz[1]),sz[0],sz[1])+ty
output=input[ix,iy]+input
That is assuming that no shifts will get to out-of-range indexes.
|
|
|
Re: shifting individual pixels within an image [message #70735 is a reply to message #70734] |
Mon, 03 May 2010 06:19  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
barbis writes:
> SHIFT function returns the following:
>
> % SHIFT: Expression must be a scalar or 1 element array in this
> context: TX.
>
> it does not accept 2 dim arrays as input.
Not sure where you are getting this information,
but you are being misinformed. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
Re: shifting individual pixels within an image [message #70739 is a reply to message #70737] |
Mon, 03 May 2010 05:07  |
mankoff
Messages: 131 Registered: March 2004
|
Senior Member |
|
|
On May 3, 12:56 am, barbis <tonimuusim...@gmail.com> wrote:
> Hello all,
>
> pleaseplease help me!
> Quite new on idl and just wondering is there a simple way to move
> individual pixels within an image?
>
> For example a function
>
> output = indishift(input, tx,ty)
>
> where input,tx and ty are same size arrays and e.g if in pixel
> location (30,30) tx has a value 5 and ty has a value 0, then output
> has the same value on (30,30) as the input image PLUS the pixel value
> from input image (35,30).
>
> So tx contains the shifts in x direction and ty in y direction.
>
> Thanks alot for any help!!!
See SHIFT.
|
|
|