Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify different objects in an image?

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 which I would further increase to aid in the object identification process. I'm planning to use Hough transform technique and OpenCV.

Sample image

As seen in the above image, I would want to separately identify the circular objects and the square objects (or any other shape out of a finite set of shapes). Since I'm quite new to image processing I do not have an idea whether such a situation needs a neural network to be implemented and each shape to be learned beforehand. Would a technique such as template matching let me do this without a neural network?

like image 551
Tru Avatar asked Mar 11 '12 20:03

Tru


People also ask

How do you identify multiple objects?

If there are multiple object to localize on an image, we use multiple object detection. As like the object localization, neural network creates 7 output vectors, but grid by grid. One image is divided by a grid 4 by 4 or 16 by 16 etc.. This example has 4 x 4 grid.

Which is used to identify multiple types of items in one image?

Object localization identifies multiple objects in an image and provides a LocalizedObjectAnnotation for each object in the image. Each LocalizedObjectAnnotation identifies information about the object, the position of the object, and rectangular bounds for the region of the image that contains the object.

How do we identify objects?

Whenever we look at any object, our brain extracts the features and in such a way that the size, orientation, illumination, perspective etc don't matter. You remember an object by its shape and inherent features. It doesn't matter how the object is placed, how big or small it is or what side is visible to you.


2 Answers

These posts will get you started:

  • How to detect circles

  • How to detect squares

  • How to detect a sheet of paper (advanced square detection)

You will probably have to adjust some parameters in these codes to match your circles/squares, but the core of the technique is shown on these examples.

like image 50
karlphillip Avatar answered Nov 01 '22 14:11

karlphillip


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.

like image 45
vsz Avatar answered Nov 01 '22 13:11

vsz