text
stringlengths 0
828
|
---|
upper = np.nanpercentile(self.image[:, :, order[color]], self.multicolormax[color].get())
|
self.image[np.where(self.image[:, :, order[color]] < lower)] = lower
|
self.image[np.where(self.image[:, :, order[color]] > upper)] = upper
|
# image values must be between (0,1) so scale image
|
for color, index in order.items():
|
self.image[:, :, index] /= np.nanmax(self.image[:, :, index])"
|
124,"def configure_singlecolor_image(self, scale=False):
|
""""""
|
configures the single color image according to the requested parameters
|
:return: nothing, just updates self.image
|
""""""
|
# determine which channel to use
|
self.image = self.data[self.singlecolorvar.get()]
|
# scale the image by requested power
|
self.image = np.power(self.image, self.singlecolorpower.get())
|
# adjust the percentile thresholds
|
lower = np.nanpercentile(self.image, self.singlecolormin.get())
|
upper = np.nanpercentile(self.image, self.singlecolormax.get())
|
self.image[self.image < lower] = lower
|
self.image[self.image > upper] = upper
|
# image values must be between (0,1) so scale image
|
self.image /= np.nanmax(self.image)"
|
125,"def updateArray(self, array, indices, value):
|
""""""
|
updates array so that pixels at indices take on value
|
:param array: (m,n) array to adjust
|
:param indices: flattened image indices to change value
|
:param value: new value to assign
|
:return: the changed (m,n) array
|
""""""
|
lin = np.arange(array.size)
|
new_array = array.flatten()
|
new_array[lin[indices]] = value
|
return new_array.reshape(array.shape)"
|
126,"def onlasso(self, verts):
|
""""""
|
Main function to control the action of the lasso, allows user to draw on data image and adjust thematic map
|
:param verts: the vertices selected by the lasso
|
:return: nothin, but update the selection array so lassoed region now has the selected theme, redraws canvas
|
""""""
|
p = path.Path(verts)
|
ind = p.contains_points(self.pix, radius=1)
|
self.history.append(self.selection_array.copy())
|
self.selection_array = self.updateArray(self.selection_array,
|
ind,
|
self.solar_class_var.get())
|
self.mask.set_data(self.selection_array)
|
self.fig.canvas.draw_idle()"
|
127,"def make_canvas_frame(self):
|
"""""" Create the data and thematic map images for the first time """"""
|
self.fig, (self.imageax, self.previewax) = plt.subplots(ncols=2,
|
figsize=self.canvas_size,
|
sharex=True, sharey=True,
|
gridspec_kw=self.subplot_grid_spec)
|
self.canvas = FigureCanvasTkAgg(self.fig, master=self.canvas_frame)
|
self.canvas.mpl_connect('button_press_event', self.onclick)
|
self.canvas.mpl_connect('key_press_event', self.onpress)
|
# set up the channel data view
|
self.configure_threecolor_image()
|
self.imageplot = self.imageax.imshow(self.image)
|
self.imageax.set_xlim([0, self.shape[0]])
|
self.imageax.set_ylim([0, self.shape[0]])
|
self.imageax.set_axis_off()
|
self.history.append(self.selection_array)
|
cmap = self.config.solar_cmap
|
self.mask = self.previewax.imshow(self.selection_array,
|
origin='lower',
|
interpolation='nearest',
|
cmap=cmap,
|
vmin=-1, vmax=max([num for _, num in self.config.solar_classes])+1)
|
self.previewax.set_xlim([0, self.shape[0]])
|
self.previewax.set_ylim([0, self.shape[0]])
|
self.previewax.set_aspect(""equal"")
|
self.previewax.set_axis_off()
|
# add selection layer for lasso
|
self.pix = np.arange(self.shape[0]) # assumes square image
|
xv, yv = np.meshgrid(self.pix, self.pix)
|
self.pix = np.vstack((xv.flatten(), yv.flatten())).T
|
lineprops = dict(color=self.config.default['lasso_color'],
|
linewidth=self.config.default['lasso_width'])
|
self.lasso = LassoSelector(self.imageax, self.onlasso, lineprops=lineprops)
|
# display everything
|
self.canvas.show()
|
self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
|
self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
|
# add the tool bar
|
self.toolbarcenterframe = tk.LabelFrame(self.canvas_frame,
|
borderwidth=0,
|
text=""Draw: unlabeled"",
|
relief=tk.FLAT,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.