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)
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)
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()