secv_guis.bimask_app package¶
Submodules¶
secv_guis.bimask_app.dialogs module¶
This module contains definitions for different kinds of dialogs and related components that are specific for this application.
-
class
secv_guis.bimask_app.dialogs.AboutDialog[source]¶ Bases:
secv_guis.dialogs.InfoDialogInfo dialog showing about section
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.dialogs.InstructionsDialog[source]¶ Bases:
secv_guis.dialogs.InfoDialogInfo dialog showing instructions
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.dialogs.KeymapsDialog(mappings, parent=None)[source]¶ Bases:
secv_guis.dialogs.FlexibleDialogInfo dialog showing keymap list
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.dialogs.SaveWarningDialog[source]¶ Bases:
secv_guis.dialogs.InfoDialogA dialog to be prompted when trying to delete unsaved changes. Usage example:
self.dialog = SaveWarningDialog() user_wants_to_remove = bool(self.dialog.exec_()) ...
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.dialogs.SavedInfoDialog(save_dict, timeout_ms=500)[source]¶ Bases:
secv_guis.dialogs.InfoDialogInformative dialog telling about saved paths.
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.dialogs.SavedStateTracker[source]¶ Bases:
objectCreate one of these every time a new state is loaded, call
editedwhen the state has been changed, andsavedwhen saved.The
savedfunction will optionally show an informative dialog.Then call
deletewhen the state is intended to be deleted. The method makes sure that unsaved changes are only deleted with user’s confirmation.Note for developers:
State machines with callbacks are a classic recipe for spaghetti alla callback inferno. Here we didn’t provide a structured way to handle GUI state, so we are applying this as high in the API as possible. It works NOW, but consider restructuring it if it gets in the way.
secv_guis.bimask_app.main_window module¶
This module contains the logic and widgets pertaining to the main window of the bimask app: An app that allows displaying an image, editing a mask on it and also displaying/editing a preannotation mask.
It can be used to efficiently annotate large images with pixel precision. Check instructions.txt for more details.
-
class
secv_guis.bimask_app.main_window.CrackAnnotPaintForm(main_window, brushes, max_brush_size=100, parent=None, thresh_min=0, thresh_max=1, thresh_num_steps=100)[source]¶ Bases:
secv_guis.base_widgets.MaskPaintFormA
MaskPaintFormthat holds a reference to the app’s main window and connects its callbacks with the main window’s corresponding components.Setter
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
class
secv_guis.bimask_app.main_window.FileLists(parent=None, img_extensions=['.png', '.jpg', '.jpeg'], mask_extensions=None, preannot_extensions=None)[source]¶ Bases:
PySide2.QtWidgets.QWidgetA cluster of 3 file lists: one for images, one for masks and one for preannotations.
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.main_window.IntegratedDisplayView(main_window, scale_percent=15)[source]¶ Bases:
secv_guis.masked_scene.DisplayViewThis class implements the main component of the main window: it features a view of the image and the masks, together with a set of operations that can be done on them (painting, updating…), and the callback mechanisms to trigger those operations.
-
clickdrag_action(x, y)[source]¶ Paint to the currently selected mask, with the currently selected brush type, at the given position. The given
x, yposition is in ‘scene coordinates’, i.e. the position from a mouse event has to be translated as follows:xpos, ypos = self.mapToScene(event.pos()).toTuple() self.clickdrag_action(xpos, ypos)
-
mask_from_path(mask_path, rgba)[source]¶ Parameters: - mask_path – Path to an image containing a binary mask, where zero pixels are considered false and non-zero true.
- rgba – Color of the loaded mask
Loads a binary mask into the scene as an RGBA-colored mask.
-
new_image(img_path, initial_mask_color=(219, 54, 148, 150), initial_preannot_color=(102, 214, 123, 100))[source]¶ If successful, removes all elements from the scene and the undo stack, and loads a fresh image and masks. If there are unsaved changes, a dialog asking for confirmation will pop up.
Returns: True if the action completed successfully, False if the user decides to abort.
-
on_left_release(event)[source]¶ If there is an open macro command, closes it and adds it to the undo stack
-
on_move(event, has_left, has_mid, has_right, this_pos, last_pos)[source]¶ Callback implementation, calls
clickdrag_actionif moving while pressing left.
-
preannot_from_path(preannot_path, rgba, upper_thresh=100, lower_thresh=90, normalize=False)[source]¶ This method is prototype-ish: It loads an
.npzfile with and ‘entropy’ field, expected to have a numpy float matrix with same shape as the image. Alternatively it takes a greyscale image file suppoted by PIL.
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.main_window.IntegratedSaveForm(main_window, default_path=None, save_dialog_timeout_ms=1000)[source]¶ Bases:
secv_guis.base_widgets.SaveFormA
SaveFormthat implements this app’s logic, namely, it features 2 masks, one for annot and one for preannot, and saves them as B&W png.-
save_bool_arr_as_img(arr, outpath, overwrite_existing=False)[source]¶ Output: RGB PNG image where false is black (0, 0, 0) and true is white (255, 255, 255).
-
save_masks(states, suffixes, overwrite)[source]¶ Overriden method that we don’t call directly. See
SaveFormfor interface details.
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-
-
class
secv_guis.bimask_app.main_window.MainWindow(parent=None, initial_mask_color=(255, 54, 76, 150), initial_preannot_color=(102, 214, 123, 100), max_brush_size=200)[source]¶ Bases:
PySide2.QtWidgets.QMainWindowThis is the central widget for the bimask application. It is a composition of all the used elements, together with the logic that binds them.
-
DISCARD_P_VALUE= 0.5¶
-
ERASER_TXT= 'Eraser'¶
-
MASKED_PAINTER_TXT= 'Masked painter'¶
-
PAINTER_TXT= 'Painter'¶
-
POINT_LIST_TXT= 'Points'¶
-
THRESH_MAX= 100¶
-
THRESH_MIN= 0¶
-
THRESH_NUM_STEPS= 100¶
-
keymaps()[source]¶ Returns: A dictionary in the form name: QtGui.QKeySequence, where theDefine this GUI’s specific key mappings. Note that this method can be overriden to return a different mapping, but the
name``s have to remain identical, in order to be recognized by ``_add_keymaps.
-
staticMetaObject= <PySide2.QtCore.QMetaObject object>¶
-