Small Satellites

Home » Featured » Computing a Skeleton of a Map for Mobile Robots,Path Planning

Computing a Skeleton of a Map for Mobile Robots,Path Planning

clc;close all;clear all;

Input Map

RGB = imread('Map1.png');
figure('Position',[0 0 800 800]);
imshow(RGB);

Robot Map1

Convert to binary image matrix and inverse matrix values

I = rgb2gray(RGB);
binaryImage = im2bw(RGB, 0.3);
binaryImage = 1-binaryImage;
figure('Position',[0 0 800 800]);
imshow(binaryImage);
Warning: Image is too big to fit on screen; displaying at
50%

Robot Map 1

Compute for every pixel the distance to the nearest obstacle(non zero elements which after inversion corespondent to the obstacles)

[D,IDX] = bwdist(binaryImage);
figure('Position',[0 0 800 800],'color','k')
colormap bone
image(D);
axis off          % Remove axis ticks and numbers
axis image
set(gcf, 'InvertHardCopy', 'off');

Robot Map 3

Taking the Laplacian of the distance transform. Play with the treshold value 0.15 to remove or add more futures in skeleton

lap = del2(D);
sz  = size(lap);
for i = 1:sz(1)
    for j = 1:sz(2)
         if( abs(lap(i,j)) < 0.15)
       lap(i,j) = 0;
    end
    end
end
lap = flipdim(lap ,1);           %# vertical flip
figure('Position',[0 0 800 800],'color','k');
colormap winter;
contour(lap,'DisplayName','lap');
axis off
axis image
set(gcf, 'InvertHardCopy', 'off');

 

Advertisement

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 )

Facebook photo

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

Connecting to %s

Recent Post

%d bloggers like this: