0
votes

I am trying to detect edges on this lane image. First blurred the image using Gaussian filter and applied Canny edge detection but it gives only blank image without detecting edges.

input image enter image description here

I have done like this:

#imports
import matplotlib.pyplot as plt
import numpy as np
import cv2
import matplotlib.image as mpimg

image= mpimg.imread("Screenshot from Lane Detection Test Video 01.mp4.png")
image = image[:,:,:3]
image_g = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)

image_blurred = cv2.GaussianBlur(image_g, (3, 3), 0)
threshold_low = 50
threshold_high = 100
image_blurred = image_blurred.astype(np.uint8)
image_canny = cv2.Canny(image_blurred, threshold_low, threshold_high)
plt.imshow(image_canny,cmap='gray')  
1
Your code seems to work for me. Could you please share the original images?Ash
Actually, this is a screenshot from a video. I read the screenshot. I don't understand what you mean by original images.NSVR
This is the screenshot from the following YouTube video: youtu.be/6q5_A5wOwDMNSVR
Thanks for sharing that, but it's not what I meant. If you want people here to be able to replicate your problem, you need to share the exact image_g that you pass to blur, not the results from plt.imshow that you get after your processing. I tested your code with random images, and it works for me, so it's probably an issue with the data type or something.Ash
@Ash Thanks for your patience. I have updated my code includes imports. , added input image and output image. Can you please look into this issue. Thanks in advaceNSVR

1 Answers

1
votes

You should always examine your data. Simply running your script step by step and examining intermediate values shows what is going wrong: mpimg.imread reads the image as a floating-point array with values between 0 and 1. After blurring, you cast it to uint8, which sets almost all values to 0. Simply multiplying the image by 255 at some point before casting to uint8 solves your issue.