コード例 #1
0
ファイル: CalibrationData.py プロジェクト: kif/Py2DeX
 def find_peaks_automatic(self, x, y, peak_ind):
     massif = Massif(self.img_data.img_data)
     cur_peak_points = massif.find_peaks([x, y])
     if len(cur_peak_points):
         self.points.append(np.array(cur_peak_points))
         self.points_index.append(peak_ind)
     return np.array(cur_peak_points)
コード例 #2
0
ファイル: CalibrationData.py プロジェクト: kif/Py2DeX
 def find_peaks_automatic(self, x, y, peak_ind):
     massif = Massif(self.img_data.img_data)
     cur_peak_points = massif.find_peaks([x, y])
     if len(cur_peak_points):
         self.points.append(np.array(cur_peak_points))
         self.points_index.append(peak_ind)
     return np.array(cur_peak_points)
コード例 #3
0
 def add_points(self, x, y, phi=0.0):
     xc, yc = self.parameters['xc'].value, self.parameters['yc'].value
     idx, idy = self.find_peak(x, y)
     points = [(idy, idx)]
     circles = []
     massif = Massif(self.counts)
     extra_points = massif.find_peaks((idy, idx))
     for point in extra_points:
         points.append(point)
         circles.append(self.circle(point[1], point[0], alpha=0.3))
     phis = np.array([np.arctan2(p[0]-yc, p[1]-xc) for p in points])
     if phi < -0.5*np.pi:
         phis[np.where(phis > 0.0)] -= 2 * np.pi
     self.phi_max = max(*phis, self.phi_max)
     self.points.append([self.circle(idx, idy), points, circles, self.ring])
コード例 #4
0
ファイル: CalibrationModel.py プロジェクト: tmichela/Dioptas
 def find_peaks_automatic(self, x, y, peak_ind):
     """
     Searches peaks by using the Massif algorithm
     :param float x:
         x-coordinate in pixel - should be from original image (not supersampled x-coordinate)
     :param float y:
         y-coordinate in pixel - should be from original image (not supersampled y-coordinate)
     :param peak_ind:
         peak/ring index to which the found points will be added
     :return:
         array of points found
     """
     massif = Massif(self.img_model._img_data)
     cur_peak_points = massif.find_peaks((int(np.round(x)), int(np.round(y))), stdout=DummyStdOut())
     if len(cur_peak_points):
         self.points.append(np.array(cur_peak_points))
         self.points_index.append(peak_ind)
     return np.array(cur_peak_points)
コード例 #5
0
ファイル: CalibrationModel.py プロジェクト: knilav/Dioptas
 def find_peaks_automatic(self, x, y, peak_ind):
     """
     Searches peaks by using the Massif algorithm
     :param x:
         x-coordinate in pixel - should be from original image (not supersampled x-coordinate)
     :param y:
         y-coordinate in pixel - should be from original image (not supersampled y-coordinate)
     :param peak_ind:
         peak/ring index to which the found points will be added
     :return:
         array of points found
     """
     massif = Massif(self.img_model._img_data)
     cur_peak_points = massif.find_peaks([x, y], stdout=DummyStdOut())
     if len(cur_peak_points):
         self.points.append(np.array(cur_peak_points))
         self.points_index.append(peak_ind)
     return np.array(cur_peak_points)
コード例 #6
0
ファイル: calibrate_powder.py プロジェクト: rayosborn/nxpeaks
 def on_button_release(self, event):
     if event.inaxes:
         if abs(event.x - self.xp) > 5 or abs(event.y - self.yp) > 5:
             return
         x, y = self.plotview.inverse_transform(event.xdata, event.ydata)
         for i, point in enumerate(self.points):
             circle = point[0]
             if circle.contains_point(self.plotview.ax.transData.transform((x,y))):
                 circle.remove()
                 for circle in point[2]:
                     circle.remove()
                 del self.points[i]
                 return
         idx, idy = self.find_peak(x, y)
         points = [(idy, idx)]
         circles = []
         massif = Massif(self.counts)
         extra_points = massif.find_peaks((idy, idx))
         for point in extra_points:
             points.append(point)
             circles.append(self.circle(point[1], point[0], alpha=0.3))
         self.points.append([self.circle(idx, idy), points, circles, self.ring])
コード例 #7
0
ファイル: CalibrationData.py プロジェクト: kif/Py2DeX
 def setup_peak_search_algorithm(self, algorithm, mask=None):
     # init the peak search algorithm
     if algorithm == 'Massif':
         self.peak_search_algorithm = Massif(self.img_data.img_data)
     elif algorithm == 'Blob':
         if mask is not None:
             self.peak_search_algorithm = BlobDetection(
                 self.img_data.img_data * mask)
         else:
             self.peak_search_algorithm = BlobDetection(
                 self.img_data.img_data)
         self.peak_search_algorithm.process()
     else:
         return
コード例 #8
0
 def on_button_release(self, event):
     if event.inaxes:
         if abs(event.x - self.xp) > 5 or abs(event.y - self.yp) > 5:
             return
         x, y = self.plotview.inverse_transform(event.xdata, event.ydata)
         for i, point in enumerate(self.points):
             circle = point[0]
             if circle.contains_point(
                     self.plotview.ax.transData.transform((x, y))):
                 circle.remove()
                 for circle in point[2]:
                     circle.remove()
                 del self.points[i]
                 return
         idx, idy = self.find_peak(x, y)
         points = [(idy, idx)]
         circles = []
         massif = Massif(self.counts)
         extra_points = massif.find_peaks((idy, idx))
         for point in extra_points:
             points.append(point)
             circles.append(self.circle(point[1], point[0], alpha=0.3))
         self.points.append(
             [self.circle(idx, idy), points, circles, self.ring])
コード例 #9
0
ファイル: CalibrationModel.py プロジェクト: tmichela/Dioptas
    def setup_peak_search_algorithm(self, algorithm, mask=None):
        """
        Initializes the peak search algorithm on the current image
        :param algorithm:
            peak search algorithm used. Possible algorithms are 'Massif' and 'Blob'
        :param mask:
            if a mask is used during the process this is provided here as a 2d array for the image.
        """

        if algorithm == 'Massif':
            self.peak_search_algorithm = Massif(self.img_model.raw_img_data)
        elif algorithm == 'Blob':
            if mask is not None:
                self.peak_search_algorithm = BlobDetection(self.img_model.raw_img_data * mask)
            else:
                self.peak_search_algorithm = BlobDetection(self.img_model.raw_img_data)
            self.peak_search_algorithm.process()
        else:
            return