4
$\begingroup$

I recently posted a question. And I got a great answer from Mr. Carl Lange

Image Segmentation

His solution worked like a charm. However, I got another request which is more generic in nature. The request is to be able to pick out the foreground car and eliminate background cars. The test picture input picture is this

Input

And the result I am currently getting is this:

enter image description here

But it should be more like this:

enter image description here

Any ideas would be greatly appreciated. Thanks.

$\endgroup$
  • $\begingroup$ In other words, the background cars should be filtered out. $\endgroup$ – Alberto Artasanchez Apr 25 '18 at 21:23
8
$\begingroup$

There's an undocumented function called ImageContents that will give you bounding boxes for various objects in your image. (This likely is some nice wrappers over the YOLO V2 network which you could use directly.)

enter image description here

First we set up a quick getCarMask function from the previous answer:

getCarMask[img_] := 
 Map[# /. {21 -> 1, _ -> 0} &, netevaluate[img], {2}]

If you know that the car you care about is going to be the biggest car, do something like:

imask=SetAlphaChannel[img,mask]

where the mask is the above mask

ImageContents[imask][
 Select[#Concept == Entity["Concept", "Auto::p735c"] &]][
 First, "Image"]

to get the largest "car" bounding box.

From here you could, for instance, attempt to re-run the original answer's method on this smaller section, or do some other processing to get a better answer - doing EdgeDetect,ImageSaliencyFilter, and GrowCutComponents might be a good place to start. Hope that helps, sorry it's not a drop-in answer - hopefully a decent starting point though.

I stress that you could probably get the same/similar result without using the undocumented ImageContents by using the YOLO V2 network.

$\endgroup$
  • $\begingroup$ Carl, you are a rock star. Thanks. $\endgroup$ – Alberto Artasanchez Apr 26 '18 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.