def line_profile(self, event): if event.inaxes == self.fig_image_parameter[4].ax: if self.line_prof_edit == 0: if self.line_prof is None: print('create line') self.line_prof_edit = 1 self.line_prof = LineDraw.LineDraw( self.ax_image, epsilon=0.05 * np.sqrt(np.size(self.image_data))) self.line_prof.ConnectDraw() else: print('edit line') self.line_prof_edit = 1 self.line_prof.ConnectMove() elif self.line_prof_edit == 1: print('disconect') self.line_prof_edit = 0 self.line_prof.DisconnectDraw() self.line_prof.DisconnectMove() self.fig_line_prof = plt.figure() self.ax_fig_line_prof = self.fig_line_prof.add_subplot(1, 1, 1) print(self.line_prof.WidthData) first_postion = (self.line_prof.LineCoords[0][1], self.line_prof.LineCoords[0][0]) second_postion = (self.line_prof.LineCoords[1][1], self.line_prof.LineCoords[1][0]) self.profile = skimage.measure.profile_line( self.image_data, first_postion, second_postion, linewidth=int(self.line_prof.WidthData)) self.ax_fig_line_prof.plot(self.profile) plt.show() else: return
def __init__(self, image, axis, colourbar_axis=None, cmap=plt.get_cmap('gray'), filepath=os.getcwd(), polygoncallback=None): '''For plotting Image as an image Input a 2D array to plot as an image, and an axis to plot the image on Optional arguments: define an axis to put a colourbar in, define the filepath to save images to''' self.axis = axis self.colourbar_axis = colourbar_axis self.cmap = cmap self.Image = image self.axis.set_axis_off() self.filepath = filepath self.PlottedImage = self.axis.imshow(self.Image.data, cmap=self.cmap, interpolation='none') if self.colourbar_axis: self.cbar = self.AddColourbar() if image.calibration != 0: self.scalebar = ScaleBar(self.Image.calibration) self.scalebar.box_alpha = 0.5 self.axis.add_artist(self.scalebar) if polygoncallback: self.polygoncallback = polygoncallback else: self.polygoncallback = self.keyboard_press self.PolygonGroups = PolygonGrouper.PolygonGroupManager(self.axis) self.Lines = LineDraw.LineDraw(self.axis) self.canvas = self.axis.figure.canvas self.connect() self.creator = None self.mover = None