astropy / imageutils

Image processing utilities for Astropy (No longer maintained)
https://imageutils.readthedocs.org/
9 stars 17 forks source link

Determine minimum enclosing header of two (or more) images #33

Open keflavich opened 9 years ago

keflavich commented 9 years ago

We need a tool for determining the minimum enclosing header of two images given some frame and pixel scale. Montage determines the overlap and finds such a header.

I've attempted to implement this in FITS_tools, but without much clear success; there is some missing logic in my approach: https://github.com/keflavich/FITS_tools/blob/master/FITS_tools/header_tools.py#L96

if we can clear up that missing logic, I think we could bring that method into imageutils

astrofrog commented 9 years ago

I also have a student working on this, so I will get him to compare his approach and yours.

keflavich commented 9 years ago

Well, my way doesn't exactly work, so please point him here.

keflavich commented 9 years ago

...apparently this is the second time I've implemented exactly this function in the same package.... https://github.com/keflavich/FITS_tools/blob/master/FITS_tools/fits_overlap.py#L25

perrygreenfield commented 9 years ago

Is this asking how to determine the WCS and array size for an output image that is combining multiple input images? Header is a bit vague.

astrofrog commented 9 years ago

@perrygreenfield - yes, strictly speaking WCS and size as you say. Just to give a bit more information on what we are doing here, my student is currently working on determining the optimal rectangular area in pixel space that can be used to fit several images once reprojected. So the idea is you say what type of projection you want, and optionally what reference coordinate, and it will figure out the rest (including optimal rotation)

perrygreenfield commented 9 years ago

If the thing to optimize is the number of pixels, then presumably the algorithm is to first determine the union of the exposures, then the convex hull of that union, and then the minimal bounding rectangle for that convex hull (there is a simple algorithm for that). Pick the tangent point at the center. This ought be good for small fields where curvature isn't a big problem. The spherical_geometry package handles unions (but not convex hulls but I may have forgotten). I suspect the that it could be generalized to the large field case. Is this basically what is needed?

astrofrog commented 9 years ago

@perrygreenfield - yes, I think that's what's needed. I think we may actually want to find the convex hull in pixel space though, since that's where the data is stored and that is what we want to optimize. This would make the problem pretty easy.