How to identify different objects in an image?

后端 未结 3 887
孤城傲影
孤城傲影 2021-02-05 12:13

I\'m intending to write a program to detect and differentiate certain objects from a nearly solid background. The foreground and the background have a high contrast difference w

3条回答
  •  感情败类
    2021-02-05 12:28

    If you intend to detect shapes other than just circles, (and from the image I assume you do), I would recommend the Chamfer matching for a quick start, especially as you have a good contrast.

    The basic premise, explained in simple terms, is following:

    1. You do an edge detection (for example, cvCanny in opencv)
    2. You create a distance image, where the value of each pixel means the distance fom the nearest edge.
    3. You take the shapes you would like to detect, define sample points along the edges of the shape, and try to match these points on the distance image. Basically you just add the values on the distance image which are "under" the coordinates of your sample points, given a specific position of your objects.
    4. Find a good minimization algorithm, the effectiveness of this depends on your application.

    This basic approach is a general solution, usually works well, but without further advancements, it is very slow.

    Usually it's a good idea to first separate the objects of interest, so you don't have to always do the full search on the whole image. Find a good threshold, so you can separate objects. You still don't know which object it is, but you only have to do the matching itself in close proximity of this object.

    Another good idea is, instead of doing the full search on the high resolution image, first do it on a very low resolution. The result will not be very accurate, but you can know the general areas where it's worth to do a search on a higher resolution, so you don't waste your time on areas where there is nothing of interest.

    There are a number of more advanced techniques, but it's still worth to take a look at the basic chamfer matching, as it is the base of a large number of techniques.

提交回复
热议问题