code: def labelmask(self, verbose = None):
          
          if verbose == None:
              verbose = self.verbose
          if verbose:
              print "Labeling mask pixels ..."
          # We morphologicaly dilate the mask to generously connect "sparse" cosmics :
          #dilstruct = np.ones((5,5))
          dilmask = ndimage.morphology.binary_dilation(self.mask, structure=dilstruct, iterations=1, mask=None, output=None, border_value=0, origin=0, brute_force=False)
          # origin = 0 means center
          (labels, n) = ndimage.measurements.label(dilmask)
          #print "Number of cosmic ray hits : %i" % n
          #tofits(labels, "labels.fits", verbose = False)
          slicecouplelist = ndimage.measurements.find_objects(labels)
          # Now we have a huge list of couples of numpy slice objects giving a frame around each object
          # For plotting purposes, we want to transform this into the center of each object.
          if len(slicecouplelist) != n:
              # This never happened, but you never know ...
              raise RuntimeError, "Mega error in labelmask !"
          centers = [[(tup[0].start + tup[0].stop)/2.0, (tup[1].start + tup[1].stop)/2.0] for tup in slicecouplelist]
          # We also want to know how many pixels where affected by each cosmic ray.
          # Why ? Dunno... it's fun and available in scipy :-)
          sizes = ndimage.measurements.sum(self.mask.ravel(), labels.ravel(), np.arange(1,n+1,1))
          retdictlist = [{"name":"%i" % size, "x":center[0], "y":center[1]} for (size, center) in zip(sizes, centers)]
          
          if verbose:
              print "Labeling done"
  
          return retdictlist
docs: Finds and labels the cosmic "islands" and returns a list of dicts containing their positions.
          This is made on purpose for visualizations a la f2n.drawstarslist, but could be useful anyway.