PRO image_grid, sx, sy, imxsize, imysize, regions, nregions, status ; Description: This module determines the set of rectangular image regions "regions" created by partitioning ; an image of dimensions "imxsize" by "imysize" pixels using a grid with grid elements of size ; "sx" by "sy" pixels. The grid is defined such that the origin of the image lies in the bottom ; left hand corner of a grid element. The resulting image regions will be of size "sx" by "sy" ; pixels where the image fully covers a grid element, and of a size smaller than "sx" by "sy" ; pixels where the image fails to fully cover a grid element. ; ; Input Parameters: ; ; sx - INTEGER/LONG - The grid element size along the x-axis (pix). ; sy - INTEGER/LONG - The grid element size along the y-axis (pix). ; imxsize - INTEGER/LONG - The image size along the x-axis (pix). ; imysize - INTEGER/LONG - The image size along the y-axis (pix). ; ; Output Parameters: ; ; regions - IDL STRUCTURE - This parameter is an IDL structure with the following tags specifying the ; image regions and their sizes: ; ; lx - LONG - The x-axis pixel index of the lower left-hand corner of the ; rectangular image region. ; ux - LONG - The x-axis pixel index of the upper right-hand corner of the ; rectangular image region. ; ly - LONG - The y-axis pixel index of the lower left-hand corner of the ; rectangular image region. ; uy - LONG - The y-axis pixel index of the upper right-hand corner of the ; rectangular image region. ; xrsize - LONG - The image region size along the x-axis (pix). ; yrsize - LONG - The image region size along the y-axis (pix). ; ; nregions - LONG - The number of image regions specified by the IDL structure "regions". ; status - INTEGER - This parameter is returned with a value of "1" if the partitioning of the image was ; successful, and it is returned with a value of "0" if the partitioning of the image ; was unsuccessful. ; ; Author: Dan Bramich (dmb@ing.iac.es) ; ; History: ; ; 22/12/2008 - Module created (dmb) ;Check the values of "sx", "sy", "imxsize" and "imysize" ;Determine the number of grid elements containing image pixels in each of the x and y directions ;Determine the number of required image regions ;For the special case where the whole image lies within one grid element ;Create the output structure containing the image region specifications ;Determine the current region limits and size in the x direction ;Determine the current region limits and size in the y direction ;Save the current region limits and size in the output structure