Example #1
0
 def lmlabel(self, threshold=0):
     """ Label pixels using the localmax assigment code
     Fills in:
        self.nlabels = number of peaks per frame
        self.labels  = peak labels (should be unique)
        self.total_labels = total number of peaks
     """
     self.nlabels = np.zeros(len(self.nnz), np.int32)
     self.labels = np.zeros(len(self.row), "i")
     # temporary workspaces
     npxmax = self.nnz.max()
     vmx = np.zeros(npxmax, np.float32)
     imx = np.zeros(npxmax, 'i')
     nl = 0
     # TODO: run this in parallel with threads?
     for i, npx in enumerate(self.nnz):
         s = self.ipt[i]
         e = self.ipt[i + 1]
         if npx > 0:
             self.nlabels[i] = cImageD11.sparse_localmaxlabel(
                 self.intensity[s:e], self.row[s:e], self.col[s:e],
                 vmx[:npx], imx[:npx], self.labels[s:e])
             assert (self.labels[s:e] > 0).all()
             self.labels[s:e] += nl
         else:
             self.nlabels[i] = 0
         nl += self.nlabels[i]
     self.total_labels = nl
Example #2
0
def sparse_localmax(frame, label_name="localmax", data_name="intensity"):
    labels = np.zeros(frame.nnz, "i")
    vmx = np.zeros(frame.nnz, np.float32)
    imx = np.zeros(frame.nnz, 'i')
    nlabel = cImageD11.sparse_localmaxlabel(frame.pixels[data_name], frame.row,
                                            frame.col, vmx, imx, labels)
    frame.set_pixels(label_name, labels, {"nlabel": nlabel})
    return nlabel
Example #3
0
 def test1(self):
     import h5py
     nnz = self.row.shape[0]
     labels = np.zeros(nnz, "i")
     vmx = np.zeros(nnz, np.float32)
     imx = np.zeros(nnz, 'i')
     nlabel = cImageD11.sparse_localmaxlabel(self.vals, self.row, self.col,
                                             vmx, imx, labels)
     self.assertTrue(nlabel > 0)
Example #4
0
def sparse_localmax(frame, label_name="localmax", data_name="intensity"):
    labels = np.zeros(frame.nnz, "i")
    vmx = np.zeros(frame.nnz, np.float32)
    imx = np.zeros(frame.nnz, 'i')
    nlabel = cImageD11.sparse_localmaxlabel(frame.pixels[data_name].data,
                                            frame.row, frame.col, vmx, imx,
                                            labels)
    px = Container(labels, **{"data_name": data_name, "nlabel": nlabel})
    frame.set_pixels(label_name, px)
Example #5
0
 def __init__(self, frame, name='data'):
     """
     adds an array names mxlabels
     """
     sparse_labelling.__init__(self, frame, name=name)
     vmx = np.zeros(self.frame.nnz, np.float32)
     imx = np.zeros(self.frame.nnz, 'i')
     self.nlabel = cImageD11.sparse_localmaxlabel(
         self.frame.pixels[self.name], self.frame.row, self.frame.col, vmx,
         imx, self.labels)