def mask_locs(self):
locs = self.locs[0]
steps_x = len(self.xedges)
steps_y = len(self.yedges)
x_ind = np.floor((locs['x']-self.x_min)/(self.x_max-self.x_min)*steps_x)-1
y_ind = np.floor((locs['y']-self.y_min)/(self.y_max-self.y_min)*steps_y)-1
x_ind = x_ind.astype(int)
y_ind = y_ind.astype(int)
index = self.mask[y_ind,x_ind].astype(bool)
self.index_locs = locs[index]
self.index_locs_out = locs[~index]
H_new, xedges, yedges = np.histogram2d(self.index_locs['x'], self.index_locs['y'], bins=(self.xedges, self.yedges))
self.H_new = H_new.T # Let each row list bins with common y range.
ax4 = self.figure.add_subplot(144, title='Masked image')
ax4.imshow(self.H_new, interpolation='nearest', origin='low',extent=[self.xedges[0], self.xedges[-1], self.yedges[0], self.yedges[-1]])
ax4.grid(False)
self.mask_exists = 1
self.saveButton.setEnabled(True)
self.canvas.draw()
评论列表
文章目录