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
641d222f
Commit
641d222f
authored
3 months ago
by
Christian
Browse files
Options
Downloads
Patches
Plain Diff
Added feature increasing contrast before creating cost image
parent
5d292d48
No related branches found
No related tags found
1 merge request
!3
Live wire to be implemented into GUI
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
live_wire.py
+15
-6
15 additions, 6 deletions
live_wire.py
with
15 additions
and
6 deletions
live_wire.py
+
15
−
6
View file @
641d222f
...
@@ -2,7 +2,7 @@ import time
...
@@ -2,7 +2,7 @@ import time
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
skimage
import
exposure
from
skimage.filters
import
gaussian
from
skimage.filters
import
gaussian
from
skimage.feature
import
canny
from
skimage.feature
import
canny
from
skimage.graph
import
route_through_array
from
skimage.graph
import
route_through_array
...
@@ -59,9 +59,19 @@ def compute_cost(image, sigma=3.0, epsilon=1e-5):
...
@@ -59,9 +59,19 @@ def compute_cost(image, sigma=3.0, epsilon=1e-5):
"""
"""
Smooth the image, run Canny edge detection, then invert the edge map into a cost image.
Smooth the image, run Canny edge detection, then invert the edge map into a cost image.
"""
"""
smoothed_img
=
gaussian
(
image
,
sigma
=
sigma
)
# Apply histogram equalization
image_contrasted
=
exposure
.
equalize_adapthist
(
image
,
clip_limit
=
0.01
)
# Apply smoothing
smoothed_img
=
gaussian
(
image_contrasted
,
sigma
=
sigma
)
# Apply Canny edge detection
canny_img
=
canny
(
smoothed_img
)
canny_img
=
canny
(
smoothed_img
)
# Create cost image
cost_img
=
1.0
/
(
canny_img
+
epsilon
)
# Invert edges: higher cost where edges are stronger
cost_img
=
1.0
/
(
canny_img
+
epsilon
)
# Invert edges: higher cost where edges are stronger
return
cost_img
,
canny_img
return
cost_img
,
canny_img
def
backtrack_pixels_on_image
(
img_color
,
path_coords
,
bgr_color
=
(
0
,
0
,
255
)):
def
backtrack_pixels_on_image
(
img_color
,
path_coords
,
bgr_color
=
(
0
,
0
,
255
)):
...
@@ -74,13 +84,12 @@ def backtrack_pixels_on_image(img_color, path_coords, bgr_color=(0, 0, 255)):
...
@@ -74,13 +84,12 @@ def backtrack_pixels_on_image(img_color, path_coords, bgr_color=(0, 0, 255)):
return
img_color
return
img_color
#### Main Script ####
#### Main Script ####
def
main
():
def
main
():
# Define input parameters
# Define input parameters
image_path
=
'
./tests/slice_60_volQ
.png
'
image_path
=
'
bipes_slice
.png
'
image_type
=
'
gray
'
# 'gray' or 'color'
image_type
=
'
gray
'
# 'gray' or 'color'
downscale_factor
=
100
# % of original size
downscale_factor
=
100
# % of original size
points_path
=
'
./tests/LiveWireEnd
Points.npy
'
points_path
=
'
bipes
Points.npy
'
# Load image
# Load image
image
=
load_image
(
image_path
,
image_type
)
image
=
load_image
(
image_path
,
image_type
)
...
@@ -132,4 +141,4 @@ def main():
...
@@ -132,4 +141,4 @@ def main():
plt
.
show
()
plt
.
show
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
main
()
main
()
\ No newline at end of file
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