Small Satellites

Home » Image Processing » Vehicle detection, blob analysis

Vehicle detection, blob analysis

clc; clear all; close all;

% Read a grayscale or color image from the file
img = imread('car3.jpg');
% Display the grayscale image I
figure(1)
imshow(img)

Blob_01

Convert the grayscale image I to a binary image

bwi = im2bw(img, graythresh(img));
bwi =~bwi; % As bacground is light its better to inverse the image
figure(2)
imshow(bwi)

Blob_02

Remove from a binary image all connected components (objects) that have fewer than 100 pixels.do some adjsutements based on image

bwi = bwareaopen(bwi,100);
figure(3);
imshow(bwi);
% Create morphological structuring element, something which resemples the
% blob
str = strel('square',20);
bw = imdilate(bwi,str);

Blob_03

Trace region boundaries in binary image, As you see there might be some false detections.

[B,L] = bwboundaries(bw,'noholes');
figure(4);
imshow(img);
hold on
for i = 1:length(B)
      plot(B{i}(:,2), B{i}(:,1), 'r', 'LineWidth', 2.5)
end

Blob_04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Recent Post

%d bloggers like this: