def plot(self, im): """ Plots and call auxfun_drag class for moving and removing points. """ #small hack in case there are any 0 intensity images! im = io.imread(im) maxIntensity = np.max(im) if maxIntensity == 0: maxIntensity = np.max(im) + 255 self.drs = [] for bpindex, bp in enumerate(self.bodyparts): color = self.colormap(self.norm(self.colorIndex[bpindex])) if 'CollectedData_' in self.fileName: self.points = [ self.Dataframe[self.scorer][bp]['x'].values[self.iter], self.Dataframe[self.scorer][bp]['y'].values[self.iter], 1.0 ] self.likelihood = self.points[2] else: self.points = [ self.Dataframe[self.scorer][bp]['x'].values[self.iter], self.Dataframe[self.scorer][bp]['y'].values[self.iter], self.Dataframe[self.scorer][bp]['likelihood'].values[ self.iter] ] self.likelihood = self.points[2] if self.move2corner == True: ny, nx = np.shape(im)[0], np.shape(im)[1] if self.points[0] > nx or self.points[0] < 0: self.points[0] = self.center[0] if self.points[1] > ny or self.points[1] < 0: self.points[1] = self.center[1] if not ('CollectedData_' in self.fileName) and self.likelihood < self.threshold: circle = [ patches.Circle((self.points[0], self.points[1]), radius=self.markerSize, facecolor='None', edgecolor=color) ] else: circle = [ patches.Circle((self.points[0], self.points[1]), radius=self.markerSize, fc=color, alpha=self.alpha) ] self.axes.add_patch(circle[0]) self.dr = auxfun_drag.DraggablePoint(circle[0], bp, self.likelihood) self.dr.connect() self.dr.coords = MainFrame.getLabels(self, self.iter)[bpindex] self.drs.append(self.dr) self.updatedCoords.append(self.dr.coords) self.figure.canvas.draw()
def plot(self,im,im_axis): """ Plots and call auxfun_drag class for moving and removing points. """ # self.canvas = FigureCanvas(self, -1, self.fig1) cbar = self.fig1.colorbar(im_axis, ax = self.ax1f1) #small hack in case there are any 0 intensity images! maxIntensity = np.max(im) if maxIntensity == 0: maxIntensity = np.max(im) + 255 cbar.set_ticks(range(12,np.max(im),int(np.floor(maxIntensity/self.num_joints)))) # cbar.set_ticks(range(12,np.max(im),8)) cbar.set_ticklabels(self.bodyparts2plot) normalize = mcolors.Normalize(vmin=np.min(self.colorparams), vmax=np.max(self.colorparams)) # Calling auxfun_drag class for moving points around for bpindex, bp in enumerate(self.bodyparts2plot): color = self.colormap(normalize(bpindex)) if 'CollectedData_' in self.fileName: self.points = [self.Dataframe[self.scorer][bp]['x'].values[self.iter],self.Dataframe[self.scorer][bp]['y'].values[self.iter],1.0] self.likelihood = self.points[2] else: self.points = [self.Dataframe[self.scorer][bp]['x'].values[self.iter],self.Dataframe[self.scorer][bp]['y'].values[self.iter],self.Dataframe[self.scorer][bp]['likelihood'].values[self.iter]] self.likelihood = self.points[2] if self.move2corner==True: ny,nx=np.shape(im)[0],np.shape(im)[1] if self.points[0]>nx or self.points[0]<0: self.points[0]=self.center[0] if self.points[1]>ny or self.points[1]<0: self.points[1]= self.center[1] if not ('CollectedData_' in self.fileName) and self.likelihood < self.threshold: circle = [patches.Circle((self.points[0], self.points[1]), radius=self.markerSize, facecolor = 'None', edgecolor = color)] else: circle = [patches.Circle((self.points[0], self.points[1]), radius=self.markerSize, fc = color, alpha=self.alpha)] self.ax1f1.add_patch(circle[0]) self.dr = auxfun_drag.DraggablePoint(circle[0],bp,self.likelihood,self.adjust_original_labels) self.dr.connect() self.drs.append(self.dr) self.updatedCoords.append(self.dr.coords)