ProfessorBrunner/bayes-detect — pull request #1 by chaithuzz2 (2014-05-26 15:01:33+00:00)
Title: Added a method to find the position of distinct sources in an astronomical image 

I have added a method findSources to detect the sources in a FITS file.

The algorithm I used is a two pass connected component algorithm using 4-connectivity. This involves labelling the pixels according to their connectivity in the first pass. We note any equivalences encountered. These equivalences will be resolved in the second pass using the set-union approach. 4-connectivity is an approach where we consider connectivity with respect to 4 diagonally neighbouring pixels as shown below.

![connectivity](https://cloud.githubusercontent.com/assets/3799830/3083555/f02b4932-e4e4-11e3-8770-1655b213951d.JPG)

An example usage of the method.

file = "simulated_images/ufig_20_g_gal_sub_500.fits"
Sources = findSources(file)

Sources will have a dictionary containing all the objects and their belonging pixels. With this information we can fit the distinct sources into probabilistic models.

To generate a plot of the sources present

Sources = finsSources(file, plot="True")

The results of the file used above is as follows:

Original file
========
![ufig_20_g_gal_sub_500 fits](https://cloud.githubusercontent.com/assets/3799830/3083618/3557ade2-e4e6-11e3-8baf-f1620cae76e2.jpg)

Objects marked and numbered
=======================

![sources_ufig_20_g_gal_sub_500](https://cloud.githubusercontent.com/assets/3799830/3083644/806964f6-e4e6-11e3-9588-37dcf2f2a19e.jpeg)