Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pt2d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
pt2d
Commits
409c3002
Commit
409c3002
authored
2 months ago
by
Christian
Browse files
Options
Downloads
Patches
Plain Diff
Slightly adjusted text on GUI and modified slider ranges
parent
fb980661
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GUI_draft_live.py
+45
-22
45 additions, 22 deletions
GUI_draft_live.py
with
45 additions
and
22 deletions
GUI_draft_live.py
+
45
−
22
View file @
409c3002
...
...
@@ -19,6 +19,8 @@ from PyQt5.QtCore import Qt, QRectF, QSize
# from skimage.filters import gaussian
# def preprocess_image(image, sigma=3, clip_limit=0.01): ...
# def compute_cost_image(path, user_radius, sigma=3, clip_limit=0.01): ...
# def find_path(cost_image, points): ...
# ...
from
live_wire
import
compute_cost_image
,
find_path
,
preprocess_image
...
...
@@ -165,12 +167,25 @@ class CircleEditorWidget(QWidget):
layout
=
QVBoxLayout
(
self
)
self
.
setLayout
(
layout
)
# Specialized CircleEditorGraphicsView
#
# 1) ADD A CENTERED LABEL ABOVE THE IMAGE, WITH BIGGER FONT
#
label_instructions
=
QLabel
(
"
Scale the dot to be of the size of your ridge
"
)
label_instructions
.
setAlignment
(
Qt
.
AlignCenter
)
big_font
=
QFont
(
"
Arial
"
,
20
)
big_font
.
setBold
(
True
)
label_instructions
.
setFont
(
big_font
)
layout
.
addWidget
(
label_instructions
)
#
# 2) THE SPECIALIZED GRAPHICS VIEW THAT SHOWS THE IMAGE
#
self
.
_graphics_view
=
CircleEditorGraphicsView
(
circle_editor_widget
=
self
)
self
.
_scene
=
QGraphicsScene
(
self
)
self
.
_graphics_view
.
setScene
(
self
.
_scene
)
layout
.
addWidget
(
self
.
_graphics_view
)
# Show the image
self
.
_image_item
=
QGraphicsPixmapItem
(
self
.
_pixmap
)
self
.
_scene
.
addItem
(
self
.
_image_item
)
...
...
@@ -184,11 +199,13 @@ class CircleEditorWidget(QWidget):
self
.
_graphics_view
.
setSceneRect
(
QRectF
(
self
.
_pixmap
.
rect
()))
self
.
_graphics_view
.
fitInView
(
self
.
_image_item
,
Qt
.
KeepAspectRatio
)
# Bottom controls
#
# 3) CONTROLS BELOW
#
bottom_layout
=
QHBoxLayout
()
layout
.
addLayout
(
bottom_layout
)
#
We'll store the label in an attribute so we can update with the
slider
value
#
label +
slider
self
.
_lbl_size
=
QLabel
(
f
"
size (
{
self
.
_init_radius
}
)
"
)
bottom_layout
.
addWidget
(
self
.
_lbl_size
)
...
...
@@ -197,6 +214,7 @@ class CircleEditorWidget(QWidget):
self
.
_slider
.
setValue
(
self
.
_init_radius
)
bottom_layout
.
addWidget
(
self
.
_slider
)
# done button
self
.
_btn_done
=
QPushButton
(
"
Done
"
)
bottom_layout
.
addWidget
(
self
.
_btn_done
)
...
...
@@ -335,7 +353,6 @@ class ImageGraphicsView(PanZoomGraphicsView):
# Smoothing parameters
self
.
_savgol_window_length
=
7
self
.
_savgol_polyorder
=
1
def
set_rainbow_enabled
(
self
,
enabled
:
bool
):
self
.
_rainbow_enabled
=
enabled
...
...
@@ -352,12 +369,6 @@ class ImageGraphicsView(PanZoomGraphicsView):
wlen
+=
1
self
.
_savgol_window_length
=
wlen
p
=
round
(
wlen
/
7.0
)
p
=
max
(
1
,
p
)
if
p
>=
wlen
:
p
=
wlen
-
1
self
.
_savgol_polyorder
=
p
self
.
_rebuild_full_path
()
# --------------------------------------------------------------------
...
...
@@ -563,7 +574,7 @@ class ImageGraphicsView(PanZoomGraphicsView):
smoothed
=
savgol_filter
(
arr_xy
,
window_length
=
self
.
_savgol_window_length
,
polyorder
=
self
.
_savgol_polyorder
,
polyorder
=
2
,
axis
=
0
)
big_xy
=
smoothed
.
tolist
()
...
...
@@ -789,16 +800,16 @@ class AdvancedSettingsWidget(QWidget):
controls_layout
.
addWidget
(
self
.
btn_toggle_rainbow
,
0
,
0
)
# 2) Circle editor
self
.
btn_circle_editor
=
QPushButton
(
"
Open Circle Editor
"
)
self
.
btn_circle_editor
=
QPushButton
(
"
Calibrate Kernel Size
"
)
self
.
btn_circle_editor
.
clicked
.
connect
(
self
.
_main_window
.
open_circle_editor
)
controls_layout
.
addWidget
(
self
.
btn_circle_editor
,
0
,
1
)
# 3) Line smoothing slider + label
self
.
_lab_smoothing
=
QLabel
(
"
Line smoothing (
7
)
"
)
self
.
_lab_smoothing
=
QLabel
(
"
Line smoothing (
3
)
"
)
controls_layout
.
addWidget
(
self
.
_lab_smoothing
,
1
,
0
)
self
.
line_smoothing_slider
=
QSlider
(
Qt
.
Horizontal
)
self
.
line_smoothing_slider
.
setRange
(
3
,
51
)
self
.
line_smoothing_slider
.
setValue
(
7
)
self
.
line_smoothing_slider
.
setValue
(
3
)
self
.
line_smoothing_slider
.
valueChanged
.
connect
(
self
.
_on_line_smoothing_slider
)
controls_layout
.
addWidget
(
self
.
line_smoothing_slider
,
1
,
1
)
...
...
@@ -806,8 +817,9 @@ class AdvancedSettingsWidget(QWidget):
self
.
_lab_contrast
=
QLabel
(
"
Contrast (0.01)
"
)
controls_layout
.
addWidget
(
self
.
_lab_contrast
,
2
,
0
)
self
.
contrast_slider
=
QSlider
(
Qt
.
Horizontal
)
self
.
contrast_slider
.
setRange
(
0
,
10
0
)
self
.
contrast_slider
.
setRange
(
1
,
2
0
)
self
.
contrast_slider
.
setValue
(
1
)
# i.e. 0.01
self
.
contrast_slider
.
setSingleStep
(
1
)
self
.
contrast_slider
.
valueChanged
.
connect
(
self
.
_on_contrast_slider
)
controls_layout
.
addWidget
(
self
.
contrast_slider
,
2
,
1
)
...
...
@@ -933,11 +945,26 @@ class MainWindow(QMainWindow):
# Outer widget + layout
self
.
_main_widget
=
QWidget
()
self
.
_main_layout
=
QHBoxLayout
(
self
.
_main_widget
)
# The "left" part: container for the image area + its controls
self
.
_left_panel
=
QVBoxLayout
()
self
.
_main_layout
.
addLayout
(
self
.
_left_panel
)
# We'll make a container widget for the left panel, so we can set stretches:
self
.
_left_container
=
QWidget
()
self
.
_left_container
.
setLayout
(
self
.
_left_panel
)
# Now we add them to the main layout with 70%:30% ratio
self
.
_main_layout
.
addWidget
(
self
.
_left_container
,
7
)
# 70%
# We haven't added the advanced widget yet, but we'll do so with ratio=3 => 30%
self
.
_advanced_widget
=
AdvancedSettingsWidget
(
self
)
# Hide it initially
self
.
_advanced_widget
.
hide
()
self
.
_main_layout
.
addWidget
(
self
.
_advanced_widget
,
3
)
self
.
setCentralWidget
(
self
.
_main_widget
)
#
I
mage view
#
The i
mage view
self
.
image_view
=
ImageGraphicsView
()
self
.
_left_panel
.
addWidget
(
self
.
image_view
)
...
...
@@ -963,11 +990,6 @@ class MainWindow(QMainWindow):
self
.
_left_panel
.
addLayout
(
btn_layout
)
# Advanced settings widget
self
.
_advanced_widget
=
AdvancedSettingsWidget
(
self
)
self
.
_advanced_widget
.
hide
()
self
.
_main_layout
.
addWidget
(
self
.
_advanced_widget
)
self
.
resize
(
1000
,
600
)
self
.
_old_central_widget
=
None
self
.
_editor
=
None
...
...
@@ -977,6 +999,7 @@ class MainWindow(QMainWindow):
self
.
_advanced_widget
.
show
()
else
:
self
.
_advanced_widget
.
hide
()
# Force re-layout
self
.
adjustSize
()
def
open_circle_editor
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment