0

In my project I want to extract color of vehicle as one of feature.I have images as shown below. Can someone suggest a way to extract color of the vehicle on image.

image 1

image 2

I am trying to extract vehicle region. Than it is easy to extract color of that region. I tried above code for edge detection and connected component detection. But it is not detecting contours of image.

    im1=cv2.imread("frame121020.jpg")
    blurred = cv2.blur(im1, (3,3))
    edges = cv2.Canny(blurred,50,200)       

    connectivity = 4 
    output = cv2.connectedComponentsWithStats(edges, connectivity, cv2.CV_32S)

    num_labels = output[0]
    Stats = output[2]

    for label in range(1,num_labels):
        cv2.rectangle(edges,(Stats[label,0],Stats[label,1]),(Stats[label,0]+Stats[label,2],Stats[label,1]+Stats[label,3]),(0,0,255),2)

    cv2.imwrite("edges.jpg" ,edges)
  • You can use the flood fill algorithm with some tolerance to select a large chunk of the vehicle's exterior, which can give you some description of the colors (min, max, std dev, mean, and you can change colorspaces and so on). However as it stands this isn't exactly a code question, which is what Stack Overflow is meant for. Have you tried anything in particular so far? – alkasm Feb 02 '19 at 11:45
  • I am trying to detect vehicle region and crop it. Then it is easy to extract color of that region. But still I don't have idea. – Sushani Nimesha Feb 02 '19 at 14:10
  • Then use an object detector. Have you tried any object detection frameworks? – alkasm Feb 02 '19 at 14:22
  • Alexander Reynolds, In my project I am not using any object detection framework. I am trying with edge detection. – Sushani Nimesha Feb 02 '19 at 14:34
  • Well...where's your code with edge detection? Stack Overflow isn't a forum to chat; it's a Q and A site to help diagnose code problems. There's no code problems here, so you're very unlikely to get any responses. – alkasm Feb 02 '19 at 14:39

0 Answers0