Object Tracking

We now have all the tools we require to find an object in an image and measure its properties. We also know how to get the location of the object in two dimensional space. In this part of the course, we are going to translate this knowledge to three-dimensional space. But before we do this, we are going to learn a little trick which will make our ability to track objects much better.

Image Registration

You register images to make sure that small movements in the image acquisition process are corrected for. Matlab has an automatic, intensity based registration algorithm and it can be used as below. Let's use our plankton data

%% Read in plankton and shift it.

plankton= imread('plankton.png'); % read in plankton.png
rotated_plankton=imrotate(plankton, 5, 'bilinear', 'crop'); % rotate plankton
imshowpair(plankton, rotated_plankton,'Scaling','joint'); % display original and rotated images together.

% Create a configuration object
[optimizer, metric]= imregconfig('monomodal')

% Pass the configuration object back in to imregister

registeredplankton= imregister(rotated_plankton, plankton, 'rigid', optimizer, metric);

% Display the images side by side.

imshowpair(plankton, registeredplankton, 'Scaling', 'joint');

Challenge 1: Registering Fingerprints

Using a for loop, load in all 8 fingerprints from the fingerprint data set. Hint: Use num2str. Register each fingerprint to the first fingerprint.

Morphological operators

Morphological operators such as imopen and imclose are quite useful, especially when two separate objects are placed close together or the same object is split by a sharp border. imopen fuses objects that are separated by thin lines whereas imclose separates these objects.

Morphological operators use structural elements. These can be created as follows:

se= strel('disk', 5);

Once the structural element has been created, the morphological operator then applies these structural elements to open or close an image.

 
opened_image= imopen(image, se);
closed_image= imclose(image, se);

Object Tracking

For this part, we are going to do a challenge together. We've done most things we need for object tracking. Now we can put it together. Download the data from here:

%Let us read in the video.
video_ob= VideoReader('angrybirds.avi');
angrybirds= read(video_ob);

% Show video
implay(angrybirds, 10);

The rest of this course is interactive and involves the group solving the problem together. Solutions will be posted in the repository. Remember the steps to detect an object? In the first step, we first need to convert our image into grayscale. Even though colour information may be quite useful in this case. Then we will convert the image into a binary image to make a mask. This will be followed by obtaining the position of the angry bird using regionprops.

results matching ""

    No results matching ""