;+ ; NAME: ; register_demo ; PURPOSE: ; Demonstrate how to use subreg.pro and mosf.pro to register and mosaic images ; ; NOTES: ; Note that this just shows off the basics of how to use this code. ; subreg and mosf both have many, many options. You should take a look ; at the documentation for each of those to find out more. ; Frankly, they've grown ; a little crufty over time. None of this code is very clean! But it ; works well enough in practice... ; ; ; INPUTS: ; imgs an array of images. ; OUTPUTS: ; mosaic the final mosaic of the images ; mosaic_exp an array showing how many original images (exposures) ; contributed to each pixel of the output mosaic. ; KEYWORDS: ; ; HISTORY: ; Began 2003-07-30 21:44:38 by Marshall Perrin ;- ;########################################################################### ; ; LICENSE ; ; This software is OSI Certified Open Source Software. ; OSI Certified is a certification mark of the Open Source Initiative. ; ; Copyright © 2003 by Marshall Perrin ; ; This software is provided "as-is", without any express or ; implied warranty. In no event will the authors be held liable ; for any damages arising from the use of this software. ; ; Permission is granted to anyone to use this software for any ; purpose, including commercial applications, and to alter it and ; redistribute it freely, subject to the following restrictions: ; ; 1. The origin of this software must not be misrepresented; you must ; not claim you wrote the original software. If you use this software ; in a product, an acknowledgment in the product documentation ; would be appreciated, but is not required. ; ; 2. Altered source versions must be plainly marked as such, and must ; not be misrepresented as being the original software. ; ; 3. This notice may not be removed or altered from any source distribution. ; ; For more information on Open Source Software, visit the Open Source ; web site: http://www.opensource.org. ; ;########################################################################### pro register_demo,imgs,mosaic,mosaic_exp ; use cross-correlations to register all images against ; the first one. There are different methods for computing ; the subpixel positioning; see the help for subreg. ; They all work about the same but sometimes one algorithm ; works a bit better than another. subreg,imgs[*,*,0],imgs,shifts ; due to historical reasons, the mosaic-making code takes as ; input, not the shifts between images, but the coordinates ; in each image which map to the same point. But it's easy ; enough to computer this from the shifts vector. This could ; probably all be rewritten to be much cleaner, but it hasn't been ; a priority yet... sz = size(imgs) xo = sz[1]/2 & yo = sz[2]/2 ; arbitrarily choose middle of first iamge. dx=xo-transpose(shifts[0,*]) ; calculate where this is in the other images dy=yo-transpose(shifts[1,*]) ; using the shifts relative to the first one xstar = max(dx) ystar = max(dy) for j = 0, sz[3]-1 do begin ; make sure that we're within the right ranges. This is necessary ; since the FFT shift finding 'wraps', so it can return a shift of -N/2 ; instead of N/2 and so on. I should rewrite this to use where() rather ; than a for loop... if dx[j] lt 0 then dx[j]=dx[j]+sz[1] if dx[j] gt sz[1] then dx[j]=dx[j]-sz[1] if dy[j] lt 0 then dy[j]=dy[j]+sz[2] if dy[j] gt sz[2] then dy[j]=dy[j]-sz[2] endfor ;make mosaic mosf, imgs, dx, dy, mosaic, mosaic_exp,/subpixel,interp_type="F" end