Skip to content
Snippets Groups Projects
Commit 641d222f authored by Christian's avatar Christian
Browse files

Added feature increasing contrast before creating cost image

parent 5d292d48
Branches
No related tags found
1 merge request!3Live wire to be implemented into GUI
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
......@@ -2,7 +2,7 @@ import time
import cv2
import numpy as np
import matplotlib.pyplot as plt
from skimage import exposure
from skimage.filters import gaussian
from skimage.feature import canny
from skimage.graph import route_through_array
......@@ -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.
"""
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)
# Create cost image
cost_img = 1.0 / (canny_img + epsilon) # Invert edges: higher cost where edges are stronger
return cost_img, canny_img
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
#### Main Script ####
def main():
# Define input parameters
image_path = './tests/slice_60_volQ.png'
image_path = 'bipes_slice.png'
image_type = 'gray' # 'gray' or 'color'
downscale_factor = 100 # % of original size
points_path = './tests/LiveWireEndPoints.npy'
points_path = 'bipesPoints.npy'
# Load image
image = load_image(image_path, image_type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment