How can I get the blue line in google maps screenshot? And also how can I fill the blanks in line?

1 view (last 30 days)
Zeynep Calik
Zeynep Calik on 4 Jan 2022
Answered: Image Analyst on 5 Jan 2022
I need the coordinates of the blue road in google directions. But there are gaps because there are texts in between. I can't get the only blue part. I tried to do as below.
map = imread('map3.png');
imshow(map, []);
[R,G,B] = imsplit(map);
imshow(R, []);
Istrech = imadjust(R,stretchlim(R));
imshow(Istrech, [])
filteredImage = imbothat(Istrech, true(50));
imshow(filteredImage, []);
threshold = 130;
mask = imfill(filteredImage, 'holes');
imshow(mask, []);
mask2 = mask > threshold;
imshow(mask2, []);
mask3= bwareaopen(mask2, 9);
imshow(mask3, []);
mask4 = bwareafilt(mask3, 1);
imshow(mask4, []);
BW2 = bwpropfilt(mask4,'perimeter',20);
imshow(BW2, []);
I also need to embed this path as a MAtlab function in simulink like shown in below. How can I do that?
function y = fcn(u)
y = u;

Answers (2)

Image Analyst
Image Analyst on 4 Jan 2022
Use the Color Thresholder tool on the Apps tab of the tool ribbon.
See attached demo.

Image Analyst
Image Analyst on 5 Jan 2022
Well you could try imclose() though that may change the shapes slightly. Or you could try searching for edge linking routines. See link and attachment, and do a web search yourself.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by