Ask Your Question

Image Segmentation

asked 2017-09-08 09:00:51 -0600

fj_abbasi gravatar image

updated 2017-09-09 07:36:24 -0600

I m working on road detection, I am following an approach as mention in this paper, which is based on the concept of reference circles from a distance transformed image. This approach is good to identify road pixels but along with that it also detects non road pixel as shown in yellow circles in an image below. I want to get rid of these regions. I removed the vegetation using NDVI but I am not sure how to get rid of ground pixels. Can someone please suggest me the possible ways to get rid of ground pixels or how to segment out the road region?

image = cv2.imread(r"C:\Users\x\Desktop\sampleImg\aoi.tif")
gray = cv2.cvtColor(rgb_img, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)

# Apply canny
canny_img = auto_canny(blurred)
invert_canny = 255 - canny_img

#Distance transformed image
dst_trans= cv2.distanceTransform(invrt_canny, cv2.DIST_L2, 3)

#Reference Circles
image_max= ndi.maximum_filter(dst_trans, (3,3), mode='constant')
comp=, image_max, cv2.CMP_EQ)
peaks= cv2.multiply(dist_trans, comp, 1/255.0, dtype=cv2.CV_8UC1)

#removing vegetaion
ndvi_map[ndvi_map > 0] = 0
ndvi_im= np.array(ndvi_map*255, dtype=np.uint8)
msk_peaks= cv2.bitwise_and(peaks,peaks, mask=ndvi_im)

#Hough transfomation
lines = cv2.HoughLinesP(image=peaks,rho=1,theta=np.pi/180, threshold=10,lines=np.array([]), minLineLength=5,maxLineGap=3)
a,b,c = lines.shape
for i in range(a):
    cv2.line(image, (lines[i][0][0], lines[i][0][1]), (lines[i][0][2], lines[i][0][3]), (255, 0, 0), 2, cv2.LINE_AA)

orignal image original image based on Reference cirlces based on reference circles hough transformation Hough transformed

edit retag flag offensive close merge delete


K-mean clustering (gpu version) is an option if you want to try it. If you already made road mask and vegetation mask just add both masks and use copyTo function to get only terrain pixels.

Ziri gravatar imageZiri ( 2017-09-08 09:24:52 -0600 )edit

if you add the original image and the code you tried. you will help those people who want to help you.

sturkmen gravatar imagesturkmen ( 2017-09-08 10:47:10 -0600 )edit

@sturkmen i have edited the question.

fj_abbasi gravatar imagefj_abbasi ( 2017-09-09 07:39:20 -0600 )edit

@Ziri k-means clustters the road and ground pixels into same category as both regions are quite the same (here we have dirt roads).

fj_abbasi gravatar imagefj_abbasi ( 2017-09-12 02:36:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-09-13 07:25:10 -0600

Ziri gravatar image

Saturation band Saturation band

Threshold + Hough image description

But this is not a good approach because you need to set parameters for both (threshold and probabilistic Hough)

The best approach is to find features that describe road/non-road ()and make a classifier .

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-09-08 09:00:51 -0600

Seen: 1,118 times

Last updated: Sep 13 '17