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

2 次查看(过去 30 天)
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');
subplot(3,3,1);
imshow(map, []);
[R,G,B] = imsplit(map);
subplot(3,3,2);
imshow(R, []);
Istrech = imadjust(R,stretchlim(R));
subplot(3,3,3);
imshow(Istrech, [])
filteredImage = imbothat(Istrech, true(50));
subplot(3,3,4);
imshow(filteredImage, []);
threshold = 130;
mask = imfill(filteredImage, 'holes');
subplot(3,3,5);
imshow(mask, []);
mask2 = mask > threshold;
subplot(3,3,6);
imshow(mask2, []);
mask3= bwareaopen(mask2, 9);
subplot(3,3,7);
imshow(mask3, []);
mask4 = bwareafilt(mask3, 1);
subplot(3,3,8);
imshow(mask4, []);
BW2 = bwpropfilt(mask4,'perimeter',20);
subplot(3,3,9);
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;

回答(2 个)

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

Image Analyst
Image Analyst 2022-1-5
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.

类别

Help CenterFile Exchange 中查找有关 Mapping Toolbox 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by