galaxy detection code