Re: Creating a new image from an image input in IDL [message #70796] |
Wed, 05 May 2010 06:57  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
> The only question I have is how would you use a bilinear interpolation
> then. It is important that I take that into account for the after
> picture after the transformation. I am reading in wikipedia what it
> is. I am assuming bilinear interpolation is needed since the
> transformation move pixels to fractional coordinates ??? But in any
> case how would that be done.
Yes that's exactly right, for your problem you will want to do
bilinear interpolation because you'll end up with fractional pixel
coordinates.
The built-in IDL routine INTERPOLATE should work for you. You can use
it by replacing:
oldimage[replicate(chan,npix), oldcoordsX, oldcoordsY]
in the last line with:
interpolate(oldimage[chan,*,*], oldcoordsX, oldcoordsY)
> I am still not clear what this line
> does:
> newcoords = array_indices([nx,ny], lindgen(npix), /dimen)
>
> It initializes an array to lindgen(npix) of the same size of the array
> of original pic???
ARRAY_INDICES maps between 1D indices and 2D coordinates. In other
words, if you have an NX x NY array, you can refer to each element by
its 2D coordinates [X,Y] or by a 1D index X + Y*NX. LINDGEN gives you
a list of all 1D indices, and then ARRAY_INDICES turns those into X,Y
pairs.
> Also for the transformation,
> i.e.,
> oldcoordsX = reform( A * newcoords[0,*] + B * newcoords[1,*], npix)
>
> is oldcoordsX a known or is newcoords a known. From this fragment of
> code, it leads me to believe that newcoords is given and oldcoordsX is
> being solved by the transformation which to me means that oldcoords is
> really the new coordinates after the transformation. Not entirely sure
> if I am understanding your code,but it ran and I saw a before and
> after picture.
Yes, that's correct. You are calculating the coordinates in the old
image (oldcoords) that correspond to a given known position in the new
image (newcoords). If your transformation equation only goes the other
way then things are more complicated...
-Jeremy.
|
|
|