Home » Posts tagged 'Path Planning for Mobile Robots via Skeletons'
Tag Archives: Path Planning for Mobile Robots via Skeletons
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);
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%
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');
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');