コード例 #1
0
ファイル: picketfence.py プロジェクト: carlosqueiroz/pylinac
    def add_to_axes(self, axes):
        """Add the overlay to the axes."""
        rect_width = self.pickets[0].sample_width * 2
        for mlc_num, mlc in enumerate(self.pickets[0].mlc_meas):
            # get pass/fail status of all measurements across pickets for that MLC
            if self.settings.action_tolerance is not None:
                if all(
                        picket.mlc_passed_action(mlc_num)
                        for picket in self.pickets):
                    color = 'b'
                elif all(
                        picket.mlc_passed(mlc_num) for picket in self.pickets):
                    color = 'm'
                else:
                    color = 'r'
            elif all(picket.mlc_passed(mlc_num) for picket in self.pickets):
                color = 'b'
            else:
                color = 'r'

            # create a rectangle overlay
            if self.settings.orientation == orientations['UD']:
                r = Rectangle(self.image.shape[1],
                              rect_width,
                              center=(self.image.center.x, mlc.center.y))
            else:
                r = Rectangle(rect_width,
                              self.image.shape[0],
                              center=(mlc.center.x, self.image.center.y))
            r.add_to_axes(axes.axes,
                          edgecolor='none',
                          fill=True,
                          alpha=0.1,
                          facecolor=color)
コード例 #2
0
ファイル: PicketFenceSumImg.py プロジェクト: Jothy/RTQA
    def add_to_axes(self, axes):
        rect_width = self.pickets[0].sample_width*2
        for mlc_num, mlc in enumerate(self.pickets[0].mlc_meas):
            # get pass/fail status of all measurements across pickets for that MLC
            if self.settings.action_tolerance is not None:
                if all(picket.mlc_passed_action(mlc_num) for picket in self.pickets):
                    color = 'b'
                elif all(picket.mlc_passed(mlc_num) for picket in self.pickets):
                    color = 'm'
                else:
                    color = 'r'
            elif all(picket.mlc_passed(mlc_num) for picket in self.pickets):
                color = 'b'
            else:
                color = 'r'

            # create a rectangle overlay
            if self.settings.orientation == orientations['UD']:
                r = Rectangle(self.image.shape[1], rect_width, center=(self.image.center.x, mlc.center.y))
            else:
                r = Rectangle(rect_width, self.image.shape[0], center=(mlc.center.y, self.image.center.y))
            r.add_to_axes(axes.axes, edgecolor='none', fill=True, alpha=0.1, facecolor=color)
コード例 #3
0
 def _create_phantom_outline_object(self):
     """Construct the phantom outline object which will be plotted on the image for visual inspection."""
     outline_type = list(self.phantom_outline_object)[0]
     outline_settings = list(self.phantom_outline_object.values())[0]
     settings = {}
     if outline_type == 'Rectangle':
         side_a = self.phantom_radius*outline_settings['width ratio']
         side_b = self.phantom_radius*outline_settings['height ratio']
         half_hyp = np.sqrt(side_a**2 + side_b**2)/2
         internal_angle = ia = np.rad2deg(np.arctan(side_b/side_a))
         new_x = self.phantom_center.x + half_hyp*(geometry.cos(ia)-geometry.cos(ia+self.phantom_angle))
         new_y = self.phantom_center.y + half_hyp*(geometry.sin(ia)-geometry.sin(ia+self.phantom_angle))
         obj = Rectangle(width=self.phantom_radius*outline_settings['width ratio'],
                         height=self.phantom_radius*outline_settings['height ratio'],
                         center=Point(new_x, new_y))
         settings['angle'] = self.phantom_angle
     elif outline_type == 'Circle':
         obj = Circle(center_point=self.phantom_center,
                      radius=self.phantom_radius*outline_settings['radius ratio'])
     else:
         raise ValueError("An outline object was passed but was not a Circle or Rectangle.")
     return obj, settings
コード例 #4
0
ファイル: picketfence.py プロジェクト: gitter-badger/pylinac
    def plot_analyzed_image(self, guard_rails=True, mlc_peaks=True, overlay=True, show=True):
        """Plot the analyzed image.

        Parameters
        ----------
        guard_rails : bool
            Do/don't plot the picket "guard rails".
        mlc_peaks : bool
            Do/don't plot the MLC positions.
        overlay : bool
            Do/don't plot the alpha overlay of the leaf status.
        """
        # plot the image
        plt.clf()
        ax = plt.imshow(self.image.array, cmap=plt.cm.Greys)

        # plot guard rails and mlc peaks as desired
        for p_num, picket in enumerate(self.pickets):
            if guard_rails:
                picket.add_guards_to_axes(ax.axes)
            if mlc_peaks:
                for idx, mlc_meas in enumerate(picket.mlc_meas):

                    if not mlc_meas.passed:
                        color = 'r'
                    elif self._action_lvl_set and not mlc_meas.passed_action:
                        color = 'm'
                    else:
                        color = 'b'
                    mlc_meas.add_to_axes(ax.axes, color=color, width=1.5)
        # plot the overlay if desired.
        if overlay:
            for mlc_num, mlc in enumerate(self.pickets[0].mlc_meas):

                below_tol = True
                if self._action_lvl_set:
                    below_action = True
                for picket in self.pickets:
                    if not picket.mlc_passed(mlc_num):
                        below_tol = False
                    if self._action_lvl_set and not picket.mlc_passed_action(mlc_num):
                        below_action = False
                if below_tol:
                    if self._action_lvl_set and not below_action:
                        color = 'm'
                    else:
                        color = 'g'
                else:
                    color = 'r'
                if self.orientation == orientations['UD']:
                    r = Rectangle(max(self.image.shape)*2, self._sm_lf_meas_wdth, (mlc.center.x, mlc.center.y))
                else:
                    r = Rectangle(self._sm_lf_meas_wdth, max(self.image.shape) * 2, (mlc.center.x, mlc.center.y))
                r.add_to_axes(ax.axes, edgecolor='none', fill=True, alpha=0.1, facecolor=color)

        plt.xlim([0, self.image.shape[1]])
        plt.ylim([0, self.image.shape[0]])

        plt.axis('off')

        if show:
            plt.show()