3.5 Selecting objects ########################################## Simple example ---------------------------------------------------------- It possible to select objects on the displayed images, just with a mouse right-click. The following code shows how to select 2 points:: # -*- coding: iso_8859_1 -*- from aspylib import astro #--- loads image data --- Image = ["C:\\Images\\Image-1.fit"] data = astro.get_imagedata(Image) #--- display image --- fig, ax = astro.display(data) xy = astro.select(fig, ax, 2) print xy raw_input() The image is displayed: .. image:: select_obj.png To perform the selection, the user places the mouse cursor on an object, and makes a right-click. Then the (x,y) image coordinates are copied to the console window, and stored in the list xy returned by the function astro.select(). When selecting two objects, the text below is displayed in the console:: --- loading FITS image --- Image-1.fit x= 252 y= 56 x= 228 y= 198 [[252, 56], [228, 198]] Markers ---------------------------------------------------------- It is possible to mark the position of the selected locations by using:: xy = astro.select(fig, ax, 2, color='r') The color must be specified as in Matplotlib (see for instance `here `_). Then the selection gives: .. image:: select_obj2.png Selecting an unspecified number of objects ---------------------------------------------------------- When the user doesn't know in advance how many objects he wants to select, the following instruction must be used:: xy = astro.select(fig, ax, -1) Then the user selects the objects one by one, by moving the mouse cursor over the objects to be selected and right-clicking. When the last object has been selected, then the selection process can be terminated by right-clicking outside of the image.