How to get data for Matlab cascade Object Detector? - matlab

I want to use the trainCascadeObjectDetector in Matlab. It requires an array with the regions of interest of the images. I found two apps where you can put boxes around the rois and the array gets created automatically:
Cascade Trainer: Specify Ground Truth, Train a Detector
Training Image Labeler
Unfortunately they both require Matlab R2014 and I only got R2013.
Is there an other way to define the rois without manually creating the array?
Regards
Philip

I did not find an other solution so I wrote a custom Matlab script for the job. The imrect function in Matlab is well suitable for this. After the image is shown, the user can drag a rectangular over the region of interest. The coordinates of the region than get stored in a structure together with the path to the image file. Additionally the parts of the image that do not belong to the roi are stored in the negative sample folder.

Related

Matlab: Find pattern in an image given a skeletonized template

I am stuck at a current project:
I have an input picture showing the ground with some shapes on it. I have to find a specific shape with a given template.
I have to use distance transformation into skeletonization. My question now is: How can I compare two skeletons? As far as I noticed and have been told, the most methods from the Image Processing Toolbox to match templates don't work, since they are not scale-invariant and rotation invariant.
Also some skeletons are really showing the shapes, others are just one or two short lines, with which I couldn't identify the shapes, if I didn't know what they should be.
I've used edge detection, and region growing on the input so there are only interessting shapes left.
On the template I used distance transformation and skeletonization.
Really looking forward to some tips.
Greetings :)
You could look into convolutions?
Basically move your template over your image and see if there is a match, and where.
The max value of your array [x,y] is the location of your object in the image.
Matlab has a built-in 2D convolution function for this

Tracking 'objects' and labelling with the same labels between images/arrays in MATLAB

This is essentially a question about blob/feature tracking in MATLAB.
I have a series of sequential arrays (for simplicity, say 5 at this stage) with a background of 0 values, and then multiple objects (blobs) within each array. This is in MATLAB. These blobs can change position and size, and appear or disappear altogether, between arrays.
I'd like to label any of the blobs that are in the same position between arrays with the same ID (either a number or a letter).
Also need to incorporate functionality so that if a new pixel is added to the edge of a blob in a previous image, then it would be given the same ID.
And some functionality so that if a blob appeared in any previous array (say it was in array 1, disappeared in arrays 2 and 3, and then reappeared in 4 and 5), then it would be given the same ID as it originally had in the 1st array.
I've currently been trying to use the bwlabel function in MATLAB to do this but obviously each sequential array is labelled independently of the previous ones, so there is no 'tracking' of blobs from one image to another, and the numbers for each blob change based on how many blobs there are in that array and their positions.
Would be very grateful of any thoughts/comments on how to do this. If further clarification is required on this question, please also let me know. Many thanks in advance.
There is functionality for object tracking in the Computer Vision System Toolbox. There is an implementation of the Kalman filter (vision.KalmanFilter) that you can use to predict the location of an object in the next video frame, and a function called assignDetectionsToTracks that you can use to associate the objects across frames. See the Motion-Based Multiple Object Tracking example.

Fit two binary images (panorama?)

I have several binary images which represent a partial map of an area (~4m radius) and were taken ~0.2m apart, for example:
(Sorry for the different axis limit).
If you look closely, you'll see that the first image is about 20cm to the right.
I want to be able to create a map of the area from several pictures like this.
I've tried several methods, such as Matlab's register but couldn't find any good algorithm for this purpose. Any ideas on how to approach this?
Thanks in advance!
Two possible routes:
Use imregister. This does registration based on image intensity. You will probably want a rigid transform.
However, this will require your data to be an image (matrix), which it doesn't look like it currently is.
Alternatively, you can use control points. These are common (labelled) points in each image which provide a reference to determine the transform.
Matlab has a built in function to determine control points, cpselect. However, again this requires image data. You may be better of writing your own function to do this or just selecting control points manually.
Once you have control points you can determine the transform between them using fitgeotrans

Matlab - Center of mass of object having only its edge

I'm trying to make an object recognition program using a k-NN classifier. I've got a bunch of images for the training part of the classifier and a bunch of images to recognize. Those images are in grayscale and there's an object per image. The problem is that there's only the edge of the object (not filled), so I don't think using regionprops(img,'centroid') will work properly for what I understand...
So how can I get their center of mass?
xenoclast's answer should be quite clear, just to add something extra.
As you are done creating the binary image from the grayscale image of yours using im2bw; if the edge of your the object is a the boundary that covers the object fully, you may use regionprops(bw,'centroid') directly without going through imfill.
The first step would be to binarise the image with im2bw. Then you can use imfill(img, 'holes') to turn it from an outline into a filled solid. After that regionprops will work as expected.

Using Haar features for cascade object detector MATLAB

I am trying to use the vision.cascadeObjectDetector (MATLAB) to detect heads from a CCTV footage(and not faces). Till now, I have tried the following:
Used vision.cascadeObjectDetector to detect faces.
trained it to detect a sign (an example shown in read me file)
created a folder with positive & negative training HEAD images & same for testing
tried to create a .mat file using trainingImageLabeler (although it gave me an error when trying to pass it as param to the object detector).
Can someone try to put me in the right track, to start detecting heads using Viola-Jones Haar features please?