gnuastro-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-devel] [task #14409] Polygon vertices from a DS9 region file


From: Mohammad Akhlaghi
Subject: [gnuastro-devel] [task #14409] Polygon vertices from a DS9 region file
Date: Thu, 16 Mar 2017 18:50:32 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

URL:
  <http://savannah.gnu.org/task/?14409>

                 Summary: Polygon vertices from a DS9 region file
                 Project: GNU Astronomy Utilities
            Submitted by: makhlaghi
            Submitted on: Fri 17 Mar 2017 07:50:31 AM JST
         Should Start On: Fri 17 Mar 2017 12:00:00 AM JST
   Should be Finished on: Fri 17 Mar 2017 12:00:00 AM JST
                Category: ImageCrop
                Priority: 5 - Normal
              Item Group: Enhancement
                  Status: Postponed
                 Privacy: Public
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                  Effort: 0.00

    _______________________________________________________

Details:

Allow users to use a file for polygon vertices instead of having to type all
the coordinates in by hand. Typing coordinates (especially for larger number
of vertices) can be prone to errors and is frustrating. 

However, in GUI tools like SAO DS9 <http://ds9.si.edu/site/Home.html>, we can
easily define a polygon region on the image and save the vertices into a file
with specific formats. So when the input is a file name (not a string of
numbers), Crop can parse the output of DS9 directly and users don't have to
deal with the actual numbers. This will greatly speed up the process and
reduces chances of error.

Until then, a script like this can be used to read the DS9 region file (saved
in the `ds9' format in `fk5', see P.S. below) and prepare it for Crop (new
name for ImageCrop) as a shell variable):


$ v=$(awk 'NR==4' ds9.reg | sed -e's/polygon(//'        \
           -e's/\([^,]*,[^,]*\),/\1:/g' -e's/)//' )
$ astimgcrop --mode=wcs image.fits --polygon=$v


This task was suggested by Guillaume Mahler.


---
P.S.

To define a region file in SAO DS9, you can take the following steps: Open the
image with DS9 and activate its "Region" mode with "Edit --> click -->
Region". Then define the region to be a polygon with "Region --> Shape -->
Polygon". Click on the approximate center of the region you want and a small
square will appear. By clicking on the vertices of the square you can shrink
or expand it, clicking and dragging anywhere on the edges will enable you to
define a new vertice. 

After the region has been nicely defined, save it as a file with "Region -->
Save" Regions. You can then select the name and address of the output file,
keep the format as "REG" and press "OK". In the next window, keep format as
"ds9" and "Coordinate System" as "fk5". A plain text file (let's call it
`ds9.reg') is now created that you can feed into the script above.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/task/?14409>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]